Class: Ruote::Synchronize::Participant

Inherits:
Object
  • Object
show all
Includes:
LocalParticipant
Defined in:
lib/ruote/synchronize/participant.rb

Overview

A special kind of participant registered as "synchronize"

Instance Method Summary collapse

Instance Method Details

#on_cancelvoid

This method returns an undefined value.

Deletes the synchronization key from storage if it still exists.



36
37
38
39
40
41
# File 'lib/ruote/synchronize/participant.rb', line 36

def on_cancel

  key = applied_workitem.lookup('params.key')
  broker.unpublish(key)

end

#on_workitemvoid

This method returns an undefined value.

Replies if another synchronize call was made previously with the same key. Otherwise stores the workitem and does not reply.

Raises:

  • (UndefinedKey)

    if synchronize was called with a nil or empty key.



25
26
27
28
29
30
31
32
# File 'lib/ruote/synchronize/participant.rb', line 25

def on_workitem

  key = workitem.lookup('params.key')
  raise UndefinedKey if key.to_s.empty?

  reply if broker.publish(key, workitem)

end