Class: Hook0::Event
- Inherits:
-
Object
- Object
- Hook0::Event
- Defined in:
- lib/hook0/client.rb
Overview
An event to send to Hook0.
event_id is the caller's to set when it already has one to key the event on. Left unset, the
client generates a UUIDv7, sends it and answers it — which is what lets it repeat a request
without risking a second copy of the event being ingested and delivered to every subscriber.
Instance Attribute Summary collapse
-
#event_id ⇒ String?
readonly
What to key the event on; the client chooses when unset.
-
#event_type ⇒ String
readonly
The type of the event, as the application declares it.
-
#labels ⇒ Hash{String => String}
readonly
What Hook0 routes the event by.
-
#metadata ⇒ Hash{String => String}?
readonly
Anything else worth carrying.
-
#occurred_at ⇒ Time?
readonly
When the event happened; the current moment when unset.
-
#payload ⇒ String
readonly
What the event carries.
-
#payload_content_type ⇒ String
readonly
How to read the payload.
Instance Method Summary collapse
-
#initialize(event_type:, payload:, payload_content_type:, labels: {}, metadata: nil, occurred_at: nil, event_id: nil) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(event_type:, payload:, payload_content_type:, labels: {}, metadata: nil, occurred_at: nil, event_id: nil) ⇒ Event
Returns a new instance of Event.
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/hook0/client.rb', line 276 def initialize( event_type:, payload:, payload_content_type:, labels: {}, metadata: nil, occurred_at: nil, event_id: nil ) @event_type = event_type @payload = payload @payload_content_type = payload_content_type @labels = labels @metadata = @occurred_at = occurred_at @event_id = event_id freeze end |
Instance Attribute Details
#event_id ⇒ String? (readonly)
Returns what to key the event on; the client chooses when unset.
267 268 269 |
# File 'lib/hook0/client.rb', line 267 def event_id @event_id end |
#event_type ⇒ String (readonly)
Returns the type of the event, as the application declares it.
249 250 251 |
# File 'lib/hook0/client.rb', line 249 def event_type @event_type end |
#labels ⇒ Hash{String => String} (readonly)
Returns what Hook0 routes the event by.
258 259 260 |
# File 'lib/hook0/client.rb', line 258 def labels @labels end |
#metadata ⇒ Hash{String => String}? (readonly)
Returns anything else worth carrying.
261 262 263 |
# File 'lib/hook0/client.rb', line 261 def @metadata end |
#occurred_at ⇒ Time? (readonly)
Returns when the event happened; the current moment when unset.
264 265 266 |
# File 'lib/hook0/client.rb', line 264 def occurred_at @occurred_at end |
#payload ⇒ String (readonly)
Returns what the event carries.
252 253 254 |
# File 'lib/hook0/client.rb', line 252 def payload @payload end |
#payload_content_type ⇒ String (readonly)
Returns how to read the payload.
255 256 257 |
# File 'lib/hook0/client.rb', line 255 def payload_content_type @payload_content_type end |