Documentation
¶
Overview ¶
Package wire is the bytes a TinyStore server and its clients exchange over any byte stream, as docs/wire.md lays them out: frames, the MessagePack profile their bodies follow, the messages and the error codes. It imports only the standard library and knows no engine's Go type, so a client links it without linking SQLite.
frame.go a frame's twelve-byte header, its rules, and a Reader of frames msgpack.go the profile: Append functions that write canonically, a Decoder that checks message.go HELLO, WELCOME and GOAWAY serve.go SERVE, and the proof a WELCOME answers a HELLO's challenge with errors.go the codes, and Error, a stream's failure kv.go, jobs.go, blobs.go, records.go, sql.go, metrics.go each engine's messages testdata/ the vectors every SDK is tested against
Index ¶
- Constants
- Variables
- func AppendArray(dst []byte, n int) []byte
- func AppendBin(dst []byte, b []byte) []byte
- func AppendBool(dst []byte, v bool) []byte
- func AppendCredit(dst []byte, stream, n uint32) []byte
- func AppendFloat(dst []byte, v float64) []byte
- func AppendFloats(dst []byte, column []float64) []byte
- func AppendFrame(dst []byte, h Header, body []byte) []byte
- func AppendHeader(dst []byte, h Header) []byte
- func AppendInt(dst []byte, v int64) []byte
- func AppendInts(dst []byte, column []int64) []byte
- func AppendKey(dst []byte, text string) []byte
- func AppendMap(dst []byte, n int) []byte
- func AppendNil(dst []byte) []byte
- func AppendSQLValue(dst []byte, value any) []byte
- func AppendStr(dst []byte, s string) []byte
- func AppendText(dst []byte, text string) []byte
- func AppendUint(dst []byte, v uint64) []byte
- func Granted(body []byte) uint32
- func Prove(secret, challenge []byte) []byte
- func SetLength(frame []byte)
- func SkipUnknown(err error) error
- type BlobsBucket
- type BlobsCall
- type BlobsObject
- type BlobsPage
- type BlobsTotal
- type Capability
- type Clock
- type Code
- type Decoder
- func (d *Decoder) Bin() []byte
- func (d *Decoder) Bool() bool
- func (d *Decoder) Duration() int64
- func (d *Decoder) End() error
- func (d *Decoder) Err() error
- func (d *Decoder) Fail(format string, args ...any)
- func (d *Decoder) Fields() iter.Seq[uint64]
- func (d *Decoder) Float() float64
- func (d *Decoder) Floats() []float64
- func (d *Decoder) Int() int64
- func (d *Decoder) Ints() []int64
- func (d *Decoder) Items() iter.Seq[int]
- func (d *Decoder) KVValue() KVValue
- func (d *Decoder) KeyText() string
- func (d *Decoder) Names() iter.Seq[string]
- func (d *Decoder) Nil() bool
- func (d *Decoder) SQLValue() any
- func (d *Decoder) Skip()
- func (d *Decoder) Str() string
- func (d *Decoder) StrBytes() []byte
- func (d *Decoder) Strs() []string
- func (d *Decoder) Text() string
- func (d *Decoder) Type() Type
- func (d *Decoder) Uint() uint64
- func (d *Decoder) Uint16() uint16
- func (d *Decoder) Uint32() uint32
- type Empty
- type Error
- type Flags
- type GoAway
- type Handle
- type Header
- type Hello
- type JobsAnswer
- type JobsBatch
- type JobsChange
- type JobsEntry
- type JobsHeld
- type JobsJob
- type JobsKept
- type JobsKey
- type JobsLease
- type JobsOutcome
- type JobsOutcomes
- type JobsPage
- type JobsQuery
- type JobsQueue
- type JobsSettled
- type JobsWorkers
- type KVAllowance
- type KVBucket
- type KVCall
- type KVCalls
- type KVConfigChange
- type KVEntry
- type KVKept
- type KVKind
- type KVOperation
- type KVPage
- type KVResults
- type KVValue
- type KVWindow
- type KVWindowUsage
- type Kind
- type Map
- func (m *Map) Bin(key uint64, b []byte)
- func (m *Map) Bool(key uint64, v bool)
- func (m *Map) Buf() []byte
- func (m *Map) End() []byte
- func (m *Map) Float(key uint64, v float64)
- func (m *Map) Int(key uint64, v int64)
- func (m *Map) Key(key uint64)
- func (m *Map) SetBuf(buf []byte)
- func (m *Map) Str(key uint64, s string)
- func (m *Map) Uint(key, v uint64)
- type Method
- type MetricsBatch
- type MetricsBucket
- type MetricsBuckets
- type MetricsCondition
- type MetricsDropped
- type MetricsLabels
- type MetricsLimits
- type MetricsPlan
- type MetricsRange
- type MetricsSeries
- type Published
- type Reader
- type Record
- type RecordField
- type RecordsBatch
- type RecordsBudget
- type RecordsCursor
- type RecordsDamage
- type RecordsDamages
- type RecordsPage
- type RecordsQuery
- type RecordsStream
- type Repeat
- type SQLColumns
- type SQLDatabase
- type SQLDone
- type SQLMigration
- type SQLResult
- type SQLResults
- type SQLRow
- type SQLStatement
- type SQLStatements
- type Type
- type UnknownFieldsError
- type Welcome
Constants ¶
const ( JobAck = 1 // done JobRetry = 2 // this attempt failed: again after the backoff, or At or After JobFail = 3 // failed for good JobSnooze = 4 // again at At or After, the attempt not counted JobExtend = 5 // the lease runs After from now JobProgress = 6 // what the handler reports of the job, which stays in its hands )
How a worker settles a job, a JobsOutcome's How.
const ( Protocol = 1 OldestProtocol = 1 )
Protocol is the newest version of this protocol a HELLO and a WELCOME name, and OldestProtocol the oldest a server still speaks. A connection speaks the older of its client's newest and its server's, so that a client newer than its server speaks the server's protocol rather than none.
const ( InstanceSize = 16 SecretSize = 32 ChallengeSize = 16 )
the bytes of a start's instance and secret, and of a HELLO's challenge
const DefaultStreamCredit = 2 << 20
DefaultStreamCredit is the DATA a server sends on a stream before its client grants more, when the client's HELLO does not say: at least the largest body, which must fit the credit it is sent under.
const HeaderSize = 12
HeaderSize is a frame's header, little-endian, before its body:
0 4 5 6 8 12 │ body length │ kind │ flags │ method │ stream │ body … u32 u8 u8 u16 u32
Variables ¶
var ErrMessage = errors.New("invalid message")
ErrMessage is a body that the profile does not allow, or that is not the message its frame and method ask for.
var ErrProtocol = errors.New("protocol error")
ErrProtocol is a frame or a handshake that breaks the protocol; the connection ends with it.
var ErrUnknownField = errors.New("a field this reader does not know")
ErrUnknownField is a message carrying a field its reader does not know.
A server refuses such a request: a field it skipped could change what the client asked, so answering would answer another question. A client reading an answer, and a server reading a HELLO, skip it, since a newer peer adds only what an older one may skip there.
Functions ¶
func AppendArray ¶
func AppendBool ¶
func AppendCredit ¶
AppendCredit appends a CREDIT granting n bytes on stream, 0 for the connection.
func AppendFloat ¶
AppendFloat writes a float 64 with its bits: -0 → cb 80 00 00 00 00 00 00 00.
func AppendFloats ¶
AppendFloats writes a column of floats as a bin, each its eight bytes of bits little-endian, so that a NaN's payload and -0 come back as they went.
func AppendHeader ¶
AppendHeader appends h, whose Length SetLength may fix once the body is appended after it.
func AppendInt ¶
AppendInt writes a value from 0 as AppendUint does, and a negative one in the signed family's shortest form:
-1 → ff -33 → d0 df -300 → d1 fe d4
func AppendInts ¶
AppendInts writes a column of integers as a bin, each eight bytes little-endian:
[1, -1] → c4 10 01 00 00 00 00 00 00 00 ff ff ff ff ff ff ff ff
func AppendSQLValue ¶
AppendSQLValue writes a value as SQLite returned it, or as an argument travels: TEXT that is not UTF-8 as bin.
func AppendText ¶
AppendText writes text as a str, or as a bin when its bytes are not UTF-8, as a program's output may be.
func AppendUint ¶
AppendUint writes v in the unsigned family's shortest form:
7 → 07 300 → cd 01 2c 70000 → ce 00 01 11 70
func Prove ¶
Prove is a WELCOME's answer to a HELLO's challenge: an HMAC-SHA256 of the challenge, keyed with the secret SERVE names.
func SetLength ¶
func SetLength(frame []byte)
SetLength writes the length of the body that follows a frame's header.
func SkipUnknown ¶
SkipUnknown is a decode's error with the fields it did not know forgiven, for a reader a newer peer may add to: a client reading an answer, or a server reading a HELLO.
Types ¶
type BlobsBucket ¶
type BlobsBucket struct {
Name string
// DefaultTTL is in milliseconds, zero for none.
DefaultTTL int64
// MaxSize bounds an object's bytes, zero for no bound.
MaxSize uint64
}
BlobsBucket is blobs.open's request: a bucket by name, with its handle's options.
func (BlobsBucket) Append ¶
func (b BlobsBucket) Append(dst []byte) []byte
func (*BlobsBucket) Decode ¶
func (b *BlobsBucket) Decode(body []byte) error
type BlobsCall ¶
type BlobsCall struct {
Handle uint64
Owners []string
Key string
To string // copy's and move's destination
ContentType *string // nil keeps what the object has, or is none
Meta map[string]string // nil keeps what the object has; otherwise it replaces all
TTL int64 // milliseconds
ExpireAt int64 // unix milliseconds
Size int64 // a put's length; -1, and absent, for unknown
IfMatch string // as an HTTP If-Match header spells it
IfNoneMatch bool
Prefix string // a scan's
After string // a scan's
Limit uint64 // a scan's
Offset int64 // a get's first byte
Length int64 // a get's bytes; zero reads to the end
}
BlobsCall is the request of every blobs method but open: an object by its key under the folder its owners name, or that folder for usage, clear and scan, and what the method takes. A key is a path; an owner is a segment, a str or an integer.
type BlobsObject ¶
type BlobsObject struct {
Found bool
Key string
Size int64
ETag string
ContentType string
Modified int64 // unix milliseconds
Expires int64 // unix milliseconds; zero for an object that does not expire
Meta map[string]string
}
BlobsObject is an object as the file knows it: stat's, copy's, move's and put's answer, get's header, and a scan's item. Found is false for a key that holds no live object, and then nothing else is set.
func (BlobsObject) Append ¶
func (o BlobsObject) Append(dst []byte) []byte
func (*BlobsObject) Decode ¶
func (o *BlobsObject) Decode(body []byte) error
type BlobsPage ¶
BlobsPage ends a scan: More says the limit ended it before the folder did, and After is the key the next page begins after.
type BlobsTotal ¶
BlobsTotal is usage's answer: the objects under a folder and their bytes.
func (BlobsTotal) Append ¶
func (u BlobsTotal) Append(dst []byte) []byte
func (*BlobsTotal) Decode ¶
func (u *BlobsTotal) Decode(body []byte) error
type Capability ¶
type Capability string
Capability is what a connection may do.
const ( // Admin may do everything, the schema included. Admin Capability = "admin" // Data reads and writes every engine's data and changes no schema. Data Capability = "data" )
type Clock ¶
Clock is server.clock's request, a time to set the clock to or a while to move it forward by, neither to read it, and its answer, the time the clock reads once moved.
type Code ¶
type Code string
Code is what failed, as a stream's Error or a GoAway says it.
const ( CodeInvalid Code = "invalid" // the request cannot be done as asked CodeLimit Code = "limit" // a bound: memory, size or count CodeClosed Code = "closed" // the store or the handle closed CodeInUse Code = "in_use" // a name is taken CodeConflict Code = "conflict" // a condition or a version no longer holds CodeCorrupt Code = "corrupt" // stored bytes no longer read CodeTooOld Code = "too_old" // a time before its engine's window CodeTooNew Code = "too_new" // a time past its engine's window CodeSuspended Code = "suspended" // a series in quarantine CodeOutcomeUnknown Code = "outcome_unknown" // a commit whose result is unknown CodePermission Code = "permission" // the connection's capability does not allow it CodeUnimplemented Code = "unimplemented" // a method this server does not have CodeCancelled Code = "cancelled" // the client cancelled it CodeInternal Code = "internal" // a fault of the server's // a GoAway's alone CodeProtocol Code = "protocol" // a frame the server cannot take CodeUnauthenticated Code = "unauthenticated" // a HELLO without the token the connection needs )
The first nine are the store's sentinels, so that a client's error means what errors.Is means in Go.
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder reads one message and checks the profile as it goes. Its first error sticks and every read after it returns a zero value, so a message's decoder reads each field and asks End once. What it returns of the body aliases the body.
func NewDecoder ¶
func (*Decoder) End ¶
End is the message's error, or one when bytes follow its value, since a message is one value; then an UnknownFieldsError when the reader left a field unread, every other field read.
func (*Decoder) Fields ¶
Fields reads a map with unsigned keys, a message or a field of one, yielding each key with its value next: the loop reads the value, or leaves it to be skipped, well formed and within bounds, and named by End as a field the reader does not know. A key twice is invalid.
func (*Decoder) Float ¶
Float reads a float 64 with its bits, or an integer a float 64 holds exactly, since a JavaScript encoder writes 3.0 as 3.
func (*Decoder) KeyText ¶
KeyText reads a key's text: a str or a bin as it is, an integer as its decimal spelling, so that 42 and "42" name one key.
func (*Decoder) Names ¶
Names reads a map of names, an error's what or a series' labels, yielding each name with its value next, as Fields does.
func (*Decoder) Nil ¶
Nil reads a nil if one is next and says so; any other value is left for the field's own reader. A field allows nil only where it says it does.
func (*Decoder) SQLValue ¶
SQLValue reads one of SQLite's five, or a bool: nil, an int64, a float64, a string or a []byte aliasing the body. An integer past int64 is refused, as SQLite would keep it as a REAL.
func (*Decoder) Skip ¶
func (d *Decoder) Skip()
Skip reads past one value, checking that it is well formed and within bounds as if it were read.
type Empty ¶
type Empty struct{}
Empty is a message without fields: an answer that says only that its call was done.
type Error ¶
type Error struct {
Code Code
Message string // what failed, as the engine's error says it
// What names the item the failure is about: a bucket and key, a queue
// and key, a series' labels, a table and constraint.
What map[string]string
}
Error is a stream's failure, the body of its final frame with FlagError.
type Handle ¶
type Handle struct {
Handle uint64
}
Handle answers an open with the number the calls on its handle carry.
type Header ¶
type Header struct {
Length uint32 // the body's
Kind Kind
Flags Flags
Method Method
Stream uint32
}
func ParseHeader ¶
ParseHeader reads a header from its twelve bytes without checking it.
type Hello ¶
type Hello struct {
Protocol uint64
Client string // a name and version, for logs
Token string // required on TCP
// MaxBody is the largest body the client takes; zero takes the server's.
MaxBody uint32
// StreamCredit is the DATA the server may send on a stream before the
// client grants more; zero is DefaultStreamCredit.
StreamCredit uint32
// Challenge is ChallengeSize random bytes from a client that found the
// server through SERVE, which the WELCOME's Proof answers.
Challenge []byte
}
Hello is a client's first frame.
type JobsAnswer ¶
type JobsAnswer struct {
Job uint64
Name string
// Answer is jobs.keep's: the step's answer as JSON.
Answer string
}
JobsAnswer names a step of a held job's run: jobs.step's request, for the answer the run kept under it, and jobs.keep's, with the answer to keep. Job is the number the job was held under, by a claim or a work stream.
func (JobsAnswer) Append ¶
func (a JobsAnswer) Append(dst []byte) []byte
func (*JobsAnswer) Decode ¶
func (a *JobsAnswer) Decode(body []byte) error
type JobsChange ¶
JobsChange is jobs.update's request: a job by its key, given a new value, and a new time or repeat when it names one.
func (JobsChange) Append ¶
func (u JobsChange) Append(dst []byte) []byte
func (*JobsChange) Decode ¶
func (u *JobsChange) Decode(body []byte) error
type JobsEntry ¶
type JobsEntry struct {
Found bool
Key string
Value string
At int64
Attempt uint64
// State is 1 waiting, 2 running, 3 failed, 4 done or 5 cancelled.
State uint64
// Err is the job's last failure.
Err string
// Repeat is a repeating job's cron text and zone.
Repeat string
// Ahead counts the jobs that run before a waiting one, up to 10,000.
Ahead uint64
// Progress is what a running job's handler last reported, as JSON.
Progress string
// Ran is when the last run a handler finished began, unix milliseconds,
// and Took how many milliseconds it took.
Ran int64
Took uint64
}
JobsEntry is a job as its queue holds it: get's answer, a scan's item and a watch's.
type JobsHeld ¶
type JobsHeld struct {
Found bool
Job uint64
Key string
Value string
At int64
Attempt uint64
// Cancelled, on a work stream whose workers take cancels, names a job in
// the client's hands that Cancel took: its handler should stop, and its
// outcome settles nothing.
Cancelled bool
}
JobsHeld is a job in a worker's hands: claim's answer, found false when no job was due, and an item of a work stream. Job is the number its settlement names.
type JobsJob ¶
type JobsJob struct {
Value string
Key string
At int64 // unix milliseconds
After int64 // milliseconds
Repeat *Repeat
}
JobsJob is a job to enqueue: its value as JSON text, its key, when it runs, at a time or after a while, and how it repeats.
type JobsKept ¶
JobsKept is jobs.step's answer: the answer a step kept, found false for a step its run has not kept.
type JobsLease ¶
JobsLease is jobs.claim's request: the next due job, leased for Lease milliseconds, the queue's when zero.
type JobsOutcome ¶
type JobsOutcome struct {
Job uint64
How uint64
Err string
At int64 // unix milliseconds
After int64 // milliseconds
// HasAfter says the outcome carries After, 0 included: a retry after
// nothing runs now, where one without a time waits its backoff.
HasAfter bool
// Progress is a progress outcome's report, as JSON.
Progress string
}
JobsOutcome settles a job a worker held: a settlement's item, and what a worker sends back on a work stream.
func (JobsOutcome) Append ¶
func (o JobsOutcome) Append(dst []byte) []byte
func (*JobsOutcome) Decode ¶
func (o *JobsOutcome) Decode(body []byte) error
type JobsOutcomes ¶
type JobsOutcomes struct {
Outcomes []JobsOutcome
}
JobsOutcomes is jobs.settle's request: outcomes of claimed jobs, written together.
func (JobsOutcomes) Append ¶
func (s JobsOutcomes) Append(dst []byte) []byte
func (*JobsOutcomes) Decode ¶
func (s *JobsOutcomes) Decode(body []byte) error
type JobsPage ¶
JobsPage ends a scan: More says the page ended before the jobs did, and After is where the next begins.
type JobsQuery ¶
type JobsQuery struct {
Handle uint64
// Prefix selects the keys under it, in the byte order of their text.
Prefix string
// State 3 with no prefix selects the failed jobs, the last failed first.
State uint64
// After is where the page before ended.
After string
Limit uint64
}
JobsQuery is jobs.scan's request.
type JobsQueue ¶
type JobsQueue struct {
Name string
Lease int64
MaxAttempts uint64
BackoffFirst int64
BackoffMost int64
MaxWaiting uint64
KeepFailed int64
KeepDone int64
Schedule *Repeat
MaxRunning uint64
In string // the database whose file keeps the queue, which its sql.batch enqueues in
}
JobsQueue is jobs.open's request: a queue by name with its policy, or a schedule, a queue holding one repeating job under its name. A duration is milliseconds, zero for the queue's default.
type JobsSettled ¶
type JobsSettled struct {
Errors []*Error
}
JobsSettled answers a settlement: nil for each outcome written, or the error that refused it, in their order.
func (JobsSettled) Append ¶
func (s JobsSettled) Append(dst []byte) []byte
func (*JobsSettled) Decode ¶
func (s *JobsSettled) Decode(body []byte) error
type JobsWorkers ¶
type JobsWorkers struct {
Handle uint64
Workers uint64
Timeout int64
// UntilIdle ends the loop once no job is due and none runs, as a test
// wants it.
UntilIdle bool
// Cancels asks for a cancelled held item when Cancel takes a job in the
// client's hands, which a client that stops its handler wants.
Cancels bool
}
JobsWorkers is jobs.work's request: the queue's Work loop, whose jobs come to the client as DATA and whose outcomes go back as DATA. Timeout is a job's time in the client's hands, milliseconds, a minute when zero.
func (JobsWorkers) Append ¶
func (w JobsWorkers) Append(dst []byte) []byte
func (*JobsWorkers) Decode ¶
func (w *JobsWorkers) Decode(body []byte) error
type KVAllowance ¶
type KVAllowance struct {
OK bool
Left uint64
RetryAfter uint64
Windows []KVWindowUsage
}
KVAllowance is kv.allow's answer, and a quota's kv.usage: whether the requests pass, how many more would pass now, and, when they do not, how many milliseconds until they would, rounded up; and a quota's windows.
func (KVAllowance) Append ¶
func (a KVAllowance) Append(dst []byte) []byte
func (*KVAllowance) Decode ¶
func (a *KVAllowance) Decode(body []byte) error
type KVBucket ¶
type KVBucket struct {
Name string
Counters bool
DefaultTTL int64
Sliding int64
LoseAtMost int64
Config bool
Rate uint64 // a limiter's requests every Per
Per int64
Burst uint64
Once bool // the answers kv.run keeps
Windows []KVWindow
}
KVBucket is kv.open's request: a bucket of values, counters, a config, a limiter, once's answers or a quota, by name, with its handle's options. A duration is milliseconds, zero for none; a limiter is a bucket with a rate, and a quota one with windows.
type KVCall ¶
type KVCall struct {
Handle uint64
Owners []string
Key string
Value KVValue
TTL int64 // milliseconds
ExpireAt int64 // unix milliseconds
IfVersion []byte
IfAbsent bool
N int64 // what add adds, and max compares
After string // where a scan's page begins
Limit uint64 // the keys a scan's page returns
}
KVCall is the request of every kv method but open, batch and view: the key it is about, or the branch a clear or a scan is, and what the method takes. A key is its text: a str, a bin, or an integer by its decimal spelling.
type KVCalls ¶
type KVCalls struct {
Calls []KVOperation
}
KVCalls is kv.batch's request, calls run in one transaction that a failure of any rolls back, and kv.view's, reads from one snapshot. Each is a KVCall's fields with its method under key 0.
type KVConfigChange ¶
KVConfigChange is kv.configure's request: the fields a config keeps, a path and its JSON each, and the paths it forgets, in one transaction.
func (KVConfigChange) Append ¶
func (c KVConfigChange) Append(dst []byte) []byte
func (*KVConfigChange) Decode ¶
func (c *KVConfigChange) Decode(body []byte) error
type KVEntry ¶
type KVEntry struct {
// Found says a live key held a value, or for set that it wrote. It is
// false when IfAbsent found a live key, whose entry this is.
Found bool
Value KVValue
Version []byte
// Expires is unix milliseconds, zero for a key that never expires.
Expires int64
// Key is a scan item's alone.
Key string
}
KVEntry answers a call about one key, and is an item of a scan.
type KVKept ¶
KVKept is an item of kv.watch: a config's kept fields, a path and its JSON each, and how many changes the server's process has made to them.
type KVOperation ¶
type KVPage ¶
KVPage ends a scan: More says its limit, or its bytes, ended the page before the branch did, and After is the key the next page begins after.
type KVResults ¶
type KVResults struct {
Entries []KVEntry
}
KVResults answers a batch or a view: an entry a call, in their order.
type KVWindow ¶
KVWindow is one of a quota's windows: a key may use up to Limit every Per milliseconds, from its first use.
type KVWindowUsage ¶
KVWindowUsage is one of a quota's windows of a key: what it used of its limit, what is left, and when it resets, in unix milliseconds, zero for a window not started.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map appends a message a field at a time, keys ascending, counting the fields as they are added, so that a field the message lacks is simply not written. Its count is one byte, set by End, which makes room for a map 16's three when sixteen fields or more were written.
func (*Map) Buf ¶
Buf is the message so far, for a value Key has made room for; the caller hands back what it appended with SetBuf.
type Method ¶
type Method uint16
Method is an operation: its high byte names the engine and its low byte the operation. A new engine takes a new high byte, so the frame stays as it is.
const ( BlobsOpen Method = 0x0301 BlobsStat Method = 0x0302 BlobsDelete Method = 0x0303 BlobsCopy Method = 0x0304 BlobsMove Method = 0x0305 BlobsUsage Method = 0x0306 BlobsClear Method = 0x0307 BlobsScan Method = 0x0308 BlobsPut Method = 0x0309 BlobsGet Method = 0x030a )
The blobs engine's methods, docs/wire.md#blobs.
const ( JobsOpen Method = 0x0201 JobsEnqueue Method = 0x0202 JobsUpdate Method = 0x0203 JobsCancel Method = 0x0204 JobsGet Method = 0x0205 JobsClaim Method = 0x0206 JobsSettle Method = 0x0207 JobsScan Method = 0x0208 JobsWork Method = 0x0209 JobsWatch Method = 0x020a JobsStep Method = 0x020b JobsKeep Method = 0x020c )
The jobs engine's methods, docs/wire.md#jobs.
const ( KVOpen Method = 0x0101 KVGet Method = 0x0102 KVHas Method = 0x0103 KVSet Method = 0x0104 KVDelete Method = 0x0105 KVTake Method = 0x0106 KVTouch Method = 0x0107 KVAdd Method = 0x0108 KVMax Method = 0x0109 KVClear Method = 0x010a KVBatch Method = 0x010b KVView Method = 0x010c KVScan Method = 0x010d KVAllow Method = 0x010e KVConfigure Method = 0x010f KVWatch Method = 0x0110 KVRun Method = 0x0111 KVUsage Method = 0x0112 KVRefund Method = 0x0113 )
The kv engine's methods, docs/wire.md#kv.
const ( MetricsIngest Method = 0x0601 MetricsRead Method = 0x0602 MetricsAggregate Method = 0x0603 MetricsDrop Method = 0x0604 MetricsExplain Method = 0x0605 )
The metrics engine's methods, docs/wire.md#metrics. Metrics are one store of series, named by their labels, so none opens a handle.
const ( RecordsAppend Method = 0x0501 RecordsRead Method = 0x0502 RecordsFollow Method = 0x0503 RecordsLines Method = 0x0504 RecordsDamaged Method = 0x0505 RecordsDrop Method = 0x0506 )
The records engine's methods, docs/wire.md#records. Records are one log of the store's, whose calls name their streams, so none opens a handle.
const ( // ServerStop asks a server to stop as its closing does: the streams // running finish, every connection is told GOAWAY, and a sidecar gives // back SERVE and its directory. An admin's alone, {} each way. ServerStop Method = 0x0001 // ServerClock moves the clock a private server started for a test runs // on, or reads it: a Clock each way. An admin's alone. ServerClock Method = 0x0002 )
The server's own methods, in the range below the engines'.
const ( SQLOpen Method = 0x0401 SQLExec Method = 0x0402 SQLQuery Method = 0x0403 SQLBatch Method = 0x0404 )
The sql engine's methods, docs/wire.md#sql.
const ServerBackup Method = 0x0003
ServerBackup is a download of the whole store as one zip, as the backup package writes it: {} to ask, then the zip's bytes in DATA. An admin's alone.
type MetricsBatch ¶
type MetricsBatch struct {
Series []MetricsSeries
}
MetricsBatch is metrics.ingest's request: series and their samples one call stores, all or none.
func (MetricsBatch) Append ¶
func (b MetricsBatch) Append(dst []byte) []byte
func (*MetricsBatch) Decode ¶
func (b *MetricsBatch) Decode(body []byte) error
type MetricsBucket ¶
type MetricsBucket struct {
// From and To are the bucket's edges in unix milliseconds.
From, To int64
// Count is the samples it counted and Resets the resets among them.
Count, Resets int64
Value float64
// Overflow says the value overflowed a float.
Overflow bool
// Partial says retention cut the bucket.
Partial bool
}
MetricsBucket is one bucket of an aggregate.
type MetricsBuckets ¶
type MetricsBuckets struct {
Labels map[string]string
Kind string
Buckets []MetricsBucket
}
MetricsBuckets is an item of aggregate's download: a series and buckets of it, the edges it was asked for.
func (MetricsBuckets) Append ¶
func (b MetricsBuckets) Append(dst []byte) []byte
func (*MetricsBuckets) Decode ¶
func (b *MetricsBuckets) Decode(body []byte) error
type MetricsCondition ¶
MetricsCondition is what a label's value must be beyond equality: one_of or none_of its values, or the prefix that is its one value.
func (MetricsCondition) Append ¶
func (c MetricsCondition) Append(dst []byte) []byte
type MetricsDropped ¶
MetricsDropped answers drop: whether the series was there, and the groups removed without the payload rows their directory no longer names.
func (MetricsDropped) Append ¶
func (r MetricsDropped) Append(dst []byte) []byte
func (*MetricsDropped) Decode ¶
func (r *MetricsDropped) Decode(body []byte) error
type MetricsLabels ¶
MetricsLabels is drop's request: the labels of the one series it removes.
func (MetricsLabels) Append ¶
func (l MetricsLabels) Append(dst []byte) []byte
func (*MetricsLabels) Decode ¶
func (l *MetricsLabels) Decode(body []byte) error
type MetricsLimits ¶
type MetricsLimits struct {
Series, Blocks, PayloadBytes, DecodedSamples, OutputSamples uint64
}
MetricsLimits bound one read or aggregate: the series it matches, the blocks it decodes, the bytes it fetches, the samples it decodes and the samples or buckets it answers. Zero is the server's.
type MetricsPlan ¶
type MetricsPlan struct {
Series, Blocks, Summarized, Bytes, Decoded uint64
Limits MetricsLimits
Stops *Error
}
MetricsPlan is metrics.explain's answer: what the read, or the aggregate when the range names an operation, would spend, each beside its limit, and the limit it would stop at, an error of code limit naming it.
func (MetricsPlan) Append ¶
func (p MetricsPlan) Append(dst []byte) []byte
func (*MetricsPlan) Decode ¶
func (p *MetricsPlan) Decode(body []byte) error
type MetricsRange ¶
type MetricsRange struct {
Matchers map[string]string
From, To int64
Limits MetricsLimits
Width int64
Op string // count, sum, min, max, avg, increase, rate or delta
Where []MetricsCondition
// By and Without group an aggregate's series; an empty one, not nil, is
// sent and groups by no label.
By, Without []string
}
MetricsRange is read's and aggregate's request: the series every matcher names exactly, in [From, To) of unix milliseconds, within limits that may only narrow the server's. Aggregate adds its buckets' width in milliseconds and its operation.
func (MetricsRange) Append ¶
func (r MetricsRange) Append(dst []byte) []byte
func (*MetricsRange) Decode ¶
func (r *MetricsRange) Decode(body []byte) error
type MetricsSeries ¶
type MetricsSeries struct {
Labels map[string]string
Kind string // "gauge" or "counter"
Times []int64
Values []float64
}
MetricsSeries is a series and samples of it: an item of ingest's request and of read's download. Times are unix milliseconds, one for each value, whose bits are the data.
func (MetricsSeries) Append ¶
func (s MetricsSeries) Append(dst []byte) []byte
func (*MetricsSeries) Decode ¶
func (s *MetricsSeries) Decode(body []byte) error
type Published ¶
type Published struct {
Protocol int `json:"protocol"`
Server string `json:"server"`
PID int `json:"pid"`
Instance string `json:"instance"` // InstanceSize bytes, base64url without padding
Secret string `json:"secret"` // SecretSize bytes, base64url without padding
Endpoints []string `json:"endpoints"`
// Sidecar is a server started for its clients, which a client of a newer
// release stops and starts its own in its place; a program's own server
// and one a person runs say nothing.
Sidecar bool `json:"sidecar,omitempty"`
}
Published is SERVE, the file in <dir>/server/ where a store's sidecar says where it listens. Only the directory's owner can read it, so its secret is what a client that found the sidecar there checks it by before its first request: a process that took the endpoint of a server gone cannot prove it.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads frames from a stream of bytes. A header that breaks the protocol, or announces a body past the agreed maximum, is refused before a byte of its body is read.
func (*Reader) Body ¶
Body reads the body the last header announced into room, grown when it is too small, so that the caller decides where bodies live.
func (*Reader) Header ¶
Header reads and checks the next frame's header; Body reads the body it announces. The end of the stream between two frames is io.EOF.
func (*Reader) SetMaxBody ¶
SetMaxBody changes the largest body a frame may carry, as a handshake agrees it.
type Record ¶
type Record struct {
// At is unix nanoseconds.
At int64
Stream string
Name string
// Level is slog's: -4 debug, 0 info, 4 warn, 8 error. Nil is absent.
Level *int64
// Body is absent when nil, which an empty body is not.
Body *string
// TraceID is 16 bytes and SpanID 8; empty is none.
TraceID []byte
SpanID []byte
Context []RecordField
Attrs []RecordField
}
Record is one log line or event. Context and Attrs keep their order and repeated keys.
type RecordField ¶
RecordField is a key and its value as JSON, spelled as it was given. Fields travel as one array, a key and then its value, so that keys may repeat.
type RecordsBatch ¶
type RecordsBatch struct {
Records []Record
}
RecordsBatch is records.append's request: records one transaction writes, all or none.
func (RecordsBatch) Append ¶
func (b RecordsBatch) Append(dst []byte) []byte
func (*RecordsBatch) Decode ¶
func (b *RecordsBatch) Decode(body []byte) error
type RecordsBudget ¶
type RecordsBudget struct {
Blocks, Bytes, Decoded uint64
}
RecordsBudget bounds one read: the blocks it opens, the bytes it fetches and the records it decodes.
type RecordsCursor ¶
RecordsCursor is a place in the sealed segments, in the order they were sealed. It is follow's request, with the records it asks for at most, and its trailer: the place the next follow begins at, with the segments retention removed before the cursor reached them.
func (RecordsCursor) Append ¶
func (c RecordsCursor) Append(dst []byte) []byte
func (*RecordsCursor) Decode ¶
func (c *RecordsCursor) Decode(body []byte) error
type RecordsDamage ¶
type RecordsDamage struct {
Stream string
Segment int64
HeadRow int64
// From and To are the times it held, unix nanoseconds.
From, To int64
// Reason is the invariant its bytes broke.
Reason string
}
RecordsDamage is a row that no longer reads: a sealed segment, dropped whole, or a head row, the other being zero.
func (RecordsDamage) Append ¶
func (g RecordsDamage) Append(dst []byte) []byte
func (*RecordsDamage) Decode ¶
func (g *RecordsDamage) Decode(body []byte) error
type RecordsDamages ¶
type RecordsDamages struct {
Damages []RecordsDamage
}
RecordsDamages answers records.damaged: the rows the server's records have met that no longer read, in the order it met them.
func (RecordsDamages) Append ¶
func (l RecordsDamages) Append(dst []byte) []byte
func (*RecordsDamages) Decode ¶
func (l *RecordsDamages) Decode(body []byte) error
type RecordsPage ¶
type RecordsPage struct {
// More says the limit or the budget ended the page before the range did.
More bool
// From and To are the range the next page reads: the query's own with
// one end moved past this page.
From, To int64
}
RecordsPage ends a read.
func (RecordsPage) Append ¶
func (p RecordsPage) Append(dst []byte) []byte
func (*RecordsPage) Decode ¶
func (p *RecordsPage) Decode(body []byte) error
type RecordsQuery ¶
type RecordsQuery struct {
// From and To are unix nanoseconds, zero for an open end.
From, To int64
// Streams and Names select records by them; none is every one.
Streams []string
Names []string
MinLevel *int64
TraceID []byte
Attrs []RecordField
Context []RecordField
Newest bool
Limit uint64
// Budget narrows the server's.
Budget RecordsBudget
// Search is text a record's body or name holds, its case ignored.
Search string
}
RecordsQuery is records.read's request: the records in [From, To) that meet every condition given.
func (RecordsQuery) Append ¶
func (q RecordsQuery) Append(dst []byte) []byte
func (*RecordsQuery) Decode ¶
func (q *RecordsQuery) Decode(body []byte) error
type RecordsStream ¶
type RecordsStream struct {
Stream string
}
RecordsStream is records.lines' request: the stream another program's output, uploaded after it, becomes records of.
func (RecordsStream) Append ¶
func (l RecordsStream) Append(dst []byte) []byte
func (*RecordsStream) Decode ¶
func (l *RecordsStream) Decode(body []byte) error
type Repeat ¶
Repeat is when a job runs again: a cron expression in a zone by its name, or every so many milliseconds.
type SQLColumns ¶
type SQLColumns struct {
Columns []string
}
SQLColumns begins sql.query's download: the columns' names, which every row that follows holds in their order.
func (SQLColumns) Append ¶
func (c SQLColumns) Append(dst []byte) []byte
func (*SQLColumns) Decode ¶
func (c *SQLColumns) Decode(body []byte) error
type SQLDatabase ¶
type SQLDatabase struct {
Name string
Migrations []SQLMigration
}
SQLDatabase is sql.open's request: a database by name, and the migrations its file must have applied, which an admin's first open applies.
func (SQLDatabase) Append ¶
func (d SQLDatabase) Append(dst []byte) []byte
func (*SQLDatabase) Decode ¶
func (d *SQLDatabase) Decode(body []byte) error
type SQLDone ¶
SQLDone answers sql.exec, and is a write's result in a batch: the rows it changed and the rowid of the last it inserted.
type SQLMigration ¶
SQLMigration is one .sql file of a database's migrations.
type SQLResult ¶
SQLResult is one statement's result: what a write changed, or, for a statement that returned rows, its columns and rows instead.
type SQLResults ¶
type SQLResults struct {
Results []SQLResult
}
SQLResults answers a batch, a result a statement in their order.
func (SQLResults) Append ¶
func (r SQLResults) Append(dst []byte) []byte
func (*SQLResults) Decode ¶
func (r *SQLResults) Decode(body []byte) error
type SQLRow ¶
type SQLRow struct {
Values []any
}
SQLRow is one row of a query's download: its values, a column each.
type SQLStatement ¶
type SQLStatement struct {
Handle uint64
SQL string
// Args are each nil, an integer, a float, str, bin or a bool.
Args []any
// Named are written without the :, @ or $ the statement spells them
// with, as sql.Named takes them.
Named map[string]any
// Write runs a query on the writer, for a write whose returning clause
// gives rows.
Write bool
// Rows asks a batch's statement for the rows it returns.
Rows bool
}
SQLStatement is one statement with its arguments: positional, named, or both.
func (SQLStatement) Append ¶
func (s SQLStatement) Append(dst []byte) []byte
func (*SQLStatement) Decode ¶
func (s *SQLStatement) Decode(body []byte) error
type SQLStatements ¶
type SQLStatements struct {
Handle uint64
Statements []SQLStatement
Read bool
// Jobs are enqueued after the statements, in the same transaction, on
// queues kept in this database: each opened with jobs.queue's in.
Jobs []JobsBatch
}
SQLStatements is sql.batch's request: statements one transaction runs, all or none, or with Read, reads from one snapshot. A statement's handle is the batch's.
func (SQLStatements) Append ¶
func (s SQLStatements) Append(dst []byte) []byte
func (*SQLStatements) Decode ¶
func (s *SQLStatements) Decode(body []byte) error
type UnknownFieldsError ¶
type UnknownFieldsError struct {
Keys []uint64
}
UnknownFieldsError names the fields a message carried that its reader does not know; every other field was read.
func (*UnknownFieldsError) Error ¶
func (e *UnknownFieldsError) Error() string
func (*UnknownFieldsError) List ¶
func (e *UnknownFieldsError) List() string
List is the fields' keys as an error's what names them: 9, or 9,40.
func (*UnknownFieldsError) Unwrap ¶
func (e *UnknownFieldsError) Unwrap() error
type Welcome ¶
type Welcome struct {
Protocol uint64
Server string // its version
Instance []byte // sixteen random bytes a start
Capability Capability
// MaxBody is the largest body either side sends.
MaxBody uint32
// InFlight is the streams a client may have open at once.
InFlight uint32
// ConnectionCredit is the bytes of REQUEST and DATA bodies a client may
// send before credit comes back, at least MaxBody.
ConnectionCredit uint32
// StreamCredit is the bytes of DATA a client may send on a stream before
// credit comes back.
StreamCredit uint32
Engines []string
Now int64 // the store's clock, unix milliseconds
// Proof answers a local HELLO's challenge, Prove of it with the secret
// SERVE names; nil when the HELLO carried none.
Proof []byte
}
Welcome is the server's answer to a Hello it takes.