wire

package
v0.1.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

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

View Source
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.

View Source
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.

View Source
const (
	InstanceSize  = 16
	SecretSize    = 32
	ChallengeSize = 16
)

the bytes of a start's instance and secret, and of a HELLO's challenge

View Source
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.

View Source
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

View Source
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.

View Source
var ErrProtocol = errors.New("protocol error")

ErrProtocol is a frame or a handshake that breaks the protocol; the connection ends with it.

View Source
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 AppendArray(dst []byte, n int) []byte

func AppendBin

func AppendBin(dst []byte, b []byte) []byte

func AppendBool

func AppendBool(dst []byte, v bool) []byte

func AppendCredit

func AppendCredit(dst []byte, stream, n uint32) []byte

AppendCredit appends a CREDIT granting n bytes on stream, 0 for the connection.

func AppendFloat

func AppendFloat(dst []byte, v float64) []byte

AppendFloat writes a float 64 with its bits: -0 → cb 80 00 00 00 00 00 00 00.

func AppendFloats

func AppendFloats(dst []byte, column []float64) []byte

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 AppendFrame

func AppendFrame(dst []byte, h Header, body []byte) []byte

func AppendHeader

func AppendHeader(dst []byte, h Header) []byte

AppendHeader appends h, whose Length SetLength may fix once the body is appended after it.

func AppendInt

func AppendInt(dst []byte, v int64) []byte

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

func AppendInts(dst []byte, column []int64) []byte

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 AppendKey

func AppendKey(dst []byte, text string) []byte

AppendKey writes a key's text as a str, or as a bin when it is not UTF-8.

func AppendMap

func AppendMap(dst []byte, n int) []byte

func AppendNil

func AppendNil(dst []byte) []byte

func AppendSQLValue

func AppendSQLValue(dst []byte, value any) []byte

AppendSQLValue writes a value as SQLite returned it, or as an argument travels: TEXT that is not UTF-8 as bin.

func AppendStr

func AppendStr(dst []byte, s string) []byte

AppendStr writes text, which the caller keeps valid UTF-8.

func AppendText

func AppendText(dst []byte, text string) []byte

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

func AppendUint(dst []byte, v uint64) []byte

AppendUint writes v in the unsigned family's shortest form:

7 → 07    300 → cd 01 2c    70000 → ce 00 01 11 70

func Granted

func Granted(body []byte) uint32

func Prove

func Prove(secret, challenge []byte) []byte

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

func SkipUnknown(err error) error

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.

func (BlobsCall) Append

func (c BlobsCall) Append(dst []byte) []byte

func (*BlobsCall) Decode

func (c *BlobsCall) Decode(body []byte) error

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

type BlobsPage struct {
	More  bool
	After string
}

BlobsPage ends a scan: More says the limit ended it before the folder did, and After is the key the next page begins after.

func (BlobsPage) Append

func (p BlobsPage) Append(dst []byte) []byte

func (*BlobsPage) Decode

func (p *BlobsPage) Decode(body []byte) error

type BlobsTotal

type BlobsTotal struct {
	Objects int64
	Bytes   int64
}

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

type Clock struct {
	At      int64 // unix milliseconds
	Advance int64 // milliseconds
}

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.

func (Clock) Append

func (c Clock) Append(dst []byte) []byte

func (*Clock) Decode

func (c *Clock) Decode(body []byte) error

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
	CodeUnavailable    Code = "unavailable"     // the server is closing: send it on another connection
	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 NewDecoder(body []byte) Decoder

func (*Decoder) Bin

func (d *Decoder) Bin() []byte

Bin reads a bin, aliasing the body; an empty one is not nil.

func (*Decoder) Bool

func (d *Decoder) Bool() bool

func (*Decoder) Duration

func (d *Decoder) Duration() int64

Duration reads milliseconds, which are never negative.

func (*Decoder) End

func (d *Decoder) End() error

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) Err

func (d *Decoder) Err() error

func (*Decoder) Fail

func (d *Decoder) Fail(format string, args ...any)

Fail refuses the message for a reason of its own, as a field out of range.

func (*Decoder) Fields

func (d *Decoder) Fields() iter.Seq[uint64]

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

func (d *Decoder) Float() float64

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) Floats

func (d *Decoder) Floats() []float64

Floats reads a column of floats AppendFloats wrote, bit for bit.

func (*Decoder) Int

func (d *Decoder) Int() int64

Int reads an integer in any encoding of its value.

func (*Decoder) Ints

func (d *Decoder) Ints() []int64

Ints reads a column of integers AppendInts wrote.

func (*Decoder) Items

func (d *Decoder) Items() iter.Seq[int]

Items reads an array, yielding each index with its element next.

func (*Decoder) KVValue

func (d *Decoder) KVValue() KVValue

KVValue reads nil, an integer or a bin, the bin aliasing the body.

func (*Decoder) KeyText

func (d *Decoder) KeyText() string

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

func (d *Decoder) Names() iter.Seq[string]

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

func (d *Decoder) Nil() bool

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

func (d *Decoder) SQLValue() any

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.

func (*Decoder) Str

func (d *Decoder) Str() string

func (*Decoder) StrBytes

func (d *Decoder) StrBytes() []byte

StrBytes reads a str, which must be valid UTF-8, aliasing the body.

func (*Decoder) Strs

func (d *Decoder) Strs() []string

func (*Decoder) Text

func (d *Decoder) Text() string

Text reads a str, or a bin whose bytes are text that is not UTF-8.

func (*Decoder) Type

func (d *Decoder) Type() Type

Type is the next value's type, without reading it.

func (*Decoder) Uint

func (d *Decoder) Uint() uint64

Uint reads an unsigned integer in any encoding of its value.

func (*Decoder) Uint16

func (d *Decoder) Uint16() uint16

Uint16 reads an unsigned integer that fits 16 bits, a method's.

func (*Decoder) Uint32

func (d *Decoder) Uint32() uint32

type Empty

type Empty struct{}

Empty is a message without fields: an answer that says only that its call was done.

func (Empty) Append

func (Empty) Append(dst []byte) []byte

func (*Empty) Decode

func (*Empty) Decode(body []byte) error

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.

func (*Error) Append

func (e *Error) Append(dst []byte) []byte

Append writes the error with What's names in their byte order. A name's value that is not UTF-8, as a key of bytes may be, travels as bin.

func (*Error) Decode

func (e *Error) Decode(body []byte) error

func (*Error) Error

func (e *Error) Error() string

type Flags

type Flags uint8

Flags say where a frame stands in its stream.

const (
	// FlagEnd marks the sender's last frame on its stream.
	FlagEnd Flags = 1
	// FlagError, only beside FlagEnd, says the body is an Error.
	FlagError Flags = 2
)

type GoAway

type GoAway struct {
	Code    Code
	Message string
}

GoAway ends a connection: the server's, or a HELLO or frame it cannot take.

func (GoAway) Append

func (g GoAway) Append(dst []byte) []byte

func (*GoAway) Decode

func (g *GoAway) Decode(body []byte) error

type Handle

type Handle struct {
	Handle uint64
}

Handle answers an open with the number the calls on its handle carry.

func (Handle) Append

func (h Handle) Append(dst []byte) []byte

func (*Handle) Decode

func (h *Handle) Decode(body []byte) error
type Header struct {
	Length uint32 // the body's
	Kind   Kind
	Flags  Flags
	Method Method
	Stream uint32
}

func ParseHeader

func ParseHeader(b []byte) Header

ParseHeader reads a header from its twelve bytes without checking it.

func (Header) Check

func (h Header) Check() error

Check refuses a header that breaks the protocol:

an unknown kind
a flag its kind does not define
ERROR without END
a method outside a REQUEST, or none in one
a stream where the kind names none, or none where it names one
a body of a length the kind cannot have

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.

func (Hello) Append

func (h Hello) Append(dst []byte) []byte

func (*Hello) Decode

func (h *Hello) Decode(body []byte) error

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 JobsBatch

type JobsBatch struct {
	Handle uint64
	Jobs   []JobsJob
}

JobsBatch is jobs.enqueue's request: jobs one transaction adds, all or none.

func (JobsBatch) Append

func (e JobsBatch) Append(dst []byte) []byte

func (*JobsBatch) Decode

func (e *JobsBatch) Decode(body []byte) error

type JobsChange

type JobsChange struct {
	Handle uint64
	JobsJob
}

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.

func (JobsEntry) Append

func (e JobsEntry) Append(dst []byte) []byte

func (*JobsEntry) Decode

func (e *JobsEntry) Decode(body []byte) error

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.

func (JobsHeld) Append

func (h JobsHeld) Append(dst []byte) []byte

func (*JobsHeld) Decode

func (h *JobsHeld) Decode(body []byte) error

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

type JobsKept struct {
	Found  bool
	Answer string
}

JobsKept is jobs.step's answer: the answer a step kept, found false for a step its run has not kept.

func (JobsKept) Append

func (k JobsKept) Append(dst []byte) []byte

func (*JobsKept) Decode

func (k *JobsKept) Decode(body []byte) error

type JobsKey

type JobsKey struct {
	Handle uint64
	Key    string
}

JobsKey is the request of jobs.cancel and jobs.get: a job by its key.

func (JobsKey) Append

func (k JobsKey) Append(dst []byte) []byte

func (*JobsKey) Decode

func (k *JobsKey) Decode(body []byte) error

type JobsLease

type JobsLease struct {
	Handle uint64
	Lease  int64
}

JobsLease is jobs.claim's request: the next due job, leased for Lease milliseconds, the queue's when zero.

func (JobsLease) Append

func (c JobsLease) Append(dst []byte) []byte

func (*JobsLease) Decode

func (c *JobsLease) Decode(body []byte) error

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

type JobsPage struct {
	More  bool
	After string
}

JobsPage ends a scan: More says the page ended before the jobs did, and After is where the next begins.

func (JobsPage) Append

func (p JobsPage) Append(dst []byte) []byte

func (*JobsPage) Decode

func (p *JobsPage) Decode(body []byte) error

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.

func (JobsQuery) Append

func (s JobsQuery) Append(dst []byte) []byte

func (*JobsQuery) Decode

func (s *JobsQuery) Decode(body []byte) error

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.

func (JobsQueue) Append

func (q JobsQueue) Append(dst []byte) []byte

func (*JobsQueue) Decode

func (q *JobsQueue) Decode(body []byte) error

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.

func (KVBucket) Append

func (b KVBucket) Append(dst []byte) []byte

func (*KVBucket) Decode

func (b *KVBucket) Decode(body []byte) error

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.

func (KVCall) Append

func (c KVCall) Append(dst []byte) []byte

func (*KVCall) Decode

func (c *KVCall) Decode(body []byte) error

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.

func (KVCalls) Append

func (b KVCalls) Append(dst []byte) []byte

func (*KVCalls) Decode

func (b *KVCalls) Decode(body []byte) error

type KVConfigChange

type KVConfigChange struct {
	Handle uint64
	Set    []string // path, JSON, path, JSON…
	Reset  []string
}

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.

func (KVEntry) Append

func (e KVEntry) Append(dst []byte) []byte

func (*KVEntry) Decode

func (e *KVEntry) Decode(body []byte) error

type KVKept

type KVKept struct {
	Changes uint64
	Fields  []string
}

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.

func (KVKept) Append

func (k KVKept) Append(dst []byte) []byte

func (*KVKept) Decode

func (k *KVKept) Decode(body []byte) error

type KVKind

type KVKind uint8

KVKind is which of the three a KVValue holds.

const (
	KVNothing KVKind = iota
	KVInt
	KVBytes
)

type KVOperation

type KVOperation struct {
	Method Method
	KVCall
}

type KVPage

type KVPage struct {
	More  bool
	After string
}

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.

func (KVPage) Append

func (p KVPage) Append(dst []byte) []byte

func (*KVPage) Decode

func (p *KVPage) Decode(body []byte) error

type KVResults

type KVResults struct {
	Entries []KVEntry
}

KVResults answers a batch or a view: an entry a call, in their order.

func (KVResults) Append

func (r KVResults) Append(dst []byte) []byte

func (*KVResults) Decode

func (r *KVResults) Decode(body []byte) error

type KVValue

type KVValue struct {
	Kind  KVKind
	Int   int64
	Bytes []byte
}

KVValue is a value as its row keeps it: nothing, an integer or bytes.

func (KVValue) Append

func (v KVValue) Append(dst []byte) []byte

Append writes nil, an integer or a bin.

type KVWindow

type KVWindow struct {
	Name  string
	Limit uint64
	Per   int64
}

KVWindow is one of a quota's windows: a key may use up to Limit every Per milliseconds, from its first use.

type KVWindowUsage

type KVWindowUsage struct {
	Name    string
	Used    uint64
	Limit   uint64
	Left    uint64
	ResetAt int64
}

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 Kind

type Kind uint8

Kind is what a frame is.

const (
	KindHello    Kind = 1
	KindWelcome  Kind = 2
	KindRequest  Kind = 3
	KindResponse Kind = 4
	KindData     Kind = 5
	KindCancel   Kind = 6
	KindCredit   Kind = 7
	KindPing     Kind = 8
	KindPong     Kind = 9
	KindGoAway   Kind = 10
)

func (Kind) String

func (k Kind) String() string

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 BeginMap

func BeginMap(dst []byte) Map

func (*Map) Bin

func (m *Map) Bin(key uint64, b []byte)

func (*Map) Bool

func (m *Map) Bool(key uint64, v bool)

func (*Map) Buf

func (m *Map) Buf() []byte

Buf is the message so far, for a value Key has made room for; the caller hands back what it appended with SetBuf.

func (*Map) End

func (m *Map) End() []byte

End sets the count and returns the message.

func (*Map) Float

func (m *Map) Float(key uint64, v float64)

func (*Map) Int

func (m *Map) Int(key uint64, v int64)

func (*Map) Key

func (m *Map) Key(key uint64)

Key writes a key and counts its field; its value is appended to Buf next.

func (*Map) SetBuf

func (m *Map) SetBuf(buf []byte)

func (*Map) Str

func (m *Map) Str(key uint64, s string)

func (*Map) Uint

func (m *Map) Uint(key, v uint64)

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

type MetricsCondition struct {
	Label  string
	Kind   string
	Values []string
}

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

type MetricsDropped struct {
	Found            bool
	UnreadableGroups uint64
}

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

type MetricsLabels struct {
	Labels map[string]string
}

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.

func (Published) Proves

func (p Published) Proves(challenge, proof []byte) bool

Proves says whether a WELCOME's proof answers the challenge with the secret SERVE names, in constant time. A SERVE without a whole secret proves nothing.

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 NewReader

func NewReader(r io.Reader, maxBody uint32) *Reader

func (*Reader) Body

func (r *Reader) Body(room []byte) ([]byte, error)

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

func (r *Reader) Header() (Header, error)

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

func (r *Reader) SetMaxBody(n uint32)

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.

func (Record) Append

func (r Record) Append(dst []byte) []byte

func (*Record) Decode

func (r *Record) Decode(body []byte) error

type RecordField

type RecordField struct {
	Key   string
	Value string
}

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

type RecordsCursor struct {
	Segment int64
	Row     int64
	Limit   uint64
	Expired uint64
}

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

type Repeat struct {
	Cron  string
	Zone  string
	Every int64
}

Repeat is when a job runs again: a cron expression in a zone by its name, or every so many milliseconds.

func (Repeat) Append

func (r Repeat) Append(dst []byte) []byte

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

type SQLDone struct {
	Changes int64
	LastID  int64
}

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.

func (SQLDone) Append

func (r SQLDone) Append(dst []byte) []byte

func (*SQLDone) Decode

func (r *SQLDone) Decode(body []byte) error

type SQLMigration

type SQLMigration struct {
	Name string
	Text string
}

SQLMigration is one .sql file of a database's migrations.

type SQLResult

type SQLResult struct {
	SQLDone
	Columns []string
	Rows    [][]any
}

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.

func (SQLRow) Append

func (r SQLRow) Append(dst []byte) []byte

func (*SQLRow) Decode

func (r *SQLRow) Decode(body []byte) error

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 Type

type Type uint8

Type is the kind of the next value a Decoder holds.

const (
	TypeInvalid Type = iota
	TypeNil
	TypeBool
	TypeInt
	TypeFloat
	TypeStr
	TypeBin
	TypeArray
	TypeMap
)

func (Type) String

func (t Type) String() string

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.

func (Welcome) Append

func (w Welcome) Append(dst []byte) []byte

func (*Welcome) Decode

func (w *Welcome) Decode(body []byte) error

Jump to

Keyboard shortcuts

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