Class: Pgbus::Web::Streamer::StreamEventDispatcher::StreamEnvelope

Inherits:
Data
  • Object
show all
Defined in:
lib/pgbus/web/streamer/stream_event_dispatcher.rb

Overview

An unwrapped stream broadcast. Similar shape to Pgbus::Client::ReadAfter::Envelope (msg_id + payload) so Connection#enqueue can consume either type via duck typing, but adds two delivery-control fields carried through from Pgbus::Streams::Stream#broadcast:

- `visible_to` — audience filter label (evaluated per-connection)
- `exclude`    — a connection id to skip (actor-echo suppression:
                 the broadcaster's own SSE connection does not
                 receive the echo of its own broadcast)

The Dispatcher uses both to decide per-connection delivery; Connection never sees either field.

- `event`      — the SSE `event:` name for the delivered frame.
                 nil means the default (turbo-stream); a typed
                 name (e.g. "presence", "reactive") lets clients
                 route without sniffing the HTML (issue #170).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg_id:, enqueued_at:, payload:, source:, visible_to: nil, exclude: nil, event: nil) ⇒ StreamEnvelope

Returns a new instance of StreamEnvelope.



59
60
61
# File 'lib/pgbus/web/streamer/stream_event_dispatcher.rb', line 59

def initialize(msg_id:, enqueued_at:, payload:, source:, visible_to: nil, exclude: nil, event: nil)
  super
end

Instance Attribute Details

#enqueued_atObject (readonly)

Returns the value of attribute enqueued_at

Returns:

  • (Object)

    the current value of enqueued_at



58
59
60
# File 'lib/pgbus/web/streamer/stream_event_dispatcher.rb', line 58

def enqueued_at
  @enqueued_at
end

#eventObject (readonly)

Returns the value of attribute event

Returns:

  • (Object)

    the current value of event



58
59
60
# File 'lib/pgbus/web/streamer/stream_event_dispatcher.rb', line 58

def event
  @event
end

#excludeObject (readonly)

Returns the value of attribute exclude

Returns:

  • (Object)

    the current value of exclude



58
59
60
# File 'lib/pgbus/web/streamer/stream_event_dispatcher.rb', line 58

def exclude
  @exclude
end

#msg_idObject (readonly)

Returns the value of attribute msg_id

Returns:

  • (Object)

    the current value of msg_id



58
59
60
# File 'lib/pgbus/web/streamer/stream_event_dispatcher.rb', line 58

def msg_id
  @msg_id
end

#payloadObject (readonly)

Returns the value of attribute payload

Returns:

  • (Object)

    the current value of payload



58
59
60
# File 'lib/pgbus/web/streamer/stream_event_dispatcher.rb', line 58

def payload
  @payload
end

#sourceObject (readonly)

Returns the value of attribute source

Returns:

  • (Object)

    the current value of source



58
59
60
# File 'lib/pgbus/web/streamer/stream_event_dispatcher.rb', line 58

def source
  @source
end

#visible_toObject (readonly)

Returns the value of attribute visible_to

Returns:

  • (Object)

    the current value of visible_to



58
59
60
# File 'lib/pgbus/web/streamer/stream_event_dispatcher.rb', line 58

def visible_to
  @visible_to
end