Help us shape the future of Go! Take the 2026 Go Developer Survey

bridge

package
v0.2.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package bridge provides the NATSBridge that delivers NATS messages to a proto.actor actor mailbox. Each actor creates one NATSBridge and calls AddSubject() for each NATS subject it wants to receive messages on.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NATSBridge

type NATSBridge struct {
	// contains filtered or unexported fields
}

NATSBridge subscribes to one or more NATS subjects and forwards decoded messages to a proto.actor actor via its mailbox.

For fire-and-forget messages (ReplyTo == ""), the decoded inner message is sent directly. For request/reply messages (ReplyTo != ""), a *msg.RequestEnvelope is sent so the actor can call env.Reply(responseMsg).

func New

func New(nc *nats.Conn, pid *actor.PID, system *actor.ActorSystem, codecs *msg.CodecRegistry) *NATSBridge

New creates a NATSBridge that delivers to pid via system. pid may be nil if SetPID will be called before any messages arrive.

func (*NATSBridge) AddSubject

func (b *NATSBridge) AddSubject(subject string) error

AddSubject subscribes to a NATS subject and routes incoming messages to the actor's mailbox. Call from the actor's *actor.Started handler.

func (*NATSBridge) SetPID

func (b *NATSBridge) SetPID(pid *actor.PID)

SetPID updates the target PID. It must be called before AddSubject() if the PID was not known at construction time.

func (*NATSBridge) SetPaneID

func (b *NATSBridge) SetPaneID(paneID string)

SetPaneID associates this bridge with a parent pane ID so that every log entry shows "pane:<shortID>" instead of the proto.actor-generated UUID. Call this before AddSubject() for it to take effect on all subscriptions.

func (*NATSBridge) Stop

func (b *NATSBridge) Stop()

Stop unsubscribes all NATS subscriptions. Call from the actor's *actor.Stopping handler before any other cleanup.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL