Documentation
¶
Overview ¶
Package store holds mash's JetStream layout: per-endpoint inbox streams, their consumer, and the directory and lease KV buckets (spec section 5).
Index ¶
- Constants
- func ConsumerConfig() jetstream.ConsumerConfig
- func DirectoryConfig() jetstream.KeyValueConfig
- func DirectoryConfigFor(l Limits) jetstream.KeyValueConfig
- func InboxConfig(owner, name string) jetstream.StreamConfig
- func InboxConfigFor(owner, name string, l Limits) jetstream.StreamConfig
- func LeaseConfig() jetstream.KeyValueConfig
- func LeaseConfigFor(l Limits) jetstream.KeyValueConfig
- func LeaseTombstone() []byte
- func ValidCap(c string) bool
- func ValidCaps(caps []string) error
- func ValidDescription(v string) error
- func ValidLabelKey(k string) bool
- func ValidLabels(l map[string]string) error
- func ValidMeta(field, v string) error
- type Limits
- type Record
Constants ¶
const ( DirectoryBucket = "mash-directory" LeaseBucket = "mash-leases" Consumer = "deliver" )
Bucket and consumer names.
const ( InboxMaxAge = 30 * 24 * time.Hour InboxMaxBytes = 16 << 20 MaxMsgSize = 1 << 20 LeaseTTL = 90 * time.Second )
Inbox limits (spec 5.1).
const ( DirectoryMaxBytes = 16 << 20 LeaseMaxBytes = 4 << 20 )
Bucket size caps. Hosted NATS accounts (Synadia Cloud) reject a stream config with no MaxBytes, so every bucket sets one. Directory records and leases are tiny; these are generous.
const InboxDuplicateWindow = 2 * time.Minute
InboxDuplicateWindow is how long the inbox stream remembers a Nats-Msg-Id: a publish with the same id inside it is dropped, after it the message is stored again. It bounds what "send --id" can promise.
const MaxCaps = 8
MaxCaps is the most capability words one record may carry.
const MaxDescriptionLen = 256
MaxDescriptionLen is the longest Description.
const MaxLabels = 8
MaxLabels is the most labels one record may carry.
const MaxMetaLen = 64
MaxMetaLen is the longest Role, Host or label value.
Variables ¶
This section is empty.
Functions ¶
func ConsumerConfig ¶
func ConsumerConfig() jetstream.ConsumerConfig
ConsumerConfig is the durable consumer the endpoint manager reads its inbox through.
func DirectoryConfig ¶
func DirectoryConfig() jetstream.KeyValueConfig
DirectoryConfig is the directory bucket: name -> Record, written by the admin.
func DirectoryConfigFor ¶ added in v0.3.1
func DirectoryConfigFor(l Limits) jetstream.KeyValueConfig
DirectoryConfigFor is DirectoryConfig under limits l.
func InboxConfig ¶
func InboxConfig(owner, name string) jetstream.StreamConfig
InboxConfig is endpoint name's inbox stream. No subject transform: a stored Agent-Sender header must verify against the stored subject (SAP §13.8).
func InboxConfigFor ¶ added in v0.3.1
func InboxConfigFor(owner, name string, l Limits) jetstream.StreamConfig
InboxConfigFor is InboxConfig under limits l.
func LeaseConfig ¶
func LeaseConfig() jetstream.KeyValueConfig
LeaseConfig is the lease bucket: name -> holder, expiring unless refreshed.
func LeaseConfigFor ¶ added in v0.3.1
func LeaseConfigFor(l Limits) jetstream.KeyValueConfig
LeaseConfigFor is LeaseConfig under limits l.
func LeaseTombstone ¶
func LeaseTombstone() []byte
LeaseTombstone is what Deprovision writes to an endpoint's lease key: it fences the name, so a live or starting session cannot take the lease back after its endpoint is gone. It expires with the bucket's TTL (LeaseTTL) like any lease, and Provision clears it.
func ValidCap ¶ added in v0.3.2
ValidCap reports whether c is a legal capability word: [a-z][a-z0-9_.-]{0,31}.
func ValidCaps ¶ added in v0.3.2
ValidCaps checks a capability list: at most MaxCaps words, each passing ValidCap, none repeated.
func ValidDescription ¶ added in v0.3.2
ValidDescription checks a description: at most MaxDescriptionLen characters, printable, no tab or newline.
func ValidLabelKey ¶
ValidLabelKey reports whether k is a legal label key.
func ValidLabels ¶
ValidLabels checks a label set: at most MaxLabels keys, each key [a-z][a-z0-9_.-]{0,31}, each value passing ValidMeta.
Types ¶
type Limits ¶ added in v0.3.1
type Limits struct {
InboxMaxBytes int64
InboxMaxAge time.Duration
DirectoryMaxBytes int64
LeaseMaxBytes int64
InboxMaxConsumers int // -1 is unlimited
}
Limits are the configurable caps: the inbox's size, age and consumer count, and the two buckets' sizes. DefaultLimits is what mash has always used.
func DefaultLimits ¶ added in v0.3.1
func DefaultLimits() Limits
DefaultLimits returns the built-in limits.
type Record ¶
type Record struct {
Name string `json:"name"`
Owner string `json:"owner"`
Agent string `json:"agent"`
AgentToken string `json:"agent_token"`
Account string `json:"account"`
User string `json:"user"`
MailSubject string `json:"mail_subject"`
Created string `json:"created"`
Note string `json:"note,omitempty"`
// Role, Host and Labels are optional directory metadata: what the endpoint is for, the machine it is meant to run
// on, and free-form key=value labels (for example a team, project or fleet). They are the identity on record; the
// lease is the live view. Readers from before these fields ignore them.
Role string `json:"role,omitempty"`
Host string `json:"host,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// Description is free text on what the endpoint does, and Caps are up to MaxCaps capability words (sorted), both
// set by the admin. Readers from before these fields ignore them, and set-meta keeps fields it does not know.
Description string `json:"description,omitempty"`
Caps []string `json:"caps,omitempty"`
}
Record is one directory entry (spec 6.1).