Documentation
¶
Overview ¶
Package bus defines a driver-agnostic messaging surface for agent platforms.
NATS/JetStream is one driver (see archon-nats-bus). Executors and product code should depend on these interfaces and open a bus via Open(Config), never import a broker SDK directly in business logic.
Part of the Archon open-source toolkit: https://github.com/diogoX451/archon-oss
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bus ¶
type Bus interface {
Publish(ctx context.Context, subject string, payload []byte) error
Subscribe(subject string, handler Handler) (Subscription, error)
Close() error
}
Bus is the minimal publish/subscribe surface every driver must implement.
type Config ¶
type Config struct {
// Driver selects the implementation: "nats", "jetstream", "memory", …
// Empty defaults to "nats".
Driver string
// URL is driver-specific (nats://host:4222, memory, kafka://…, …).
URL string
// MaxReconnects / ReconnectWait apply to reconnecting drivers.
// MaxReconnects -1 = reconnect forever (recommended for production).
MaxReconnects int
ReconnectWait time.Duration
// SubscribeAckWait / SubscribeMaxDeliver apply to push consumers.
SubscribeAckWait time.Duration
SubscribeMaxDeliver int
// Extra holds driver-specific options without polluting the core API.
Extra map[string]string
}
Config opens a bus for a named driver. Fields beyond Driver/URL are driver-specific hints (reconnect, ack wait, …).
type Handler ¶
Handler processes one message. Return nil after Ack (or when the driver auto-acks). Return a non-nil error for redelivery on supporting drivers.
type Message ¶
type Message interface {
Data() []byte
Subject() string
Ack() error
Nak(delay ...time.Duration) error
InProgress() error
Metadata() (*MsgMetadata, error)
}
Message is a transport-agnostic bus message with manual ack support.
type MsgMetadata ¶
type MsgMetadata struct {
Sequence uint64
Time time.Time
Stream string
Consumer string
Deliveries int
}
MsgMetadata carries delivery info when the driver exposes it.
type Subscription ¶
type Subscription interface {
Unsubscribe() error
}
Subscription can be cancelled.