Documentation
¶
Index ¶
- Constants
- func DecodeLocalChannel(b []byte) (string, error)
- func Deserialize(b []byte, maxSize int) (proto.Message, error)
- func DeserializePayload[T proto.Message](buf []byte) (T, error)
- func SerializePayload(m proto.Message) ([]byte, error)
- type BusOption
- type BusOpts
- type Channel
- type CompressionOpts
- type EmptySubscription
- type MessageBus
- type PublishHandler
- type PublishInterceptor
- type ReadHandler
- type Reader
- type SubscribeInterceptor
- type Subscription
- func Subscribe[MessageType proto.Message](ctx context.Context, bus MessageBus, channel Channel, channelSize int) (Subscription[MessageType], error)
- func SubscribeQueue[MessageType proto.Message](ctx context.Context, bus MessageBus, channel Channel, channelSize int) (Subscription[MessageType], error)
- type TestBusOption
- type TestBusOpts
- type Transport
Constants ¶
View Source
const ( DefaultChannelSize = 100 DefaultCompressionThreshold = 1024 )
Variables ¶
This section is empty.
Functions ¶
func DecodeLocalChannel ¶
Reads Channel.Local back out of a serialized payload without decoding the message.
func Deserialize ¶
maxSize caps the result after decompression; zero is unlimited.
Types ¶
type BusOption ¶
type BusOption func(*BusOpts)
func WithBusCompression ¶
func WithBusCompression(c CompressionOpts) BusOption
type BusOpts ¶
type BusOpts struct {
Compression CompressionOpts
}
type Channel ¶
type Channel struct {
// Flat '|'-delimited key, for brokers with no subject hierarchy.
Legacy string
// Hierarchical subject, e.g. SRV.<service>.<topic>.
Server string
// Demultiplexes several logical channels sharing one Server subject. Carried
// in the payload, not alongside it.
Local string
}
One destination in three forms. A transport routes on whichever it supports and ignores the rest.
type CompressionOpts ¶
type CompressionOpts struct {
// Zero disables compression; otherwise the gzip level.
Quality int
// Payload bytes below which compression is skipped.
Threshold int
// Caps an inbound payload after decompression, bounding amplification from a
// hostile publisher. Zero is unlimited.
MaxDecompressedSize int
}
CompressionOpts applies to publishing only. Decompression is driven by a flag on the wire, so a reader needs no configuration.
type EmptySubscription ¶
type EmptySubscription[MessageType any] struct{}
func (EmptySubscription[MessageType]) Channel ¶
func (s EmptySubscription[MessageType]) Channel() <-chan MessageType
func (EmptySubscription[MessageType]) Close ¶
func (s EmptySubscription[MessageType]) Close() error
type MessageBus ¶
type MessageBus interface {
Publish(ctx context.Context, channel Channel, msg proto.Message) error
Subscribe(ctx context.Context, channel Channel, channelSize int) (Reader, error)
SubscribeQueue(ctx context.Context, channel Channel, channelSize int) (Reader, error)
// Caps an inbound payload after decompression. Zero is unlimited.
MaxDecompressedSize() int
}
func New ¶
func New(t Transport, opts ...BusOption) MessageBus
func NewTestBus ¶
func NewTestBus(bus MessageBus, opts ...TestBusOption) MessageBus
type PublishHandler ¶
type PublishInterceptor ¶
type PublishInterceptor func(next PublishHandler) PublishHandler
type ReadHandler ¶
type SubscribeInterceptor ¶
type SubscribeInterceptor func(ctx context.Context, channel Channel, next ReadHandler) ReadHandler
type Subscription ¶
type Subscription[MessageType proto.Message] interface { Channel() <-chan MessageType Close() error }
func Subscribe ¶
func Subscribe[MessageType proto.Message]( ctx context.Context, bus MessageBus, channel Channel, channelSize int, ) (Subscription[MessageType], error)
func SubscribeQueue ¶
func SubscribeQueue[MessageType proto.Message]( ctx context.Context, bus MessageBus, channel Channel, channelSize int, ) (Subscription[MessageType], error)
type TestBusOption ¶
type TestBusOption func(*TestBusOpts)
type TestBusOpts ¶
type TestBusOpts struct {
PublishInterceptors []PublishInterceptor
SubscribeInterceptors []SubscribeInterceptor
}
type Transport ¶
type Transport interface {
Publish(ctx context.Context, channel Channel, payload []byte) error
Subscribe(ctx context.Context, channel Channel, channelSize int) (Reader, error)
SubscribeQueue(ctx context.Context, channel Channel, channelSize int) (Reader, error)
}
Transport is the seam a message broker implements. Payloads are opaque: encoding, compression and the decompression cap belong to the MessageBus wrapping it, so an implementation must not interpret them.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package bustest is the psrpc bus conformance harness.
|
Package bustest is the psrpc bus conformance harness. |
|
dockerutil
Package dockerutil holds the container plumbing shared by the broker-backed bustest servers.
|
Package dockerutil holds the container plumbing shared by the broker-backed bustest servers. |
|
Package localbus provides an in-process psrpc bus.
|
Package localbus provides an in-process psrpc bus. |
|
Package natsbus provides a psrpc bus backed by NATS.
|
Package natsbus provides a psrpc bus backed by NATS. |
|
natstest
Package natstest registers a Docker-backed NATS broker with bustest.
|
Package natstest registers a Docker-backed NATS broker with bustest. |
|
Package redisbus provides a psrpc bus backed by Redis pub/sub.
|
Package redisbus provides a psrpc bus backed by Redis pub/sub. |
|
redistest
Package redistest registers a Docker-backed Redis broker with bustest.
|
Package redistest registers a Docker-backed Redis broker with bustest. |
Click to show internal directories.
Click to hide internal directories.