Class: RubyVolt::Base
- Inherits:
-
Object
- Object
- RubyVolt::Base
- Defined in:
- lib/ruby_volt/base.rb
Defined Under Namespace
Classes: AsyncCall
Instance Attribute Summary collapse
-
#connect_timeout ⇒ Object
readonly
Returns the value of attribute connect_timeout.
-
#connection_pool ⇒ Object
readonly
Returns the value of attribute connection_pool.
-
#login_protocol ⇒ Object
readonly
Returns the value of attribute login_protocol.
-
#procedure_protocol ⇒ Object
readonly
Returns the value of attribute procedure_protocol.
-
#procedure_timeout ⇒ Object
readonly
Returns the value of attribute procedure_timeout.
-
#requests_queue ⇒ Object
readonly
Returns the value of attribute requests_queue.
-
#servicename ⇒ Object
readonly
Returns the value of attribute servicename.
Instance Method Summary collapse
- #async_call_procedure(procedure, *parameters) ⇒ Object
- #benchmark(cycle = 1000) ⇒ Object
- #call_procedure(*args, &block) ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #ping ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Base
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ruby_volt/base.rb', line 31 def initialize( = {}) @login_protocol = [:login_protocol]||LOGIN_PROTOCOL @procedure_protocol = [:procedure_protocol]||PROCEDURE_PROTOCOL @servicename = [:servicename]||SERVICE_NAME @connect_timeout = [:connect_timeout]||CONNECT_TIMEOUT # timeout (secs) or Nil for authentication (default=8) @procedure_timeout = [:procedure_timeout]||PROCEDURE_TIMEOUT # timeout (secs) or Nil for procedure call (default=8) @requests_queue = Queue.new @connection_pool = configure_pool() # You can create the connection to any of the nodes in the database cluster and your stored procedure will be routed appropriately. In fact, you can create connections to multiple nodes on the server and your subsequent requests will be distributed to the various connections. @connection_pool.each do |connection| Thread.new do begin while async_call = @requests_queue.pop response_msg = connection.call_procedure(*async_call.args) async_call.accept_response(response_msg) end rescue ThreadError end end end end |
Instance Attribute Details
#connect_timeout ⇒ Object (readonly)
Returns the value of attribute connect_timeout.
29 30 31 |
# File 'lib/ruby_volt/base.rb', line 29 def connect_timeout @connect_timeout end |
#connection_pool ⇒ Object (readonly)
Returns the value of attribute connection_pool.
29 30 31 |
# File 'lib/ruby_volt/base.rb', line 29 def connection_pool @connection_pool end |
#login_protocol ⇒ Object (readonly)
Returns the value of attribute login_protocol.
29 30 31 |
# File 'lib/ruby_volt/base.rb', line 29 def login_protocol @login_protocol end |
#procedure_protocol ⇒ Object (readonly)
Returns the value of attribute procedure_protocol.
29 30 31 |
# File 'lib/ruby_volt/base.rb', line 29 def procedure_protocol @procedure_protocol end |
#procedure_timeout ⇒ Object (readonly)
Returns the value of attribute procedure_timeout.
29 30 31 |
# File 'lib/ruby_volt/base.rb', line 29 def procedure_timeout @procedure_timeout end |
#requests_queue ⇒ Object (readonly)
Returns the value of attribute requests_queue.
29 30 31 |
# File 'lib/ruby_volt/base.rb', line 29 def requests_queue @requests_queue end |
#servicename ⇒ Object (readonly)
Returns the value of attribute servicename.
29 30 31 |
# File 'lib/ruby_volt/base.rb', line 29 def servicename @servicename end |
Instance Method Details
#async_call_procedure(procedure, *parameters) ⇒ Object
53 54 55 56 57 |
# File 'lib/ruby_volt/base.rb', line 53 def async_call_procedure(procedure, *parameters) AsyncCall.new(procedure, *parameters).tap do |async_call| @requests_queue.push(async_call) end end |
#benchmark(cycle = 1000) ⇒ Object
67 68 69 |
# File 'lib/ruby_volt/base.rb', line 67 def benchmark(cycle = 1000) Helper.benchmark(cycle) {ping} # call @Ping - system stored procedure & dispatch end |
#call_procedure(*args, &block) ⇒ Object
59 60 61 |
# File 'lib/ruby_volt/base.rb', line 59 def call_procedure(*args, &block) async_call_procedure(*args).dispatch(&block) end |
#ping ⇒ Object
63 64 65 |
# File 'lib/ruby_volt/base.rb', line 63 def ping call_procedure("@Ping") end |