Class: OMQ::CLI::BaseRunner
- Inherits:
-
Object
- Object
- OMQ::CLI::BaseRunner
- Defined in:
- lib/omq/cli/base_runner.rb
Overview
Template runner base class for all socket-type CLI runners. Subclasses override #run_loop to implement socket-specific behaviour.
Direct Known Subclasses
DishRunner, GatherRunner, PairRunner, PubRunner, PullRunner, PushRunner, RadioRunner, RepRunner, ReqRunner, RouterRunner, ScatterRunner, ServerRunner, SubRunner
Instance Attribute Summary collapse
- #config ⇒ Config, Object readonly
- #sock ⇒ Config, Object readonly
Instance Method Summary collapse
-
#call(task) ⇒ void
Runs the full lifecycle: socket setup, peer wait, BEGIN/END blocks, and the main loop.
-
#initialize(config, socket_class) ⇒ BaseRunner
constructor
A new instance of BaseRunner.
Constructor Details
#initialize(config, socket_class) ⇒ BaseRunner
Returns a new instance of BaseRunner.
15 16 17 18 19 |
# File 'lib/omq/cli/base_runner.rb', line 15 def initialize(config, socket_class) @config = config @klass = socket_class @fmt = Formatter.new(config.format) end |
Instance Attribute Details
#config ⇒ Config, Object (readonly)
10 11 12 |
# File 'lib/omq/cli/base_runner.rb', line 10 def config @config end |
#sock ⇒ Config, Object (readonly)
10 11 12 |
# File 'lib/omq/cli/base_runner.rb', line 10 def sock @sock end |
Instance Method Details
#call(task) ⇒ void
This method returns an undefined value.
Runs the full lifecycle: socket setup, peer wait, BEGIN/END blocks, and the main loop.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/omq/cli/base_runner.rb', line 26 def call(task) set_process_title setup_socket start_event_monitor maybe_start_transient_monitor(task) sleep(config.delay) if config.delay && config.recv_only? wait_for_peer if needs_peer_wait? run_begin_blocks run_loop(task) run_end_blocks rescue OMQ::SocketDeadError => error reason = error.cause&. || error. $stderr.write("omq: #{reason}\n") exit 1 ensure @sock&.close end |