Class: VoltRb::ProcedureResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/voltrb/procedure_response.rb

Overview

An object of this class is returned by a call to Client#call_procedure.

response = client.call_procedure("Select", "Spanish")

Some VoltDB stored procedures return multiple rowsets. (Think of one rowset as the rows returned by a SQL select.) You get access to these array of rowsets (VoltTable objects) thru results.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ProcedureResponse

Returns a new instance of ProcedureResponse.



14
15
16
# File 'lib/voltrb/procedure_response.rb', line 14

def initialize(response)
  @raw = JSON.parse(response)      
end

Instance Attribute Details

#rawObject (readonly)

This is a plain Ruby hash derived from the JSON response from VoltDB. We can use this hash to access the entire response entity as an alternative to the object methods below. May save us a few CPU cycles. (Benchmark to be sure.) No conversions are done for values of type Decimal and Timestamp so we’ll have to handle those ourselves. We can also use the conversion functions in Utils



12
13
14
# File 'lib/voltrb/procedure_response.rb', line 12

def raw
  @raw
end

Instance Method Details

#app_statusObject



26
27
28
# File 'lib/voltrb/procedure_response.rb', line 26

def app_status
  @app_status ||= @raw["appstatus"]
end

#app_status_stringObject



30
31
32
# File 'lib/voltrb/procedure_response.rb', line 30

def app_status_string
  @app_status_string ||= @raw["appstatusstring"]
end

#resultsObject

Returns an array of VoltTable.



35
36
37
# File 'lib/voltrb/procedure_response.rb', line 35

def results
  @results ||= hydrate_results
end

#statusObject



18
19
20
# File 'lib/voltrb/procedure_response.rb', line 18

def status
  @status ||= @raw["status"]
end

#status_stringObject



22
23
24
# File 'lib/voltrb/procedure_response.rb', line 22

def status_string
  @status_string ||= @raw["statusstring"]
end