admin

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 13 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 admin provisions mash endpoints: the permission template a NATS user needs, and the streams, consumer and directory record behind it. mash never mints users or holds account seeds; the operator's own tooling issues the user with these permissions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NSCFlags

func NSCFlags(owner, name string) []string

NSCFlags renders Permissions as `nsc add user` flags.

func Permissions

func Permissions(owner, name string) jwt.Permissions

Permissions is the complete permission set of endpoint name under owner (spec section 8). Anything not listed is denied.

Types

type Admin

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

Admin provisions endpoints with the account's admin credentials.

func New

func New(nc *nats.Conn, owner string) (*Admin, error)

New returns an Admin for owner.

func (*Admin) Deprovision

func (a *Admin) Deprovision(ctx context.Context, name string) error

Deprovision fences name's lease with a tombstone, then removes its directory record and inbox stream. The fence comes first: a session that is live or starting cannot take the lease back once its endpoint is gone (#10).

func (*Admin) EnsureInbox

func (a *Admin) EnsureInbox(ctx context.Context, name string) ([]string, error)

EnsureInbox makes sure name's inbox stream and its durable consumer exist, creating whichever is missing with the same configuration Provision uses. It is for an endpoint whose directory record already exists (Provision refuses those) and reports what it had to create: "stream", "consumer", both, or neither. An existing stream or consumer is only checked, never updated: one that differs from that configuration in any field mail depends on is an error naming the field, because fixing it in place could discard stored mail (a lower MaxBytes or MaxAge would). The user decides to deprovision it, which removes whatever the inbox holds, and provisions again.

func (*Admin) Init

func (a *Admin) Init(ctx context.Context) error

Init creates the directory and lease buckets. It is idempotent. A bucket from before buckets had a size cap (no MaxBytes) is bounded in place with a stream update, keeping its keys; a bucket that already has an explicit MaxBytes keeps it, larger or smaller, and nothing is purged.

func (*Admin) List

func (a *Admin) List(ctx context.Context) ([]store.Record, error)

List returns every directory record, sorted by name.

func (*Admin) Provision

func (a *Admin) Provision(ctx context.Context, name, user, account, note string, meta Meta) (store.Record, error)

Provision creates name's inbox stream, its consumer and, last, its directory record, so a half-done provision can simply be re-run.

func (*Admin) SetMeta

func (a *Admin) SetMeta(ctx context.Context, name string, u MetaUpdate) (store.Record, error)

SetMeta changes name's role, host and labels, only those given. It merges into the stored JSON object, so every other field, including ones a newer mash wrote, survives, and writes with a compare-and-set against the revision it read, re-reading and retrying if another write got in between.

type Meta

type Meta struct {
	Role, Host string
	Labels     map[string]string
}

Meta is a record's optional directory metadata.

type MetaUpdate

type MetaUpdate struct {
	Role, Host *string
	Labels     map[string]string
}

MetaUpdate names the metadata fields SetMeta changes; a nil field is left alone and a pointer to "" clears it. Labels is applied per key: a value sets that label, an empty value clears it, other labels are left alone.

Jump to

Keyboard shortcuts

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