class Concord::ComputationContext
Transactional wrapper for proxy <=> client interactions
Attributes
Public Class Methods
Initialize a new ‘ComputationContext` @param computation [Object] The user-defined computation
# File lib/concord.rb, line 35 def initialize(computation) self.computation = computation self.transaction = ::Concord::Thrift::ComputationTx.new self.transaction.records = [] self.transaction.timers = {} end
Public Instance Methods
Retrieve a binary blob stored in the proxy state @param key [String] Key to fetch from data store @return [String] Binary blob of data
# File lib/concord.rb, line 67 def get_state(key) computation.get_state(key) end
Produce a record on ‘stream` with `key` and `value` @param stream [String] Globally unique name of string @param key [String] Key to group by on stream (pending grouping) @param value [String] Binary blob to pass downstream with tuple
# File lib/concord.rb, line 46 def produce_record(stream, key, value) r = ::Concord::Thrift::Record.new r.meta = ::Concord::Thrift::RecordMetadata.new r.key = key r.data = value r.userStream = stream transaction.records.push(r) end
Store a binary blob, identified by a key, in the proxy state @param key [String] Key to set in data store @param value [String] Binary blob
# File lib/concord.rb, line 74 def set_state(key, value) computation.set_state(key, value) end
Set a timer to trigger a callback in the future @param key [String] Name of the timer. This parameter will be passed to the ‘process_timer` callback to identify the specific callback. @param time [FixNum] Integer representing the time (in milliseconds) at
which the callback should be triggered.
# File lib/concord.rb, line 60 def set_timer(key, time) transaction.timers[key] = time end