chunkcodec

package
v2.0.0-rc.10 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CompressedEnvelopeMediaType identifies the versioned compressed chunk transport.
	// It reduces false-positive inspection of sync payloads; it does not provide secrecy.
	CompressedEnvelopeMediaType = "application/vnd.engram.sync+gzip"

	// DefaultMaxDecodedBytes bounds decompression when a peer does not provide a
	// negotiated payload limit. It matches the default cloud push body limit.
	DefaultMaxDecodedBytes int64 = 8 * 1024 * 1024
)

Variables

View Source
var (
	ErrPayloadTooLarge            = errors.New("compressed payload exceeds decoded size limit")
	ErrUnsupportedEnvelopeVersion = errors.New("unsupported compressed envelope version")
)

Functions

func AcceptsCompressedEnvelope

func AcceptsCompressedEnvelope(accept string) bool

AcceptsCompressedEnvelope reports whether an Accept header advertises the supported envelope. Requests without that explicit advertisement receive legacy JSON.

func CanonicalizeForProject

func CanonicalizeForProject(payload []byte, project string) ([]byte, error)

func ChunkID

func ChunkID(payload []byte) string

func CompressedEnvelopeContentType

func CompressedEnvelopeContentType() string

CompressedEnvelopeContentType returns the exact media type for the supported envelope.

func DecodeCompressedEnvelope

func DecodeCompressedEnvelope(payload []byte, maxBytes int64) ([]byte, error)

DecodeCompressedEnvelope decodes a gzip envelope and refuses decoded payloads that exceed maxBytes, preventing compressed inputs from bypassing request body limits.

func DecodeSyncMutationPayload

func DecodeSyncMutationPayload(payload string, dest any) error

func EncodeCompressedEnvelope

func EncodeCompressedEnvelope(payload []byte) ([]byte, error)

EncodeCompressedEnvelope gzip-compresses a canonical JSON payload for transport.

func IsCompressedEnvelopeContentType

func IsCompressedEnvelopeContentType(contentType string) (bool, error)

IsCompressedEnvelopeContentType reports whether contentType is the supported envelope. A recognized envelope media type with another version is rejected rather than decoded as legacy JSON.

func ValidateRelationPayload

func ValidateRelationPayload(payload json.RawMessage) (string, bool)

ValidateRelationPayload reports the first required relation payload field that is absent, not a string, or empty after trimming whitespace.

Types

This section is empty.

Jump to

Keyboard shortcuts

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