Module: Elrpc
- Defined in:
- lib/elrpc.rb,
lib/elrpc/version.rb
Defined Under Namespace
Classes: CallMessage, EPCErrorMessage, EPCRuntimeError, EPCStackError, ErrorMessage, Method, MethodsMessage, RPCService, ReturnMessage, Service, WorkerPool
Constant Summary
collapse
- VERSION =
"0.0.7"
- @@default_log_level =
Logger::WARN
- @@count =
1
Class Method Summary
collapse
Class Method Details
.default_log_level ⇒ Object
22
23
24
|
# File 'lib/elrpc.rb', line 22
def self.default_log_level
@@default_log_level
end
|
.gen_uid ⇒ Object
28
29
30
31
|
# File 'lib/elrpc.rb', line 28
def self.gen_uid
@@count += 1
@@count
end
|
33
34
35
|
# File 'lib/elrpc.rb', line 33
def self.get_logger_format(comid)
return "%Y/%m/%d %H:%M:%S #{comid}"
end
|
.set_default_log_level(level) ⇒ Object
Logger::WARN, Logger::INFO, Logger::DEBUG
18
19
20
|
# File 'lib/elrpc.rb', line 18
def self.set_default_log_level(level)
@@default_log_level = level
end
|
.start_client(port, methods = [], host = "127.0.0.1") ⇒ Object
52
53
54
55
56
|
# File 'lib/elrpc.rb', line 52
def self.start_client(port, methods=[], host = "127.0.0.1")
socket = TCPSocket.open(host, port)
client = RPCService.new("CL", socket, methods)
return client
end
|
.start_process(cmd, port = nil) ⇒ Object
58
59
60
61
62
|
# File 'lib/elrpc.rb', line 58
def self.start_process(cmd, port = nil)
svr = Service.new(cmd, port)
svr.start
return svr
end
|
.start_server(methods = [], port = 0) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/elrpc.rb', line 39
def self.start_server(methods = [], port = 0)
server_socket = TCPServer.open(port)
port_number = server_socket.local_address.ip_port
STDOUT.puts "#{port_number}"
STDOUT.flush
socket = server_socket.accept
server = RPCService.new("SV", socket, methods)
server.add_close_hook do
server_socket.close
end
return server
end
|