Class: KubeMQ::PubSub::EventReceived

Inherits:
Object
  • Object
show all
Defined in:
lib/kubemq/pubsub/event_received.rb

Overview

An event received from a pub/sub subscription.

Delivered to the block passed to KubeMQ::PubSubClient#subscribe_to_events. This is a read-only snapshot — modifying attributes has no effect on the broker.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, channel:, metadata:, body:, timestamp:, sequence:, tags:) ⇒ EventReceived

Returns a new instance of EventReceived.

Parameters:

  • id (String)

    event identifier

  • channel (String)

    source channel name

  • metadata (String)

    event metadata

  • body (String)

    event payload

  • timestamp (Integer)

    broker timestamp (Unix nanoseconds)

  • sequence (Integer)

    broker sequence number

  • tags (Hash{String => String}, nil)

    key-value tags



37
38
39
40
41
42
43
44
45
# File 'lib/kubemq/pubsub/event_received.rb', line 37

def initialize(id:, channel:, metadata:, body:, timestamp:, sequence:, tags:)
  @id = id
  @channel = channel
  @metadata = 
  @body = body
  @timestamp = timestamp
  @sequence = sequence
  @tags = tags || {}
end

Instance Attribute Details

#bodyString (readonly)

Returns event payload (binary).

Returns:

  • (String)

    event payload (binary)



28
# File 'lib/kubemq/pubsub/event_received.rb', line 28

attr_reader :id, :channel, :metadata, :body, :timestamp, :sequence, :tags

#channelString (readonly)

Returns the channel the event was published to.

Returns:

  • (String)

    the channel the event was published to



28
# File 'lib/kubemq/pubsub/event_received.rb', line 28

attr_reader :id, :channel, :metadata, :body, :timestamp, :sequence, :tags

#idString (readonly)

Returns unique event identifier.

Returns:

  • (String)

    unique event identifier



28
29
30
# File 'lib/kubemq/pubsub/event_received.rb', line 28

def id
  @id
end

#metadataString (readonly)

Returns event metadata.

Returns:

  • (String)

    event metadata



28
# File 'lib/kubemq/pubsub/event_received.rb', line 28

attr_reader :id, :channel, :metadata, :body, :timestamp, :sequence, :tags

#sequenceInteger (readonly)

Returns broker-assigned sequence number.

Returns:

  • (Integer)

    broker-assigned sequence number



28
# File 'lib/kubemq/pubsub/event_received.rb', line 28

attr_reader :id, :channel, :metadata, :body, :timestamp, :sequence, :tags

#tagsObject (readonly)

Returns the value of attribute tags.



28
# File 'lib/kubemq/pubsub/event_received.rb', line 28

attr_reader :id, :channel, :metadata, :body, :timestamp, :sequence, :tags

#timestampInteger (readonly)

Returns broker-assigned timestamp (Unix nanoseconds).

Returns:

  • (Integer)

    broker-assigned timestamp (Unix nanoseconds)



28
# File 'lib/kubemq/pubsub/event_received.rb', line 28

attr_reader :id, :channel, :metadata, :body, :timestamp, :sequence, :tags