Class: ClusteredRpc::Transport::Base
- Inherits:
-
Object
- Object
- ClusteredRpc::Transport::Base
show all
- Defined in:
- lib/clustered_rpc/transport/base.rb
Instance Method Summary
collapse
Instance Method Details
#connect ⇒ Object
9
10
11
|
# File 'lib/clustered_rpc/transport/base.rb', line 9
def connect
end
|
#get_result(request_id) ⇒ Object
5
6
7
|
# File 'lib/clustered_rpc/transport/base.rb', line 5
def get_result(request_id)
raise "Subclassers must implement this to retrieve results"
end
|
#reconnect ⇒ Object
17
18
19
|
# File 'lib/clustered_rpc/transport/base.rb', line 17
def reconnect
end
|
#run_method_from_message(payload) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/clustered_rpc/transport/base.rb', line 21
def run_method_from_message(payload)
klass=payload['klass']
method=payload['method']
klass = Object.const_get(klass) rescue nil if klass.is_a? String
if klass
start_time = Time.now
args = payload['args']
kwargs = payload['kwargs']
kwargs = Hash[kwargs.map{|k,v| [k.to_sym, v] }] if kwargs
result = if args && args.length > 0 && kwargs && kwargs.length > 0
klass.send method.to_sym, *args, **kwargs
elsif kwargs && kwargs.length > 0
klass.send method.to_sym, **kwargs
elsif args && args.length > 0
klass.send method.to_sym, *args
else
klass.send method.to_sym
end
seconds = Time.now - start_time
end
{seconds: seconds, result: result}
end
|
#subscribed? ⇒ Boolean
13
14
15
|
# File 'lib/clustered_rpc/transport/base.rb', line 13
def subscribed?
end
|