Class: GDK::Services::Base Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/gdk/services/base.rb

Overview

This class is abstract.

Base class to be used by individual service classes.

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



10
11
12
# File 'lib/gdk/services/base.rb', line 10

def initialize
  validate_env_keys!
end

Instance Method Details

#commandString

This method is abstract.

to be implemented by the subclass

Command to execute the service

Returns:

  • (String)

    command

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/gdk/services/base.rb', line 26

def command
  raise NotImplementedError
end

#enabled?Boolean

Is service enabled?

Returns:

  • (Boolean)

    whether is enabled or not



41
42
43
# File 'lib/gdk/services/base.rb', line 41

def enabled?
  false
end

#envHash

Environment variables

this service.

Returns:

  • (Hash)

    a hash of environment variables that need to be set for



49
50
51
# File 'lib/gdk/services/base.rb', line 49

def env
  {}
end

#nameString

This method is abstract.

to be implemented by the subclass

Name of the service

Returns:

  • (String)

    name

Raises:

  • (NotImplementedError)


18
19
20
# File 'lib/gdk/services/base.rb', line 18

def name
  raise NotImplementedError
end

#procfile_entryString

Entry to be used in Procfile.

Returns:

  • (String)

    in the format expected used in Procfiles.



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/gdk/services/base.rb', line 56

def procfile_entry
  cmd = []
  cmd << '#' unless enabled?

  cmd += %W[#{name}: exec]
  if env.any?
    cmd << '/usr/bin/env'
    cmd += env.map { |k, v| "#{k}=\"#{v}\"" }
  end

  cmd << command
  cmd.join(' ')
end

#ready_messageString

This method is abstract.

to be implemented by the subclass

Message to display when the service is ready

Returns:

  • (String)

    ready_message

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/gdk/services/base.rb', line 34

def ready_message
  raise NotImplementedError
end