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
- Variables
- func DecodePath(encoded string) ([]string, error)
- func EncodePath(path []string) (string, error)
- func MarshalJSON(value any) ([]byte, error)
- func RawUnicode(data []byte) error
- func ValidID(id, prefix string) bool
- func ValidPath(path []string) bool
- func ValidTraceparent(value string) bool
- func Validate(name string, value wire.ProfileFrame, limit int64) error
- func ValidateUnicodeJSON(data []byte) error
- type Frame
- type PublicError
Constants ¶
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 ¶
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 ¶
DecodePath accepts only the canonical form of EncodePath, without Unicode normalization or interpretation of dots, slashes or empty segments.
func EncodePath ¶
EncodePath concatenates UTF-8 byte-length-prefixed scalar-string segments. The empty path is "", while a single empty segment is "0:".
func MarshalJSON ¶
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 ¶
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 ¶
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 ¶
ValidPath says whether every segment is Unicode-scalar text: the access law's rule, independent of how the profile encodes a path.
func ValidTraceparent ¶
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 ¶
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.
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.