Module: ClusteredRpc
- Defined in:
- lib/clustered_rpc.rb,
lib/clustered_rpc/info.rb,
lib/clustered_rpc/proxy.rb,
lib/clustered_rpc/methods.rb,
lib/clustered_rpc/version.rb,
lib/clustered_rpc/transport/base.rb,
lib/clustered_rpc/transport/local_process.rb,
lib/clustered_rpc/transport/redis_cluster.rb
Defined Under Namespace
Modules: Methods, Transport
Classes: Error, Info, Proxy
Constant Summary
collapse
- VERSION =
"0.3.1"
- @@instance_id =
SecureRandom.hex(5)
- @@logger =
::Logger.new(STDOUT)
- @@cluster_namespace =
"clustered_rpc"
- @@transport_class =
nil
- @@transport =
nil
- @@options =
{}
Class Method Summary
collapse
Class Method Details
.cluster_namespace ⇒ Object
27
|
# File 'lib/clustered_rpc.rb', line 27
def self.cluster_namespace; @@cluster_namespace; end
|
.cluster_namespace=(cluster_namespace) ⇒ Object
26
|
# File 'lib/clustered_rpc.rb', line 26
def self.cluster_namespace=(cluster_namespace); @@cluster_namespace = cluster_namespace; end
|
.config(force = false, &block) ⇒ Object
46
47
48
49
50
51
52
|
# File 'lib/clustered_rpc.rb', line 46
def self.config(force=false, &block)
@@transport = nil
block.call(self)
@@instance_id ||= SecureRandom.hex(5)
ensure_transport
@@transport.connect
end
|
.get_result(request_id, wait_seconds = 1.0) ⇒ Object
request_id should have been returned from the call to #cluster_send
36
37
38
39
40
41
42
|
# File 'lib/clustered_rpc.rb', line 36
def self.get_result(request_id, wait_seconds = 1.0)
sleep(wait_seconds) if wait_seconds && transport_class != ClusteredRpc::Transport::LocalProcess
results = @@transport.get_result(request_id)
results.keys.each{|k| results[k] = JSON.parse(results[k])}
results end
|
.instance_id ⇒ Object
24
|
# File 'lib/clustered_rpc.rb', line 24
def self.instance_id; @@instance_id; end
|
.instance_id=(instance_id) ⇒ Object
23
|
# File 'lib/clustered_rpc.rb', line 23
def self.instance_id=(instance_id); @@instance_id = instance_id; end
|
.logger ⇒ Object
21
|
# File 'lib/clustered_rpc.rb', line 21
def self.logger; @@logger; end
|
.logger=(logger) ⇒ Object
20
|
# File 'lib/clustered_rpc.rb', line 20
def self.logger=(logger); @@logger = logger; end
|
.options ⇒ Object
33
|
# File 'lib/clustered_rpc.rb', line 33
def self.options; @@options; end
|
.options=(options) ⇒ Object
32
|
# File 'lib/clustered_rpc.rb', line 32
def self.options=(options); @@options = options; end
|
.publish(payload = {}) ⇒ Object
payload will likely have keys: [:klass, :method, :args]
60
61
62
63
64
65
66
67
|
# File 'lib/clustered_rpc.rb', line 60
def self.publish(payload={})
ensure_transport
payload[:request_id] ||= SecureRandom.hex(8)
@@transport.publish payload
payload[:request_id]
end
|
.reconnect ⇒ Object
54
55
56
57
|
# File 'lib/clustered_rpc.rb', line 54
def self.reconnect
@@transport.reconnect
@@transport
end
|
.transport_class ⇒ Object
30
|
# File 'lib/clustered_rpc.rb', line 30
def self.transport_class; @@transport_class; end
|
.transport_class=(transport_class) ⇒ Object
29
|
# File 'lib/clustered_rpc.rb', line 29
def self.transport_class=(transport_class); @@transport_class = transport_class; end
|