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 Conn
- type ConnOptions
- type ConsumerConfig
- type Handler
- type KVConfig
- 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 StreamConfig
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 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
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 KVConfig ¶
type KVConfig struct {
Bucket string
Description string
TTL time.Duration
MaxBytes int64
Storage nats.StorageType
}
func DefaultKVConfig ¶
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 StreamConfig ¶
type StreamConfig struct {
Name string
Subjects []string
MaxAge time.Duration
MaxBytes int64
Storage nats.StorageType
Compression nats.StoreCompression
}
func DefaultStreamConfig ¶
func DefaultStreamConfig(name string) StreamConfig
Click to show internal directories.
Click to hide internal directories.