Class: Elementary::Executor
- Inherits:
-
Object
- Object
- Elementary::Executor
- Defined in:
- lib/elementary/executor.rb
Instance Attribute Summary collapse
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
Instance Method Summary collapse
-
#initialize(service, transport, future_opts = {}) ⇒ Executor
constructor
A new instance of Executor.
- #method_missing(method_name, *params) ⇒ Object
Constructor Details
#initialize(service, transport, future_opts = {}) ⇒ Executor
Returns a new instance of Executor.
6 7 8 9 10 |
# File 'lib/elementary/executor.rb', line 6 def initialize(service, transport, future_opts={}) @service = service @transport = transport @future_opts = future_opts end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *params) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/elementary/executor.rb', line 12 def method_missing(method_name, *params) rpc_method = service.rpcs[method_name.to_sym] # XXX: explode if rpc_method is nil future = Elementary::Future.new(@future_opts) do # This is effectively a Rack middleware stack. yay. # # Easiest to think of it like this: # Statsd.new(HTTP.new(nil)) stack = Elementary.middleware.inject(transport) do |accumulator, middleware| klass = middleware.first = middleware.last klass.new(accumulator, ) end stack.call(service, rpc_method, *params) end return future.execute end |
Instance Attribute Details
#service ⇒ Object (readonly)
Returns the value of attribute service.
4 5 6 |
# File 'lib/elementary/executor.rb', line 4 def service @service end |
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
4 5 6 |
# File 'lib/elementary/executor.rb', line 4 def transport @transport end |