class Protobuf::Nats::Runner

Public Class Methods

new(options) click to toggle source
# 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

Public Instance Methods

run() { || ... } click to toggle source
# 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?() click to toggle source
# File lib/protobuf/nats/runner.rb, line 30
def running?
  @server.try :running?
end
stop() click to toggle source
# File lib/protobuf/nats/runner.rb, line 34
def stop
  @server.try :stop
end

Private Instance Methods

register_signals() click to toggle source
# File lib/protobuf/nats/runner.rb, line 40
      def register_signals
        trap(:TRAP) do
          ::Thread.list.each do |thread|
            logger.info do
              <<-THREAD_TRACE
                #{thread.inspect}:
                  #{thread.backtrace.try(:join, $INPUT_RECORD_SEPARATOR)}"
              THREAD_TRACE
            end
          end
        end

      end