nats

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package nats provides a NATS-based message bus implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus[T any] struct {
	// contains filtered or unexported fields
}

Bus is a message bus implementation using NATS.

func New

func New[T any](config *bus.NatsBus) (*Bus[T], error)

New creates a new NATS bus.

func (*Bus[T]) Close

func (b *Bus[T]) Close()

Close closes the NATS bus.

func (*Bus[T]) Publish

func (b *Bus[T]) Publish(_ context.Context, topic string, msg T) error

Publish sends a message to a NATS topic.

func (*Bus[T]) Subscribe

func (b *Bus[T]) Subscribe(_ context.Context, topic string, handler func(T)) (unsubscribe func())

Subscribe registers a handler for a NATS topic.

func (*Bus[T]) SubscribeOnce

func (b *Bus[T]) SubscribeOnce(_ context.Context, topic string, handler func(T)) (unsubscribe func())

SubscribeOnce registers a one-time handler for a NATS topic.

Jump to

Keyboard shortcuts

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