Class: Falcon::Service::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/falcon/service/generic.rb

Overview

Captures the stateful behaviour of a specific service. Specifies the interfaces required by derived classes.

Designed to be invoked within an Async::Controller::Container.

Direct Known Subclasses

Proxy, Supervisor

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ Generic

Initialize the service from the given environment.



41
42
43
44
# File 'lib/falcon/service/generic.rb', line 41

def initialize(environment)
	@environment = environment
	@evaluator = @environment.evaluator
end

Class Method Details

.wrap(environment) ⇒ Object

Convert the given environment into a service if possible.



32
33
34
35
36
37
# File 'lib/falcon/service/generic.rb', line 32

def self.wrap(environment)
	evaluator = environment.evaluator
	service = evaluator.service || self
	
	return service.new(environment)
end

Instance Method Details

#include?(keys) ⇒ Boolean

Whether the service environment contains the specified keys. This is used for matching environment configuration to service behaviour.

Returns:

  • (Boolean)


48
49
50
# File 'lib/falcon/service/generic.rb', line 48

def include?(keys)
	keys.all?{|key| @environment.include?(key)}
end

#loggerObject

The logger to use for this service.



60
61
62
# File 'lib/falcon/service/generic.rb', line 60

def logger
	return Console.logger # .with(name: name)
end

#nameObject

The name of the service. e.g. `myapp.com`.



54
55
56
# File 'lib/falcon/service/generic.rb', line 54

def name
	@evaluator.name
end

#setup(container) ⇒ Object

Setup the service into the specified container.



70
71
# File 'lib/falcon/service/generic.rb', line 70

def setup(container)
end

#startObject

Start the service.



65
66
# File 'lib/falcon/service/generic.rb', line 65

def start
end

#stopObject

Stop the service.



74
75
# File 'lib/falcon/service/generic.rb', line 74

def stop
end