Documentation
¶
Index ¶
- Constants
- Variables
- func SetLogFunc(f func(string, ...interface{}))
- func WithNamespace(ctx context.Context, ns string) context.Context
- type ClientAdapter
- func (a *ClientAdapter) Close() error
- func (a *ClientAdapter) ListTopics(ctx context.Context) ([]string, error)
- func (a *ClientAdapter) Publish(ctx context.Context, topic string, data []byte) error
- func (a *ClientAdapter) Subscribe(ctx context.Context, topic string, handler MessageHandler) error
- func (a *ClientAdapter) Unsubscribe(ctx context.Context, topic string) error
- type HandlerID
- type Manager
- func (m *Manager) Close() error
- func (m *Manager) ListTopics(ctx context.Context) ([]string, error)
- func (m *Manager) Publish(ctx context.Context, topic string, data []byte) error
- func (m *Manager) Subscribe(ctx context.Context, topic string, handler MessageHandler) error
- func (m *Manager) Unsubscribe(ctx context.Context, topic string) error
- type MessageHandler
Constants ¶
const CtxKeyNamespaceOverride ctxKey = "pubsub_ns_override"
CtxKeyNamespaceOverride is the context key used to override namespace per pubsub call
Variables ¶
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.
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) 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 HandlerID ¶ added in v0.52.14
type HandlerID string
HandlerID uniquely identifies a handler registration. Each call to Subscribe generates a new HandlerID, allowing multiple subscribers to the same topic with independent lifecycles. Unsubscribe operations are ref-counted per topic.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles pub/sub operations
func NewManager ¶
NewManager creates a new pubsub manager
func (*Manager) ListTopics ¶
ListTopics returns all subscribed topics
type MessageHandler ¶
MessageHandler represents a message handler function signature. Each handler is called when a message arrives on a subscribed topic. Multiple handlers can be registered for the same topic, and each will receive a copy of the message. Handlers should return an error only for critical failures; the error is logged but does not stop other handlers. This matches the client.MessageHandler type to avoid circular imports.