Documentation
¶
Index ¶
- Constants
- func AppendByteVector(dst []byte, items ...[]byte) []byte
- func AppendByteVectorPayload(dst []byte, lengths []int, payload []byte) ([]byte, error)
- func AppendByteVectorWithEncodedLen(dst []byte, encodedLen int, items ...[]byte) []byte
- func AppendCommandHeader(dst []byte, h CommandHeader) []byte
- func AppendDeterministicEntry(dst []byte, cmd ValidatedCommand) ([]byte, error)
- func AppendDeterministicEntryWithLimits(dst []byte, cmd ValidatedCommand, limits Limits) ([]byte, error)
- func AppendHeader(dst []byte, h Header) ([]byte, error)
- func AppendSection(dst []byte, s Section) ([]byte, error)
- func AppendSectionHeader(dst []byte, id SectionID, flags uint64, sectionLen int) ([]byte, error)
- func ByteVectorEncodedLen(items [][]byte) int
- func ByteVectorPayloadEncodedLen(lengths []int, payloadLen int) (int, error)
- func DecodeByteVectorItems(src []byte, limits Limits) ([][]byte, error)
- func DecodeByteVectorItemsInto(dst [][]byte, src []byte, limits Limits) ([][]byte, error)
- func DeterministicCommandFlags(flags uint64) uint64
- func DeterministicEntryDigest(entry []byte) [32]byte
- func SectionEncodedLen(s Section) int
- func SectionHeaderEncodedLen(id SectionID, flags uint64, sectionLen int) int
- func UnsupportedDeterministicCommandFlags(flags uint64) uint64
- func ValidateHeaderVersion(h Header, selected Version) error
- type AckPolicy
- type ByteVector
- type ByteVectorScratch
- type CommandHeader
- type CommandID
- type CommandKind
- type CommandSchema
- type CommandScratch
- type ConsistencyPolicy
- type DeterministicEntry
- func DecodeDeterministicEntry(src []byte, limits Limits) (DeterministicEntry, error)
- func DecodeDeterministicEntryInto(src []byte, limits Limits, scratch *DeterministicEntryScratch) (DeterministicEntry, error)
- func DecodeDeterministicEntryIntoWithRegistry(src []byte, limits Limits, scratch *DeterministicEntryScratch, ...) (DeterministicEntry, error)
- func DecodeDeterministicEntryWithRegistry(src []byte, limits Limits, registry *Registry) (DeterministicEntry, error)
- type DeterministicEntryScratch
- type DocumentFormat
- type ErrorCode
- type FrameType
- type Header
- type Limits
- type ProtocolError
- type Registry
- func (r *Registry) LookupCommand(id CommandID, version uint64) (*CommandSchema, bool)
- func (r *Registry) Schemas() []CommandSchema
- func (r *Registry) ValidateRequestSections(sections []Section) (ValidatedCommand, error)
- func (r *Registry) ValidateRequestSectionsInto(sections []Section, scratch *CommandScratch) (ValidatedCommand, error)
- type Section
- type SectionID
- type SectionRule
- type ValidatedCommand
- type Version
Constants ¶
const ( // CommandFlagOmitResultIDs asks mutation responses to omit result ID vectors // when the command can otherwise report success through response_meta. CommandFlagOmitResultIDs uint64 = 1 << iota // CommandFlagOmitResponseMeta asks success responses to omit response_meta // when the client only needs success/error signaling. CommandFlagOmitResponseMeta )
const ( DeterministicEntryMagic = "TDC1" DeterministicEntryVersion = uint64(1) )
const ( Magic = "TDB1" ProtocolMajorV1 = uint16(1) ProtocolMinorV0 = uint16(0) FrameHeaderLenV1 = uint16(40) MaxFrameHeaderLen = FrameHeaderLenV1 )
const ( CommandSpecificSectionStart SectionID = 100 SectionFlagCritical uint64 = 1 )
const MaxErrorCode = errCodeSentinel - 1
MaxErrorCode is the highest native-wire error code currently assigned by this protocol version.
Variables ¶
This section is empty.
Functions ¶
func AppendByteVector ¶
func AppendByteVectorPayload ¶
func AppendCommandHeader ¶
func AppendCommandHeader(dst []byte, h CommandHeader) []byte
func AppendDeterministicEntry ¶
func AppendDeterministicEntry(dst []byte, cmd ValidatedCommand) ([]byte, error)
AppendDeterministicEntry appends a canonical replicated command entry using default limits. On error it returns dst truncated to its original length.
func AppendDeterministicEntryWithLimits ¶
func AppendDeterministicEntryWithLimits(dst []byte, cmd ValidatedCommand, limits Limits) ([]byte, error)
AppendDeterministicEntryWithLimits appends a canonical replicated command entry while validating deterministic payloads against caller-provided limits. On error it returns dst truncated to its original length.
func AppendSectionHeader ¶
func ByteVectorEncodedLen ¶
func DecodeByteVectorItems ¶
DecodeByteVectorItems decodes a byte-vector into item slices that borrow from src. It avoids offset/length table allocation for callers that only need a transient [][]byte view.
func DecodeByteVectorItemsInto ¶
DecodeByteVectorItemsInto decodes a byte-vector into dst[:count] item slices that borrow from src. It avoids offset/length table allocation for callers that only need a transient [][]byte view.
func DeterministicEntryDigest ¶
DeterministicEntryDigest returns the SHA-256 digest of canonical deterministic entry bytes.
func SectionEncodedLen ¶
func SectionHeaderEncodedLen ¶
func ValidateHeaderVersion ¶
Types ¶
type ByteVector ¶
type ByteVector struct {
// contains filtered or unexported fields
}
func DecodeByteVector ¶
func DecodeByteVector(src []byte, limits Limits) (ByteVector, error)
func DecodeByteVectorInto ¶
func DecodeByteVectorInto(src []byte, limits Limits, scratch *ByteVectorScratch) (ByteVector, error)
DecodeByteVectorInto decodes a byte-vector using reusable buffers when scratch is non-nil. The returned vector borrows from src and scratch.
func (ByteVector) Len ¶
func (v ByteVector) Len() int
type ByteVectorScratch ¶
type ByteVectorScratch struct {
// contains filtered or unexported fields
}
ByteVectorScratch carries reusable decode buffers for DecodeByteVectorInto.
type CommandHeader ¶
func DecodeCommandHeader ¶
func DecodeCommandHeader(src []byte) (CommandHeader, error)
type CommandID ¶
type CommandID uint64
const ( CommandCreateCollection CommandID = 10 CommandListCollections CommandID = 11 CommandCreateIndex CommandID = 12 CommandListIndexes CommandID = 13 CommandDropIndex CommandID = 14 CommandOpenCollection CommandID = 15 CommandCloseCollection CommandID = 16 CommandDropCollection CommandID = 17 CommandInsertBatch CommandID = 30 CommandReplaceBatch CommandID = 31 CommandDeleteBatch CommandID = 32 CommandFlushCollection CommandID = 33 CommandFlushAll CommandID = 34 CommandCheckpoint CommandID = 35 CommandUpdateBSONSet CommandID = 36 CommandGetMany CommandID = 50 CommandIndexLookup CommandID = 51 CommandIndexRange CommandID = 52 CommandOpenScan CommandID = 53 CommandCursorNext CommandID = 54 CommandCursorClose CommandID = 55 CommandExplain CommandID = 56 CommandStats CommandID = 57 )
type CommandKind ¶
type CommandKind uint8
const ( CommandKindControl CommandKind = iota + 1 CommandKindMutation CommandKindRead )
type CommandSchema ¶
type CommandScratch ¶
type CommandScratch struct {
Known []Section
Ignored []Section
// contains filtered or unexported fields
}
CommandScratch carries reusable buffers for command-schema validation.
type ConsistencyPolicy ¶
type ConsistencyPolicy uint64
const ( ConsistencyLocalStale ConsistencyPolicy = 1 ConsistencyLeaderRead ConsistencyPolicy = 2 ConsistencyLinearizable ConsistencyPolicy = 3 ConsistencyLeaseRead ConsistencyPolicy = 4 )
type DeterministicEntry ¶
type DeterministicEntry struct {
Version uint64
CommandID CommandID
CommandVersion uint64
CommandFlags uint64
Sections []Section
}
func DecodeDeterministicEntry ¶
func DecodeDeterministicEntry(src []byte, limits Limits) (DeterministicEntry, error)
func DecodeDeterministicEntryInto ¶
func DecodeDeterministicEntryInto(src []byte, limits Limits, scratch *DeterministicEntryScratch) (DeterministicEntry, error)
DecodeDeterministicEntryInto decodes a deterministic command-entry envelope.
The returned section payloads borrow from src and the section slice may borrow from scratch. Callers that need to retain the entry after reusing src or scratch must copy it.
func DecodeDeterministicEntryIntoWithRegistry ¶
func DecodeDeterministicEntryIntoWithRegistry(src []byte, limits Limits, scratch *DeterministicEntryScratch, registry *Registry) (DeterministicEntry, error)
DecodeDeterministicEntryIntoWithRegistry is DecodeDeterministicEntryInto with caller-supplied command registry validation. A nil registry uses the v1 native-wire registry.
func DecodeDeterministicEntryWithRegistry ¶
func DecodeDeterministicEntryWithRegistry(src []byte, limits Limits, registry *Registry) (DeterministicEntry, error)
DecodeDeterministicEntryWithRegistry decodes a deterministic command-entry envelope using registry for command validation. A nil registry uses the v1 native-wire registry.
type DeterministicEntryScratch ¶
type DeterministicEntryScratch struct {
Sections []Section
}
DeterministicEntryScratch carries reusable buffers for DecodeDeterministicEntryInto.
type DocumentFormat ¶
type DocumentFormat uint64
const ( DocumentFormatDefault DocumentFormat = 0 DocumentFormatJSON DocumentFormat = 1 DocumentFormatBSON DocumentFormat = 2 DocumentFormatTemplateV1 DocumentFormat = 3 )
type ErrorCode ¶
type ErrorCode uint64
const ( ErrMalformedFrame ErrorCode = iota + 1 ErrUnsupportedVersion ErrUnsupportedFeature ErrAuthRequired ErrPermissionDenied ErrInvalidCommand ErrCollectionNotFound ErrIndexNotFound ErrDuplicateDocumentID ErrDocumentExists ErrUniqueIndexConflict ErrCatalogVersionMismatch ErrReadOnly ErrTimeout ErrCanceled ErrResourceExhausted ErrInternal ErrCursorNotFound ErrCatalogChanged ErrIdempotencyConflict ErrCommitAmbiguous )
func ErrorCodeOf ¶
type Header ¶
type Limits ¶
type Limits struct {
MaxFrameSize uint64
MaxHeaderLen uint16
MaxSections int
MaxSectionLen uint64
MaxByteVectorItems int
MaxByteVectorBytes uint64
MaxDeterministicOpaquePayloadBytes uint64
MaxDeterministicNameBytes uint64
}
func DefaultLimits ¶
func DefaultLimits() Limits
type ProtocolError ¶
func (*ProtocolError) Error ¶
func (e *ProtocolError) Error() string
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func MustV1Registry ¶
func MustV1Registry() *Registry
func NewRegistry ¶
func NewRegistry(commands ...CommandSchema) (*Registry, error)
func (*Registry) LookupCommand ¶
func (r *Registry) LookupCommand(id CommandID, version uint64) (*CommandSchema, bool)
func (*Registry) Schemas ¶
func (r *Registry) Schemas() []CommandSchema
func (*Registry) ValidateRequestSections ¶
func (r *Registry) ValidateRequestSections(sections []Section) (ValidatedCommand, error)
func (*Registry) ValidateRequestSectionsInto ¶
func (r *Registry) ValidateRequestSectionsInto(sections []Section, scratch *CommandScratch) (ValidatedCommand, error)
ValidateRequestSectionsInto validates sections using scratch when provided.
The returned command borrows section slices from sections and scratch. Callers may reuse scratch after they are done with the validated command view.
type Section ¶
func DecodeSectionsInto ¶
DecodeSectionsInto decodes section envelopes, reusing dst[:0] when capacity allows and allocating a larger backing array when needed.
The returned sections borrow from src. Callers may reuse dst after they are done with the decoded section view. Callers that want reuse across calls must retain the returned slice; a grow will not update the caller's dst variable.
type SectionID ¶
type SectionID uint64
const ( SectionCommandHeader SectionID = 1 SectionError SectionID = 2 SectionCapabilitySet SectionID = 3 SectionDeadline SectionID = 4 SectionTraceContext SectionID = 5 SectionAckPolicy SectionID = 6 SectionConsistencyPolicy SectionID = 7 SectionIdempotencyKey SectionID = 8 SectionChecksum SectionID = 9 SectionCompression SectionID = 10 SectionResponseMeta SectionID = 11 SectionCursorMeta SectionID = 12 )
const ( SectionCollectionRef SectionID = 100 SectionDocumentFormat SectionID = 101 SectionDocumentIDs SectionID = 102 SectionDocuments SectionID = 103 SectionTemplateRecords SectionID = 104 SectionExpectedCatalogVersion SectionID = 105 SectionReplacementMode SectionID = 106 SectionCollectionMeta SectionID = 107 SectionIndexDefinition SectionID = 108 SectionIndexName SectionID = 109 SectionCollectionHandle SectionID = 110 SectionIndexValue SectionID = 111 SectionIndexLowerBound SectionID = 112 SectionIndexUpperBound SectionID = 113 SectionCursorRef SectionID = 114 SectionCursorLimits SectionID = 115 SectionPresenceBitmap SectionID = 116 SectionTruncated SectionID = 117 SectionUpdateFieldNames SectionID = 121 SectionUpdateFieldValues SectionID = 122 )
type SectionRule ¶
type ValidatedCommand ¶
type ValidatedCommand struct {
Header CommandHeader
Schema *CommandSchema
Known []Section
Ignored []Section
}