Documentation
¶
Index ¶
- type JSON
- type Protobuf
- type Registry
- func (r *Registry) Default() int32
- func (r *Registry) Lookup(id int32) (cfacade.IBodyCodec, bool)
- func (r *Registry) Marshal(id int32, value any) ([]byte, error)
- func (r *Registry) Register(codec cfacade.IBodyCodec) error
- func (r *Registry) SetDefault(id int32) error
- func (r *Registry) Unmarshal(id int32, data []byte, value any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSON ¶
type JSON struct {
// contains filtered or unexported fields
}
JSON implements the shared body codec for ordinary Go values and protobuf messages.
func NewJSON ¶
func NewJSON() *JSON
NewJSON creates a codec for ordinary structs and canonical ProtoJSON messages.
type Protobuf ¶
type Protobuf struct{}
Protobuf serializes concrete generated protobuf messages.
type Registry ¶ added in v1.0.20
type Registry struct {
// contains filtered or unexported fields
}
Registry is the application-scoped allow-list of protocol body codecs.
func NewRegistry ¶ added in v1.0.20
func NewRegistry(codecs ...cfacade.IBodyCodec) *Registry
NewRegistry creates a registry and fails fast on conflicting built-in codecs. When protobuf is registered it becomes the default codec.
func (*Registry) Default ¶ added in v1.0.20
Default returns the codec id used when a call does not specify one.
func (*Registry) Lookup ¶ added in v1.0.20
func (r *Registry) Lookup(id int32) (cfacade.IBodyCodec, bool)
Lookup returns the codec registered for id.
func (*Registry) Marshal ¶ added in v1.0.20
Marshal encodes a concrete request, response or notification body.
func (*Registry) Register ¶ added in v1.0.20
func (r *Registry) Register(codec cfacade.IBodyCodec) error
Register adds or replaces a codec with the same ID and name. Reusing an ID for a different encoding is rejected because codec IDs are wire values.
func (*Registry) SetDefault ¶ added in v1.0.20
SetDefault selects the default codec. The id must already be registered.