Class: Protobuf::Nats::Runner
- Inherits:
-
Object
- Object
- Protobuf::Nats::Runner
- Includes:
- Logging
- Defined in:
- lib/protobuf/nats/runner.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
- #running? ⇒ Boolean
- #stop ⇒ Object
Constructor Details
#initialize(options) ⇒ Runner
Returns a new instance of Runner.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/protobuf/nats/runner.rb', line 11 def initialize() @options = case when .is_a?(OpenStruct) then .marshal_dump when .respond_to?(:to_hash) then .to_hash.symbolize_keys else fail "Cannot parse Nats Server - server options" end end |
Instance Method Details
#run ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/protobuf/nats/runner.rb', line 22 def run @server = ::Protobuf::Nats::Server.new(@options) register_signals @server.run do yield if block_given? end end |
#running? ⇒ Boolean
30 31 32 |
# File 'lib/protobuf/nats/runner.rb', line 30 def running? @server.try :running? end |
#stop ⇒ Object
34 35 36 |
# File 'lib/protobuf/nats/runner.rb', line 34 def stop @server.try :stop end |