module ClusteredRpc
Constants
- VERSION
Public Class Methods
cluster_namespace()
click to toggle source
# File lib/clustered_rpc.rb, line 27 def self.cluster_namespace; @@cluster_namespace; end
cluster_namespace=(cluster_namespace)
click to toggle source
# File lib/clustered_rpc.rb, line 26 def self.cluster_namespace=(cluster_namespace); @@cluster_namespace = cluster_namespace; end
config(force=false, &block)
click to toggle source
# 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)
click to toggle source
request_id should have been returned from the call to cluster_send
# File lib/clustered_rpc.rb, line 36 def self.get_result(request_id, wait_seconds = 1.0) # Don't wait at all when using LocalProcess 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 # ??? Rails anyone? .with_indifferent_access end
instance_id()
click to toggle source
# File lib/clustered_rpc.rb, line 24 def self.instance_id; @@instance_id; end
instance_id=(instance_id)
click to toggle source
# File lib/clustered_rpc.rb, line 23 def self.instance_id=(instance_id); @@instance_id = instance_id; end
logger()
click to toggle source
# File lib/clustered_rpc.rb, line 21 def self.logger; @@logger; end
logger=(logger)
click to toggle source
# File lib/clustered_rpc.rb, line 20 def self.logger=(logger); @@logger = logger; end
options()
click to toggle source
# File lib/clustered_rpc.rb, line 33 def self.options; @@options; end
options=(options)
click to toggle source
# File lib/clustered_rpc.rb, line 32 def self.options=(options); @@options = options; end
publish(payload={})
click to toggle source
payload will likely have keys: [:klass, :method, :args]
# File lib/clustered_rpc.rb, line 60 def self.publish(payload={}) # if :request_id is already present, then we're responding with a process-level response # otherwise we're creating a new clustered_request and should generate a :request_io ensure_transport payload[:request_id] ||= SecureRandom.hex(8) @@transport.publish payload payload[:request_id] end
reconnect()
click to toggle source
# File lib/clustered_rpc.rb, line 54 def self.reconnect @@transport.reconnect @@transport end
transport_class()
click to toggle source
# File lib/clustered_rpc.rb, line 30 def self.transport_class; @@transport_class; end
transport_class=(transport_class)
click to toggle source
# File lib/clustered_rpc.rb, line 29 def self.transport_class=(transport_class); @@transport_class = transport_class; end
Private Class Methods
ensure_transport()
click to toggle source
# File lib/clustered_rpc.rb, line 70 def self.ensure_transport return if @@transport if @@transport_class.nil? require "clustered_rpc/transport/local_process" @@transport_class = ClusteredRpc::Transport::LocalProcess end logger.info "Clustered using #{@@transport_class}[#{@@cluster_namespace}]" @@transport = @@transport_class.new end