nats

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package nats is the NATS Core driver for OpenAgentIO.

It maps the transport contract onto github.com/nats-io/nats.go: Publish, Subscribe (with optional queue groups), Request/Reply, and ephemeral _INBOX-backed Inbox for streaming responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Driver

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

Driver is the NATS Core transport. The zero value is unusable; construct with New and call Connect before any Publish/Subscribe/Request.

func New

func New(opts ...Option) *Driver

New constructs a Driver. Options are applied in order; later options win.

func (*Driver) Capabilities

func (*Driver) Capabilities() transport.Capabilities

Capabilities advertises NATS Core features. Persistence is false; durable streams are reserved for the future JetStream driver (v0.3).

func (*Driver) Close

func (d *Driver) Close() error

Close drains the connection so in-flight handlers complete, then releases the cancel context handed to subscription handlers. Idempotent.

func (*Driver) Connect

func (d *Driver) Connect(_ context.Context) error

Connect establishes the underlying NATS connection. Idempotent: a second call while already connected is a no-op.

func (*Driver) Flush

func (d *Driver) Flush() error

Flush blocks until the server has acknowledged all queued protocol writes. Useful before exiting a process to ensure the last Publish actually hit the wire, and in tests to make a Subscribe + Publish on different connections race-free.

func (*Driver) OpenInbox

func (d *Driver) OpenInbox(_ context.Context) (transport.Inbox, error)

func (*Driver) Publish

func (d *Driver) Publish(_ context.Context, msg *transport.RawMessage) error

func (*Driver) Request

func (d *Driver) Request(ctx context.Context, msg *transport.RawMessage) (*transport.RawMessage, error)

func (*Driver) Subscribe

func (d *Driver) Subscribe(_ context.Context, subject, queue string, h transport.Handler) (transport.Subscription, error)

type Option

type Option func(*Options)

Option mutates Options.

func Name

func Name(n string) Option

Name sets the client connection name reported to the server.

func URL

func URL(u string) Option

URL sets the NATS server URL (default "nats://localhost:4222").

type Options

type Options struct {
	URL  string
	Name string
}

Options configure the NATS driver.

Jump to

Keyboard shortcuts

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