Documentation ¶
Overview ¶
Package codec is an interface for encoding messages
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInvalidMessage returned when invalid messge passed to codec ErrInvalidMessage = errors.New("invalid message") // ErrUnknownContentType returned when content-type is unknown ErrUnknownContentType = errors.New("unknown content-type") )
View Source
var ( // DefaultCodec is the global default codec DefaultCodec = NewCodec() // DefaultTagName specifies struct tag name to control codec Marshal/Unmarshal DefaultTagName = "codec" )
Functions ¶
Types ¶
type Codec ¶
type Codec interface { Marshal(v interface{}, opts ...Option) ([]byte, error) Unmarshal(b []byte, v interface{}, opts ...Option) error String() string }
Codec encodes/decodes various types of messages.
func FromContext ¶
FromContext returns codec from context
type Frame ¶
type Frame struct {
Data []byte
}
Frame gives us the ability to define raw data to send over the pipes
func (*Frame) MarshalJSON ¶
MarshalJSON returns frame data
func (*Frame) UnmarshalJSON ¶
UnmarshalJSON set frame data
type Option ¶
type Option func(*Options)
Option func
type Options ¶
type Options struct { // Meter used for metrics Meter meter.Meter // Logger used for logging Logger logger.Logger // Tracer used for tracing Tracer tracer.Tracer // Context stores additional codec options Context context.Context // TagName specifies tag name in struct to control codec TagName string // Flatten specifies that struct must be analyzed for flatten tag Flatten bool }
Options contains codec options
type RawMessage ¶ added in v3.10.19
type RawMessage []byte
RawMessage is a raw encoded JSON value. It implements Marshaler and Unmarshaler and can be used to delay decoding or precompute a encoding.
func (*RawMessage) MarshalJSON ¶ added in v3.10.19
func (m *RawMessage) MarshalJSON() ([]byte, error)
MarshalJSON returns m as the JSON encoding of m.
func (*RawMessage) UnmarshalJSON ¶ added in v3.10.19
func (m *RawMessage) UnmarshalJSON(data []byte) error
UnmarshalJSON sets *m to a copy of data.
Click to show internal directories.
Click to hide internal directories.