Help us shape the future of Go! Take the 2026 Go Developer Survey

protocol

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package protocol defines the JSON contract between Questlock and its clients.

Index

Constants

View Source
const (
	ExpectedAuthorityHeader = "X-Questlock-Expected-Authority"
	ExpectedScopeHeader     = "X-Questlock-Expected-Scope"
	ExpectedAgentHeader     = "X-Questlock-Expected-Agent"
)
View Source
const (
	MaxSyncItems        = 128
	MaxSyncBytes        = 8 << 20
	MinSyncBytes        = 4096
	MaxSyncCursorBytes  = 2048
	MaxSyncRequestBytes = 4096
)
View Source
const MaxContentBytes = 1 << 20

Variables

This section is empty.

Functions

func DecodeDataJSON added in v0.9.0

func DecodeDataJSON(data []byte, value any) error

DecodeDataJSON preserves case-sensitive application data (for example a json_equals expectation) while requiring exact struct field names. Callers impose their byte bound. This does not relax the sync wire format.

func DecodeSyncJSON added in v0.8.0

func DecodeSyncJSON(data []byte, value any) error

DecodeSyncJSON strictly decodes a bounded object; callers set the byte limit. Nested duplicate members, malformed UTF-8, unknown struct fields, trailing values and excessive nesting are rejected.

Types

type Artifact

type Artifact struct {
	Scope     string `json:"scope"`
	Key       string `json:"key"`
	Version   int64  `json:"version"`
	Content   string `json:"content"`
	UpdatedAt string `json:"updated_at"`
}

type AuditEvent

type AuditEvent struct {
	ID              int64  `json:"id"`
	AgentID         string `json:"agent_id"`
	Scope           string `json:"scope"`
	Key             string `json:"key"`
	OperationID     string `json:"operation_id"`
	Outcome         string `json:"outcome"`
	ExpectedVersion int64  `json:"expected_version"`
	CurrentVersion  int64  `json:"current_version"`
	CreatedAt       string `json:"created_at"`
}

type ErrorBody

type ErrorBody struct {
	Code           string `json:"code"`
	Message        string `json:"message"`
	CurrentVersion int64  `json:"current_version,omitempty"`
}

type Identity added in v0.8.0

type Identity struct {
	Authority string `json:"authority"`
	Scope     string `json:"scope"`
	AgentID   string `json:"agent_id"`
}

Identity is authenticated server evidence, not authority supplied by a writer. AgentID matters because successful operation IDs are namespaced by agent.

func (Identity) Validate added in v0.8.0

func (i Identity) Validate() error

type PublishRequest

type PublishRequest struct {
	Key             string `json:"key"`
	OperationID     string `json:"operation_id"`
	ExpectedVersion int64  `json:"expected_version"`
	Content         string `json:"content"`
}

type PublishResult

type PublishResult struct {
	Artifact Artifact `json:"artifact"`
	Replayed bool     `json:"replayed"`
}

type SyncEntry added in v0.8.0

type SyncEntry struct {
	Sequence int64    `json:"sequence"`
	Artifact Artifact `json:"artifact"`
}

SyncEntry contains raw immutable artifact content. Sequence is an accepted publication ID, never a client-writable version or scope-wide CAS version.

type SyncPage added in v0.8.0

type SyncPage struct {
	Authority string      `json:"authority"`
	Scope     string      `json:"scope"`
	Kind      string      `json:"kind"`
	Through   int64       `json:"through"`
	Entries   []SyncEntry `json:"entries"`
	Cursor    string      `json:"cursor"`
	HasMore   bool        `json:"has_more"`
}

func DecodeSyncPage added in v0.8.0

func DecodeSyncPage(data []byte) (SyncPage, error)

DecodeSyncPage requires every canonical response field, including false, zero, and intentionally empty content. Omission/null is never a default. Semantic scope, sequence, and requested-limit checks remain with the client.

type SyncRequest added in v0.8.0

type SyncRequest struct {
	Cursor   string `json:"cursor,omitempty"`
	Limit    int    `json:"limit,omitempty"`
	MaxBytes int    `json:"max_bytes,omitempty"`
}

SyncRequest requests read-only pages in the token's scope. Zero limits select defaults. Cursor is opaque; persist it without editing. No writes are accepted.

func DecodeSyncRequest added in v0.8.0

func DecodeSyncRequest(data []byte) (SyncRequest, error)

DecodeSyncRequest rejects unknown, duplicate, null and trailing fields.

func (SyncRequest) Bounds added in v0.8.0

func (r SyncRequest) Bounds() (SyncRequest, error)

Jump to

Keyboard shortcuts

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