Class: Takagi::EventBus::Message
- Inherits:
-
Object
- Object
- Takagi::EventBus::Message
- Defined in:
- lib/takagi/event_bus.rb
Overview
Event message wrapper (shareable for Ractor)
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#reply_address ⇒ Object
readonly
Returns the value of attribute reply_address.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(address, body, headers: {}, reply_address: nil, scope: Scope::DEFAULT, freeze_body: true) ⇒ Message
constructor
A new instance of Message.
-
#reply(body, headers: {}) ⇒ Object
Reply to this message (request-reply pattern).
Constructor Details
#initialize(address, body, headers: {}, reply_address: nil, scope: Scope::DEFAULT, freeze_body: true) ⇒ Message
Returns a new instance of Message.
36 37 38 39 40 41 42 43 |
# File 'lib/takagi/event_bus.rb', line 36 def initialize(address, body, headers: {}, reply_address: nil, scope: Scope::DEFAULT, freeze_body: true) @address = address.freeze @body = freeze_body ? deep_freeze(body) : body @headers = deep_freeze(headers) @reply_address = reply_address&.freeze @scope = Scope.normalize(scope) @timestamp = Time.now end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
34 35 36 |
# File 'lib/takagi/event_bus.rb', line 34 def address @address end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
34 35 36 |
# File 'lib/takagi/event_bus.rb', line 34 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
34 35 36 |
# File 'lib/takagi/event_bus.rb', line 34 def headers @headers end |
#reply_address ⇒ Object (readonly)
Returns the value of attribute reply_address.
34 35 36 |
# File 'lib/takagi/event_bus.rb', line 34 def reply_address @reply_address end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
34 35 36 |
# File 'lib/takagi/event_bus.rb', line 34 def scope @scope end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
34 35 36 |
# File 'lib/takagi/event_bus.rb', line 34 def @timestamp end |