Class: KubeMQ::PubSub::EventsSubscription

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

Overview

Configuration for subscribing to real-time (non-durable) events.

Pass to KubeMQ::PubSubClient#subscribe_to_events along with a block to receive EventReceived messages. Supports wildcard channels (+*+ and >) and consumer groups for load balancing.

Examples:

sub = KubeMQ::PubSub::EventsSubscription.new(
  channel: "events.>",
  group: "workers"
)
client.subscribe_to_events(sub) { |event| puts event.body }

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(channel:, group: nil) ⇒ EventsSubscription

Returns a new instance of EventsSubscription.

Parameters:

  • channel (String)

    channel name or wildcard pattern (required)

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

    consumer group name (default: nil)



29
30
31
32
# File 'lib/kubemq/pubsub/events_subscription.rb', line 29

def initialize(channel:, group: nil)
  @channel = channel
  @group = group
end

Instance Attribute Details

#channelString

Returns channel name or wildcard pattern to subscribe to.

Returns:

  • (String)

    channel name or wildcard pattern to subscribe to



25
26
27
# File 'lib/kubemq/pubsub/events_subscription.rb', line 25

def channel
  @channel
end

#groupString?

Returns consumer group for load-balanced delivery.

Returns:

  • (String, nil)

    consumer group for load-balanced delivery



25
# File 'lib/kubemq/pubsub/events_subscription.rb', line 25

attr_accessor :channel, :group

Instance Method Details

#subscribe_typeInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the subscribe type constant for the transport layer.

Returns:



38
39
40
# File 'lib/kubemq/pubsub/events_subscription.rb', line 38

def subscribe_type
  SubscribeType::EVENTS
end