Documentation
¶
Index ¶
- Constants
- 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
Constants ¶
View Source
const ( DefaultChannelSize = 100 DefaultCompressionThreshold = 1024 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BusOption ¶ added in v0.7.6
type BusOption func(*BusOpts)
func WithBusCompression ¶ added in v0.7.6
func WithBusCompression(c CompressionOpts) BusOption
type BusOpts ¶ added in v0.7.6
type BusOpts struct {
Compression CompressionOpts
}
type CompressionOpts ¶ added in v0.7.6
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)
}
func NewLocalMessageBus ¶
func NewLocalMessageBus(opts ...BusOption) MessageBus
func NewNatsMessageBus ¶
func NewNatsMessageBus(nc *nats.Conn, opts ...BusOption) MessageBus
func NewRedisMessageBus ¶
func NewRedisMessageBus(rc redis.UniversalClient, opts ...BusOption) MessageBus
func NewTestBus ¶ added in v0.3.4
func NewTestBus(bus MessageBus, opts ...TestBusOption) MessageBus
type PublishHandler ¶ added in v0.3.4
type PublishInterceptor ¶ added in v0.3.4
type PublishInterceptor func(next PublishHandler) PublishHandler
type ReadHandler ¶ added in v0.3.4
type SubscribeInterceptor ¶ added in v0.3.4
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 ¶ added in v0.3.4
type TestBusOption func(*TestBusOpts)
type TestBusOpts ¶ added in v0.3.4
type TestBusOpts struct {
PublishInterceptors []PublishInterceptor
SubscribeInterceptors []SubscribeInterceptor
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.