Class: Protobuf::Rpc::SocketRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/protobuf/rpc/servers/socket_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ SocketRunner

Returns a new instance of SocketRunner.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/protobuf/rpc/servers/socket_runner.rb', line 11

def initialize(options)
  options = case
             when options.is_a?(OpenStruct) then
               options.marshal_dump
             when options.is_a?(Hash) then
               options
             when options.respond_to?(:to_hash) then
               options.to_hash
             else
               fail "Cannot parser Socket Server - server options"
             end

  self.server = ::Protobuf::Rpc::Socket::Server.new(options)
end

Instance Method Details

#runObject



26
27
28
29
# File 'lib/protobuf/rpc/servers/socket_runner.rb', line 26

def run
  yield if block_given?
  server.run
end

#running?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/protobuf/rpc/servers/socket_runner.rb', line 31

def running?
  server.running?
end

#stopObject



35
36
37
# File 'lib/protobuf/rpc/servers/socket_runner.rb', line 35

def stop
  server.stop
end