nats-client

module
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT

README ΒΆ

nats-client

A Go package that connects to a NATS server and operates on it.

release codecov license build powered by conventional commits nats built with just gitHub commit activity go reference

One client for the connection and for JetStream.

One client and one constructor give connection management, JetStream, KV buckets and consumers. The client has four authentication types. Its create-or-update helpers make the setup idempotent.

πŸ“¦ Install

go get github.com/osapi-io/nats-client

✨ Features

The client documentation gives a quick start, the authentication types, and a reference for each feature.

Feature Description Docs Source
Connection management Connect to NATS with options and authentication types docs connect.go
Key-value buckets Create KV buckets, and read, write and delete keys docs kv.go
Object Store Store large blobs, which NATS divides into chunks docs objectstore.go
Streams Create streams and consumers, and read a stream docs stream.go
Messaging Publish, subscribe, and consume with a handler docs messaging.go
Telemetry OpenTelemetry spans and metrics for each call to NATS docs telemetry.go

πŸ§ͺ Examples

Each example is a standalone Go program. You can read it and run it.

Example What it shows
auth-none-stream Stream publish and subscribe, no authentication
auth-none-kv Create a KV bucket, no authentication
auth-user-pass-stream Stream with username and password authentication
auth-nkeys-stream Stream with NKey authentication
auth-creds-stream Stream with a credentials file (JWT)
workqueue-stream Work queue with one durable consumer for each priority

πŸ“š Documentation

🀝 Contributing

The Contributing guide gives the prerequisites, the setup, the conventions, and the pull request workflow.

πŸ“„ License

The MIT License.

Directories ΒΆ

Path Synopsis
pkg
client
Package client provides a NATS JetStream client with connection management, KV buckets, Object Store buckets, streams, messaging, and OpenTelemetry spans and metrics for each call.
Package client provides a NATS JetStream client with connection management, KV buckets, Object Store buckets, streams, messaging, and OpenTelemetry spans and metrics for each call.
client/mocks
Package mocks provides generated mock implementations for testing.
Package mocks provides generated mock implementations for testing.

Jump to

Keyboard shortcuts

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