Module: Pione::TupleSpace::TupleSpaceInterface
- Included in:
- Bacon::Context, Agent::TupleSpaceClient, Command::PioneClient, RuleEngine::BasicHandler, RuleEngine::DataFinder
- Defined in:
- lib/pione/tuple-space/tuple-space-interface.rb
Class Method Summary collapse
-
.tuple_space_operation(name) ⇒ Object
Define tuple space operation.
Instance Method Summary collapse
-
#process_log(record) ⇒ void
Put a log tuple with the data as a process record into tuple space.
-
#processing_error(msg) ⇒ void
Send a processing error.
-
#set_tuple_space(server) ⇒ void
Set tuple space server which provides operations.
-
#tuple_space_server ⇒ Object
Return the tuple space server.
-
#with_process_log(record) { ... } ⇒ void
Do the action with loggging.
Class Method Details
.tuple_space_operation(name) ⇒ Object
Define tuple space operation.
6 7 8 9 10 |
# File 'lib/pione/tuple-space/tuple-space-interface.rb', line 6 def self.tuple_space_operation(name) define_method(name) do |*args, &b| @__tuple_space__.__send__(name, *args, &b) end end |
Instance Method Details
#process_log(record) ⇒ void
This method returns an undefined value.
Put a log tuple with the data as a process record into tuple space. The record's value of transition is "complete" by default and the timestamp set automatically.
36 37 38 39 |
# File 'lib/pione/tuple-space/tuple-space-interface.rb', line 36 def process_log(record) record = record.merge(transition: "complete") unless record.transition write(TupleSpace::ProcessLogTuple.new(record)) end |
#processing_error(msg) ⇒ void
This method returns an undefined value.
Send a processing error.
62 63 64 |
# File 'lib/pione/tuple-space/tuple-space-interface.rb', line 62 def processing_error(msg) write(TupleSpace::CommandTuple.new(name: "terminate", args: {message: msg})) end |
#set_tuple_space(server) ⇒ void
This method returns an undefined value.
Set tuple space server which provides operations.
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/pione/tuple-space/tuple-space-interface.rb', line 68 def set_tuple_space(server) @__tuple_space__ = server # override #to_s as it's uri because dead remote objects cause exceptions # when you try to watch the object if server.methods.include?(:__drburi) def @__tuple_space__.to_s __drburi end end end |
#tuple_space_server ⇒ Object
Return the tuple space server.
25 26 27 |
# File 'lib/pione/tuple-space/tuple-space-interface.rb', line 25 def tuple_space_server @__tuple_space__ end |
#with_process_log(record) { ... } ⇒ void
This method returns an undefined value.
Do the action with loggging.
48 49 50 51 52 53 54 55 |
# File 'lib/pione/tuple-space/tuple-space-interface.rb', line 48 def with_process_log(record) process_log(record.merge(transition: "start")) result = yield process_log(record.merge(transition: "complete")) return result rescue DRb::DRbConnError yield end |