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 ¶
- func NSCFlags(owner, name string) []string
- func Permissions(owner, name string) jwt.Permissions
- type Admin
- func (a *Admin) Deprovision(ctx context.Context, name string) error
- func (a *Admin) EnsureInbox(ctx context.Context, name string) ([]string, error)
- func (a *Admin) Init(ctx context.Context) error
- func (a *Admin) List(ctx context.Context) ([]store.Record, error)
- func (a *Admin) Provision(ctx context.Context, name, user, account, note string, meta Meta) (store.Record, error)
- func (a *Admin) SetMeta(ctx context.Context, name string, u MetaUpdate) (store.Record, error)
- type Meta
- type MetaUpdate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 (*Admin) Deprovision ¶
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 ¶
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 ¶
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) 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 ¶
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 MetaUpdate ¶
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.