Class: Peplum::Application
- Inherits:
-
Cuboid::Application
- Object
- Cuboid::Application
- Peplum::Application
- Defined in:
- lib/peplum/application.rb,
lib/peplum/application/peers.rb,
lib/peplum/application/services/scheduler.rb,
lib/peplum/application/services/shared_hash.rb
Defined Under Namespace
Modules: Services Classes: Error, Peers
Instance Attribute Summary collapse
-
#peers ⇒ Object
readonly
Returns the value of attribute peers.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Application
constructor
A new instance of Application.
-
#payload ⇒ Object
abstract
Implements: * ‘.run` – Worker; executes its payload against `objects`.
- #report(data) ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
31 32 33 34 35 |
# File 'lib/peplum/application.rb', line 31 def initialize(*) super @peers = Peers.new end |
Instance Attribute Details
#peers ⇒ Object (readonly)
Returns the value of attribute peers.
29 30 31 |
# File 'lib/peplum/application.rb', line 29 def peers @peers end |
Class Method Details
.inherited(application) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/peplum/application.rb', line 16 def inherited( application ) super Cuboid::Application.application = application application. :validate_options application.serialize_with JSON application.instance_service_for :scheduler, Services::Scheduler application.instance_service_for :shared_hash, Services::SharedHash end |
Instance Method Details
#payload ⇒ Object
This method is abstract.
Implements:
* `.run` -- Worker; executes its payload against `objects`.
* `.group` -- Splits given `objects` into groups for each worker.
* `.merge` -- 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, 'Missing payload app!' end |
#report(data) ⇒ Object
68 69 70 |
# File 'lib/peplum/application.rb', line 68 def report( data ) super payload.merge( data ) end |
#run ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/peplum/application.rb', line 37 def run Raktr.global.on_error do |_, e| $stderr.puts e end = @options.dup = .delete( 'peplum' ) = .delete( 'payload' ) # We have a master so we're not the scheduler, run the payload. if ['master'] execute( , ) # We're the scheduler Instance, get to grouping and spawning. else schedule( , ) end end |