natssetup

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package natssetup is the setup group under osapi nats: osapi nats setup, which creates osapi's streams and buckets on a NATS server that osapi does not run, such as an existing cluster.

Index

Constants

This section is empty.

Variables

View Source
var Group = command.Register(command.Define(
	"setup", "Create osapi's streams and buckets on a NATS server",
	command.Flat(),
	command.Under(command.ParentNATS),
	command.Uses[Deps](),
	command.Method[Input, Output]("setup").
		Short("Create osapi's streams and buckets on a NATS server").
		Long("It connects as the controller does, with `controller.nats`: its host,\n"+
			"port, namespace and auth. Run it one time before you start the controller\n"+
			"and the agents with that server.\n\n"+
			"Run it again after you change the settings of a stream or a bucket. Each\n"+
			"stream and bucket is created or updated to match the config, so running it\n"+
			"again changes nothing. `osapi nats start` does the same for the\n"+
			"embedded server when the server starts. Thus a deployment that runs the\n"+
			"NATS server of osapi does not need this command.").
		Example("-f /etc/osapi/osapi.yaml").
		Prints(sampleSetup).
		NoCheck("it makes the streams and buckets of osapi, which no osapi command lists: "+
			"the suite's controller and agent use each of them, and a second run changes nothing").
		Handle(Setup),
))

Group is the setup group's definition. It is flat, Under nats, so its method is osapi nats setup.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Config  config.Config
	Logger  *slog.Logger
	Prepare func(
		ctx context.Context,
		log *slog.Logger,
		opts *natsclient.Options,
		namespace string,
		cfg config.NATS,
	) error
	// Audit writes an entry to the audit log of the controller, or is nil.
	// It fails when NATS cannot be reached, such as before NATS starts.
	Audit func(ctx context.Context, e audit.Entry) error
}

Deps is what setup uses: the config, the log, and what prepares the server, bus.Prepare.

type Input

type Input struct{}

Input is the input of setup, which has none: the config is its input.

type Output

type Output struct {
	Host      string `json:"host"`
	Port      int    `json:"port"`
	Namespace string `json:"namespace"`
	Auth      string `json:"auth"`
	// contains filtered or unexported fields
}

Output is the server that setup prepared.

func Setup

func Setup(
	ctx context.Context,
	d Deps,
	_ Input,
) (Output, error)

Setup connects as the controller does, with controller.nats, and creates or updates each stream and bucket to match the config.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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