Class: Protobuf::Nats::Runner

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/protobuf/nats/runner.rb

Instance Method Summary collapse

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)
  @options = case
             when options.is_a?(OpenStruct) then
               options.marshal_dump
             when options.respond_to?(:to_hash) then
               options.to_hash.symbolize_keys
             else
               fail "Cannot parse Nats Server - server options"
             end
end

Instance Method Details

#runObject



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

Returns:

  • (Boolean)


30
31
32
# File 'lib/protobuf/nats/runner.rb', line 30

def running?
  @server.try :running?
end

#stopObject



34
35
36
# File 'lib/protobuf/nats/runner.rb', line 34

def stop
  @server.try :stop
end