Class: Shamu::Events::Message

Inherits:
Object
  • Object
show all
Includes:
Attributes, Attributes::Equality
Defined in:
lib/shamu/events/message.rb

Overview

The event Message consists of a set of well-defined attributes describing a single discrete event in the system and associated meta-data needed by subscribers to process the message.

Messages should attempt to forward the state available at the time the event was published so that subscribers can process the message without contacting additional services.

Event messages are serialized for network or IPC transimission and must limit attributes to primitive types (Strings, Numbers, Arrays and Hashes) so they can be round tripped with Message.new( message.to_attributes ).

Attributes collapse

Instance Method Summary collapse

Methods included from Attributes::Equality

#==, #hash

Methods included from Attributes

#[], #as_json, #assign_attributes, association, associations, attribute, #attribute?, attributes, #pretty_print, #set?, #slice, #to_attributes, #to_json

Constructor Details

#initializeMessage

Returns a new instance of Message.



31
32
33
34
35
# File 'lib/shamu/events/message.rb', line 31

def initialize( * )
  super

  @id ||= SecureRandom.uuid
end

Instance Attribute Details

#idString

Returns the ID for the message. Automatically generated UUID.

Returns:

  • (String)

    the ID for the message. Automatically generated UUID



25
# File 'lib/shamu/events/message.rb', line 25

attribute :id