profile

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package profile holds the bitwire/1 envelope: its JSON frame, the canonical encoding of an addressed path into the frame's method or event name, and the validation a peer applies before it admits a frame. It is shared by the in-process pair, the protocol engine and the helpers, and is not public API.

Index

Constants

View Source
const MetaReserved = "nightseam."

MetaReserved prefixes the meta keys the profile keeps for itself. Revision 1 defines none, so every key under it is refused, on the way out as on the way in. The prefix keeps its historical spelling until a later revision.

Variables

View Source
var ErrPath = errors.New("invalid wire path")

ErrPath refuses a path segment that is not Unicode-scalar text, or an encoded name that is not the canonical form of one.

Functions

func DecodePath

func DecodePath(encoded string) ([]string, error)

DecodePath accepts only the canonical form of EncodePath, without Unicode normalization or interpretation of dots, slashes or empty segments.

func EncodePath

func EncodePath(path []string) (string, error)

EncodePath concatenates UTF-8 byte-length-prefixed scalar-string segments. The empty path is "", while a single empty segment is "0:".

func MarshalJSON

func MarshalJSON(value any) ([]byte, error)

MarshalJSON encodes a wire value without replacing malformed Unicode, so invalid UTF-8 in Go strings and unpaired surrogate escapes in raw encodings are refused rather than silently repaired.

func RawUnicode

func RawUnicode(data []byte) error

RawUnicode checks original JSON text, including overwritten members. JSON syntax remains the decoder's job; this scan only rules out lossy string decoding.

func ValidID

func ValidID(id, prefix string) bool

ValidID holds a request identifier to the profile's form: the role's prefix followed by a decimal serial without leading zeros, at most 20 digits.

func ValidPath

func ValidPath(path []string) bool

ValidPath says whether every segment is Unicode-scalar text: the access law's rule, independent of how the profile encodes a path.

func ValidTraceparent

func ValidTraceparent(value string) bool

ValidTraceparent holds a traceparent to the one form W3C Trace Context gives it: version, trace id, parent id and flags, lower-case hexadecimal, dashed.

func Validate

func Validate(name string, value wire.ProfileFrame, limit int64) error

Validate holds a structured frame to the envelope it would travel as, with name as its method or event, and to a carrier's frame limit. A logical return address identifies an origin independently of the carrier role, so either identifier prefix is valid before a peer remaps it.

func ValidateUnicodeJSON

func ValidateUnicodeJSON(data []byte) error

ValidateUnicodeJSON checks original JSON text for malformed Unicode, including strings a decoder would discard as duplicate members. It does not replace JSON syntax or envelope validation performed by its caller.

Types

type Frame

type Frame struct {
	Version int                `json:"version"`
	Kind    string             `json:"kind"`
	ID      string             `json:"id,omitempty"`
	Method  string             `json:"method,omitempty"`
	Params  json.RawMessage    `json:"params,omitempty"`
	Result  json.RawMessage    `json:"result,omitempty"`
	Error   *wire.ProfileError `json:"error,omitempty"`
	Event   string             `json:"event,omitempty"`
	Data    json.RawMessage    `json:"data,omitempty"`
	// W3C Trace Context, which every kind may carry and none requires.
	Traceparent string `json:"traceparent,omitempty"`
	Tracestate  string `json:"tracestate,omitempty"`
	// What is about a call rather than the call, which a request and an event
	// may carry. The profile carries it verbatim and reads nothing into it.
	Meta map[string]string `json:"meta,omitempty"`
}

Frame is one bitwire/1 envelope as it travels. The path of an addressed request or event is its canonical encoding in Method or Event.

func Decode

func Decode(data []byte) (Frame, error)

Decode admits one envelope exactly as the profile allows it.

type PublicError

type PublicError struct {
	Code    string          `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}

PublicError is a decoded envelope's public error.

Jump to

Keyboard shortcuts

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