Class: KubeMQ::PubSub::EventStoreMessage

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

Overview

Outbound durable event message for the events store pattern.

Unlike EventMessage, events store messages are persisted by the broker and can be replayed by subscribers using start-position policies. Pass to KubeMQ::PubSubClient#send_event_store or KubeMQ::PubSub::EventStoreSender#publish.

Examples:

msg = KubeMQ::PubSub::EventStoreMessage.new(
  channel: "orders.created",
  metadata: "order-event",
  body: '{"order_id": 100}',
  tags: { "region" => "us-east" }
)
result = client.send_event_store(msg)

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel:, metadata: nil, body: nil, tags: nil, id: nil) ⇒ EventStoreMessage

Returns a new instance of EventStoreMessage.

Parameters:

  • channel (String)

    target channel name (required)

  • metadata (String, nil) (defaults to: nil)

    arbitrary metadata

  • body (String, nil) (defaults to: nil)

    message payload

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

    key-value tags (default: {})

  • id (String, nil) (defaults to: nil)

    message ID (default: auto-generated UUID)



44
45
46
47
48
49
50
# File 'lib/kubemq/pubsub/event_store_message.rb', line 44

def initialize(channel:, metadata: nil, body: nil, tags: nil, id: nil)
  @id = id || SecureRandom.uuid
  @channel = channel
  @metadata = 
  @body = body
  @tags = tags || {}
end

Instance Attribute Details

#bodyString?

Returns message payload (binary-safe).

Returns:

  • (String, nil)

    message payload (binary-safe)



37
# File 'lib/kubemq/pubsub/event_store_message.rb', line 37

attr_accessor :id, :channel, :metadata, :body, :tags

#channelString

Returns target channel name.

Returns:

  • (String)

    target channel name



37
# File 'lib/kubemq/pubsub/event_store_message.rb', line 37

attr_accessor :id, :channel, :metadata, :body, :tags

#idString

Returns unique message identifier (auto-generated UUID if not provided).

Returns:

  • (String)

    unique message identifier (auto-generated UUID if not provided)



37
38
39
# File 'lib/kubemq/pubsub/event_store_message.rb', line 37

def id
  @id
end

#metadataString?

Returns arbitrary metadata string.

Returns:

  • (String, nil)

    arbitrary metadata string



37
# File 'lib/kubemq/pubsub/event_store_message.rb', line 37

attr_accessor :id, :channel, :metadata, :body, :tags

#tagsHash{String => String}

Returns user-defined key-value tags.

Returns:

  • (Hash{String => String})

    user-defined key-value tags



37
# File 'lib/kubemq/pubsub/event_store_message.rb', line 37

attr_accessor :id, :channel, :metadata, :body, :tags