Class: Peplum::Application
- Inherits:
-
Cuboid::Application
- Object
- Cuboid::Application
- Peplum::Application
- Defined in:
- lib/peplum/application.rb,
lib/peplum/application/worker.rb,
lib/peplum/application/payload.rb,
lib/peplum/application/services/scheduler.rb,
lib/peplum/application/services/shared_hash.rb
Defined Under Namespace
Modules: Payload, Services, Worker Classes: Error
Class Method Summary collapse
Instance Method Summary collapse
-
#payload ⇒ #run, ...
abstract
-
‘#run` – Worker; executes its payload against `objects`.
-
-
#report(data) ⇒ Object
Overload Cuboid#report and delegate to the Payload#merge prior passing it on to Cuboid.
- #run ⇒ Object
Class Method Details
.inherited(application) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/peplum/application.rb', line 20 def inherited( application ) super # Don't trust Cuboid's auto-detection for this, make sure the inheriting class is the Cuboid application. Cuboid::Application.application = application application. :validate_options application.serialize_with MessagePack application.instance_service_for :scheduler, Services::Scheduler # Shared, in-memory key-value store for the workers, the scheduler will not be participate. application.instance_service_for :shared_hash, Services::SharedHash end |
Instance Method Details
#payload ⇒ #run, ...
This method is abstract.
Returns * ‘#run` – Worker; executes its payload against `objects`.
-
‘#split` – Scheduler; splits given `objects` into groups for each worker.
-
‘#merge` – Scheduler; merges results from multiple workers.
That’s all we need to turn any application into a super version of itself.
64 65 66 |
# File 'lib/peplum/application.rb', line 64 def payload fail Error::PayloadMissing, 'Missing #payload implementation!' end |
#report(data) ⇒ Object
Overload Cuboid#report and delegate to the Peplum::Application::Payload#merge prior passing it on to Cuboid.
70 71 72 |
# File 'lib/peplum/application.rb', line 70 def report( data ) super payload.merge( data ) end |
#run ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/peplum/application.rb', line 36 def run = @options.dup # System options. = .delete( 'peplum' ) # Payload options. = .delete( 'payload' ) # We have a master so we're a worker, run the payload. if ['master'] work( , ) # We're the scheduler Instance, get to grouping objects and spawning workers. else schedule( , ) end end |