Documentation
¶
Index ¶
- func ConsumePull[T any](ctx context.Context, js nats.JetStreamContext, cfg ConsumerConfig, ...) error
- func ConsumePush[T any](ctx context.Context, js nats.JetStreamContext, cfg ConsumerConfig, ...) error
- func WaitForNATS(ctx context.Context, url string, retries int, delay time.Duration) error
- type AckAction
- type Cache
- type CompressionType
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) Context() context.Context
- func (c *Conn) Drain()
- func (c *Conn) EnsureKeyValue(cfg KVConfig) (nats.KeyValue, error)
- func (c *Conn) EnsureStream(cfg StreamConfig) error
- func (c *Conn) EnsureStreams(configs ...StreamConfig) error
- func (c *Conn) Name() string
- func (c *Conn) Publish(ctx context.Context, subject string, data []byte) error
- func (c *Conn) PullSubscribe(ctx context.Context, subject string, durable string) (PullConsumer, error)
- func (c *Conn) Request(ctx context.Context, subject string, data []byte, timeout time.Duration) ([]byte, error)
- func (c *Conn) Subscribe(ctx context.Context, subject string, durable string, handler MessageHandler) (Subscription, error)
- type ConnOptions
- type ConsumerConfig
- type EventBroker
- type Handler
- type KVConfig
- type KafkaBroker
- func (b *KafkaBroker) Close() error
- func (b *KafkaBroker) EnsureStream(cfg StreamConfig) error
- func (b *KafkaBroker) EnsureStreams(configs ...StreamConfig) error
- func (b *KafkaBroker) Name() string
- func (b *KafkaBroker) Publish(ctx context.Context, subject string, data []byte) error
- func (b *KafkaBroker) PullSubscribe(_ context.Context, _ string, _ string) (PullConsumer, error)
- func (b *KafkaBroker) Request(_ context.Context, _ string, _ []byte, _ time.Duration) ([]byte, error)
- func (b *KafkaBroker) Subscribe(ctx context.Context, subject string, durable string, handler MessageHandler) (Subscription, error)
- type Message
- type MessageHandler
- type Msg
- type Producer
- func (p *Producer[T]) Publish(msg T, opts ...nats.PubOpt) error
- func (p *Producer[T]) PublishAndWait(ctx context.Context, msg T, timeout time.Duration) (*Msg[T], error)
- func (p *Producer[T]) PublishAndWaitRaw(ctx context.Context, data []byte, timeout time.Duration) (*nats.Msg, error)
- func (p *Producer[T]) PublishWithID(msg T, id string, opts ...nats.PubOpt) error
- type PullConsumer
- type StorageType
- type StreamConfig
- type Subscription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConsumePull ¶
func ConsumePull[T any](ctx context.Context, js nats.JetStreamContext, cfg ConsumerConfig, handler Handler[T]) error
func ConsumePush ¶
func ConsumePush[T any](ctx context.Context, js nats.JetStreamContext, cfg ConsumerConfig, handler Handler[T]) error
Types ¶
type Cache ¶
type Cache[T any] struct { // contains filtered or unexported fields }
type CompressionType ¶ added in v0.1.0
type CompressionType int
const ( S2Compression CompressionType = iota NoCompression )
type Conn ¶
type Conn struct {
NC *nats.Conn
JS nats.JetStreamContext
// contains filtered or unexported fields
}
func (*Conn) EnsureStream ¶
func (c *Conn) EnsureStream(cfg StreamConfig) error
func (*Conn) EnsureStreams ¶
func (c *Conn) EnsureStreams(configs ...StreamConfig) error
func (*Conn) PullSubscribe ¶ added in v0.1.0
func (*Conn) Subscribe ¶ added in v0.1.0
func (c *Conn) Subscribe(ctx context.Context, subject string, durable string, handler MessageHandler) (Subscription, error)
type ConnOptions ¶
type ConsumerConfig ¶
type ConsumerConfig struct {
Stream string
Subject string
Durable string
QueueGroup string
DeliverAll bool
MaxDeliver int
AckWait time.Duration
BackOff []time.Duration
PullBatch int
PullMaxWait time.Duration
NakDelay time.Duration
Reply bool // if true, handler returns data for msg.Respond()
}
func DefaultConsumerConfig ¶
func DefaultConsumerConfig(stream, durable string) ConsumerConfig
type EventBroker ¶ added in v0.1.0
type EventBroker interface {
Name() string
Publish(ctx context.Context, subject string, data []byte) error
Subscribe(ctx context.Context, subject string, durable string, handler MessageHandler) (Subscription, error)
PullSubscribe(ctx context.Context, subject string, durable string) (PullConsumer, error)
Request(ctx context.Context, subject string, data []byte, timeout time.Duration) ([]byte, error)
EnsureStream(cfg StreamConfig) error
EnsureStreams(configs ...StreamConfig) error
Close() error
}
type KVConfig ¶
type KVConfig struct {
Bucket string
Description string
TTL time.Duration
MaxBytes int64
Storage StorageType
}
func DefaultKVConfig ¶
type KafkaBroker ¶ added in v0.1.0
type KafkaBroker struct {
// contains filtered or unexported fields
}
func NewKafkaBroker ¶ added in v0.1.0
func NewKafkaBroker(name string, brokers []string, consumerGroup string) *KafkaBroker
func (*KafkaBroker) Close ¶ added in v0.1.0
func (b *KafkaBroker) Close() error
func (*KafkaBroker) EnsureStream ¶ added in v0.1.0
func (b *KafkaBroker) EnsureStream(cfg StreamConfig) error
func (*KafkaBroker) EnsureStreams ¶ added in v0.1.0
func (b *KafkaBroker) EnsureStreams(configs ...StreamConfig) error
func (*KafkaBroker) Name ¶ added in v0.1.0
func (b *KafkaBroker) Name() string
func (*KafkaBroker) PullSubscribe ¶ added in v0.1.0
func (b *KafkaBroker) PullSubscribe(_ context.Context, _ string, _ string) (PullConsumer, error)
func (*KafkaBroker) Subscribe ¶ added in v0.1.0
func (b *KafkaBroker) Subscribe(ctx context.Context, subject string, durable string, handler MessageHandler) (Subscription, error)
type MessageHandler ¶ added in v0.1.0
type Producer ¶
type Producer[T any] struct { // contains filtered or unexported fields }
func NewProducer ¶
func (*Producer[T]) PublishAndWait ¶
func (p *Producer[T]) PublishAndWait(ctx context.Context, msg T, timeout time.Duration) (*Msg[T], error)
PublishAndWait publishes a message and waits for a reply (NATS request-reply). Returns the typed response or an error. Uses core NATS Request, not JetStream.
type PullConsumer ¶ added in v0.1.0
type StorageType ¶ added in v0.1.0
type StorageType int
const ( FileStorage StorageType = iota MemoryStorage )
type StreamConfig ¶
type StreamConfig struct {
Name string
Subjects []string
MaxAge time.Duration
MaxBytes int64
Storage StorageType
Compression CompressionType
}
func DefaultStreamConfig ¶
func DefaultStreamConfig(name string) StreamConfig
type Subscription ¶ added in v0.1.0
type Subscription interface {
Unsubscribe() error
}
Click to show internal directories.
Click to hide internal directories.