Documentation
¶
Overview ¶
Package json provides an es.TypedCodec backed by the standard library's encoding/json package.
Typical usage:
import (
"github.com/ianunruh/synapse/es"
jsoncodec "github.com/ianunruh/synapse/codec/json"
)
reg := es.NewRegistry()
es.Register(reg, "order.placed", jsoncodec.For[OrderPlaced]())
es.Register(reg, "order.shipped", jsoncodec.For[OrderShipped]())
Event types may freely implement encoding/json.Marshaler and encoding/json.Unmarshaler; encoding/json honors them. The Go 1.24 `omitzero` struct tag works transparently.
Index ¶
Constants ¶
View Source
const ContentType es.ContentType = "application/json"
ContentType is the IANA media type emitted by codecs from this package.
Variables ¶
This section is empty.
Functions ¶
func For ¶
func For[E any]() es.TypedCodec[E]
For returns an es.TypedCodec that serializes values of type E through encoding/json. Register it with es.Register:
es.Register(reg, "order.placed", jsoncodec.For[OrderPlaced]())
The returned codec is stateless and safe for concurrent use; the zero value of the internal type carries no fields, so calling For is effectively free.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.