pubsub

package
v0.50.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const CtxKeyNamespaceOverride ctxKey = "pubsub_ns_override"

CtxKeyNamespaceOverride is the context key used to override namespace per pubsub call

Variables

View Source
var Logf = func(format string, args ...interface{}) { _ = fmt.Sprintf(format, args...) }

Logf is a package-level logger function used by pubsub internals. By default it is a no-op to avoid polluting stdout; applications can assign it (e.g., to a UI-backed logger) to surface logs as needed.

Functions

func SetLogFunc

func SetLogFunc(f func(string, ...interface{}))

SetLogFunc allows applications to provide a custom logger sink.

func WithNamespace

func WithNamespace(ctx context.Context, ns string) context.Context

WithNamespace returns a new context that carries a pubsub namespace override

Types

type ClientAdapter

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

ClientAdapter adapts the pubsub Manager to work with the existing client interface

func NewClientAdapter

func NewClientAdapter(ps *pubsub.PubSub, namespace string) *ClientAdapter

NewClientAdapter creates a new adapter for the pubsub manager

func (*ClientAdapter) Close

func (a *ClientAdapter) Close() error

Close closes all subscriptions and topics

func (*ClientAdapter) ListTopics

func (a *ClientAdapter) ListTopics(ctx context.Context) ([]string, error)

ListTopics returns all subscribed topics

func (*ClientAdapter) Publish

func (a *ClientAdapter) Publish(ctx context.Context, topic string, data []byte) error

Publish publishes a message to a topic

func (*ClientAdapter) Subscribe

func (a *ClientAdapter) Subscribe(ctx context.Context, topic string, handler MessageHandler) error

Subscribe subscribes to a topic

func (*ClientAdapter) Unsubscribe

func (a *ClientAdapter) Unsubscribe(ctx context.Context, topic string) error

Unsubscribe unsubscribes from a topic

type Manager

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

Manager handles pub/sub operations

func NewManager

func NewManager(ps *pubsub.PubSub, namespace string) *Manager

NewManager creates a new pubsub manager

func (*Manager) Close

func (m *Manager) Close() error

Close closes all subscriptions and topics

func (*Manager) ListTopics

func (m *Manager) ListTopics(ctx context.Context) ([]string, error)

ListTopics returns all subscribed topics

func (*Manager) Publish

func (m *Manager) Publish(ctx context.Context, topic string, data []byte) error

Publish publishes a message to a topic

func (*Manager) Subscribe

func (m *Manager) Subscribe(ctx context.Context, topic string, handler MessageHandler) error

Subscribe subscribes to a topic

func (*Manager) Unsubscribe

func (m *Manager) Unsubscribe(ctx context.Context, topic string) error

Unsubscribe unsubscribes from a topic

type MessageHandler

type MessageHandler func(topic string, data []byte) error

MessageHandler represents a message handler function signature This matches the client.MessageHandler type to avoid circular imports

Jump to

Keyboard shortcuts

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