Documentation
¶
Index ¶
- Variables
- func Decode(packet []byte, options Options) (_ any, _ []byte, ret error)
- func Encode(x any, b *lib.Buffer, options Options) (ret error)
- func GetAtomCache() map[uint16]gen.Atom
- func GetErrCache() map[uint16]error
- func GetRegCache() map[uint16]string
- func LookupType(name string) (reflect.Type, bool)
- func MakeEncodeRegTypeCache(names []string) *sync.Map
- func RegisterAtom(a gen.Atom) error
- func RegisterError(e error) error
- func RegisterTypeOf(v any) error
- func RegisterTypesOf(types []any) error
- func RegisteredAtoms() []gen.RegisteredAtomInfo
- func RegisteredErrors() []gen.RegisteredErrorInfo
- func RegisteredTypes() []gen.RegisteredTypeInfo
- type Marshaler
- type Options
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
var ( ErrBinaryTooLong = fmt.Errorf("binary too long - max allowed length is 2^32-1 bytes (4GB)") ErrStructTooLong = fmt.Errorf("struct too long - max allowed encoded length is 2^32-1 bytes (4GB) with schema evolution enabled") ErrStringTooLong = fmt.Errorf("string too long - max allowed length is 2^16-1 (65535) bytes") ErrAtomTooLong = fmt.Errorf("atom too long - max allowed length is 255 bytes") ErrErrorTooLong = fmt.Errorf("error too long - max allowed length is 32767 bytes") ErrMaxDepthExceeded = fmt.Errorf("max encoding depth exceeded (cyclic reference?)") )
Functions ¶
func GetAtomCache ¶
func GetErrCache ¶
func GetRegCache ¶
func LookupType ¶ added in v1.999.330
LookupType returns the reflect.Type registered under the canonical EDF name ("#pkgpath/TypeName"), matched exactly. The old short-name fallback took the first suffix hit over a sync.Map, so the same name could resolve to a different package's type on every call. Search by short name over RegisteredTypes instead.
func MakeEncodeRegTypeCache ¶
func RegisterAtom ¶
func RegisterError ¶
func RegisterTypeOf ¶
func RegisterTypesOf ¶ added in v1.999.330
RegisterTypesOf registers a batch with iterative resolve. Order-agnostic: types with unresolved dependencies are retried while progress is made. Returns error listing types that cannot be resolved after exhausting passes.
func RegisteredAtoms ¶ added in v1.999.330
func RegisteredAtoms() []gen.RegisteredAtomInfo
RegisteredAtoms lists the atom cache entries, ordered by cache id. An unregistered atom is absent here and encoded in full on every hop, so an atom missing from this list is a wire-size cost, never a correctness problem.
The cache is process-global, not per-node: two nodes in one process report the same list.
func RegisteredErrors ¶ added in v1.999.330
func RegisteredErrors() []gen.RegisteredErrorInfo
RegisteredErrors lists the sentinel errors in the wire-format error cache, ordered by cache id. Framework sentinels pre-registered at init are included, so the result is the whole dictionary this process would offer at handshake - not only what the caller registered.
The cache is process-global, not per-node: two nodes in one process report the same list.
func RegisteredTypes ¶ added in v1.999.330
func RegisteredTypes() []gen.RegisteredTypeInfo
RegisteredTypes returns all registered EDF type metadata in registration order. Each entry is a value snapshot of the underlying *gen.RegisteredTypeInfo; counter fields reflect their values at snapshot time.
Types ¶
type Options ¶
type Options struct {
AtomCache *sync.Map // atom => id (encoding), id => atom (decoding)
AtomMapping *sync.Map // atomX => atomY (encoding/decoding)
RegCache *sync.Map // type/name => id (encoding), id => type (for decoding)
ErrCache *sync.Map // error => id (for encoder), id => error (for decoder)
Cache *sync.Map // common cache (caching reflect.Type => encoder, string([]byte) => decoder)
MaxDepth int // max encoding depth for pointers (default 100)
// WrappedErrorsSupported: peer supports *gen.Error wrapped wire format.
WrappedErrorsSupported bool
// SchemaEvolution: length-prefix encoded structs so a peer with a different
// field count tolerates the difference (extra skipped, missing zero-valued).
SchemaEvolution bool
}
Options for encoding/decoding