nats

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package nats publishes outbox events to NATS JetStream. The event ID is sent as Nats-Msg-Id, so JetStream de-duplicates redeliveries inside the stream's duplicate window — effectively exactly-once into the stream.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Publisher)

Option configures the publisher.

func WithDefaultSubject

func WithDefaultSubject(s string) Option

WithDefaultSubject is used when Event.Topic is empty.

func WithSubjectPrefix

func WithSubjectPrefix(prefix string) Option

WithSubjectPrefix prepends prefix to every subject, e.g. "events." .

type Publisher

type Publisher struct {
	// contains filtered or unexported fields
}

Publisher implements xoutbox.BatchPublisher.

func New

func New(js jetstream.JetStream, opts ...Option) *Publisher

func (*Publisher) Publish

func (p *Publisher) Publish(ctx context.Context, e xoutbox.Event) error

func (*Publisher) PublishBatch

func (p *Publisher) PublishBatch(ctx context.Context, events []xoutbox.Event) []error

PublishBatch pipelines all messages with async publishing and waits for every ack.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL