Class: Workling::Routing::StaticRouting
- Defined in:
- lib/workling/routing/static_routing.rb
Instance Method Summary collapse
-
#initialize(*args) ⇒ StaticRouting
constructor
./script/workling_client run – <worker_class> <worker_method> <routing_key> ./script/workling_client run – <worker_class> <worker_method> <routing_key> <queue_name>.
-
#method_name(queue = nil) ⇒ Object
returns the worker method name, given the routing string.
-
#queue_for(clazz = nil, method = nil) ⇒ Object
returns the routing string, given a class and method.
-
#queue_names ⇒ Object
returns array containing the single configured route.
-
#queue_names_routing_class(clazz) ⇒ Object
TODO - not sure what this is…
- #routing_key_for ⇒ Object
Constructor Details
#initialize(*args) ⇒ StaticRouting
./script/workling_client run – <worker_class> <worker_method> <routing_key>
./script/workling_client run – <worker_class> <worker_method> <routing_key> <queue_name>
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/workling/routing/static_routing.rb', line 12 def initialize(*args) @worker = args[0].constantize.new @method_name = args[1] @routing_key = args[2] if(args.size==4) @queue_name = args[3] else @queue_name = [@worker.class.to_s.tableize, @method_name, @routing_key].join("__") end # so routing[x] hash access works as expected self.default = @worker end |
Instance Method Details
#method_name(queue = nil) ⇒ Object
returns the worker method name, given the routing string.
28 |
# File 'lib/workling/routing/static_routing.rb', line 28 def method_name(queue=nil); @method_name; end |
#queue_for(clazz = nil, method = nil) ⇒ Object
returns the routing string, given a class and method. delegating. TODO - we can check for consistency here with clazz and methods vs. current configuration of this single route
34 |
# File 'lib/workling/routing/static_routing.rb', line 34 def queue_for(clazz=nil, method=nil); @queue_name; end |
#queue_names ⇒ Object
returns array containing the single configured route
37 |
# File 'lib/workling/routing/static_routing.rb', line 37 def queue_names; [@queue_name]; end |
#queue_names_routing_class(clazz) ⇒ Object
TODO - not sure what this is…
40 |
# File 'lib/workling/routing/static_routing.rb', line 40 def queue_names_routing_class(clazz); @worker.class; end |
#routing_key_for ⇒ Object
30 |
# File 'lib/workling/routing/static_routing.rb', line 30 def routing_key_for; @routing_key; end |