Class: Conquer::Container
- Inherits:
-
Object
- Object
- Conquer::Container
- Defined in:
- lib/conquer/container.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Worker
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Instance Method Summary collapse
-
#initialize(topic) ⇒ Container
constructor
A new instance of Container.
- #register(child_class, *args) ⇒ Object
- #start_worker ⇒ Object
Constructor Details
#initialize(topic) ⇒ Container
Returns a new instance of Container.
36 37 38 39 |
# File 'lib/conquer/container.rb', line 36 def initialize(topic) @topic = topic @children = {} end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
34 35 36 |
# File 'lib/conquer/container.rb', line 34 def children @children end |
Instance Method Details
#register(child_class, *args) ⇒ Object
41 42 43 44 |
# File 'lib/conquer/container.rb', line 41 def register(child_class, *args) id = SecureRandom.uuid @children[id] = child_class.new(id, *args) end |
#start_worker ⇒ Object
46 47 48 49 |
# File 'lib/conquer/container.rb', line 46 def start_worker Worker.supervise(args: [@topic, @children.keys]) @children.values.each(&:start_worker) end |