codec

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package codec defines the serialization boundary between the bus runtime and the wire. v0.1 ships a JSON implementation; protobuf is reserved for v0.3.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	// Name returns a stable identifier for the codec, e.g. "json" or "protobuf".
	// Used by adapters that negotiate Content-Type / Content-Encoding.
	Name() string

	EncodeEnvelope(e *event.Envelope) ([]byte, error)
	DecodeEnvelope(data []byte) (*event.Envelope, error)

	// Encode/DecodePayload handle the inner business value. Returning RawMessage
	// keeps the wire representation opaque to the bus runtime so callers can
	// embed pre-serialized blobs without double-encoding.
	EncodePayload(v any) (json.RawMessage, error)
	DecodePayload(raw json.RawMessage, v any) error
}

Codec marshals/unmarshals envelopes and payloads. Implementations must be safe for concurrent use.

func JSON

func JSON() Codec

JSON returns the default JSON codec. The same instance is safe for concurrent use; callers may stash it in package-level variables.

Jump to

Keyboard shortcuts

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