Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EncoderInterface ¶
EncoderInterface is an interface each Encoder will have to abide to it will be used by the publisher/producer object to marshal payloads check defualt implementation of JSONEncoder for more info Example for protobuf:
import "google.golang.org/protobuf/proto"
type ProtoEncoder struct{}
func (e *ProtoEncoder) Encode(msg interface{}) ([]byte, error) { return proto.Marshal(msg) }
func NewProtoEncoder() EncoderInterface { return &ProtoEncoder{} }
func NewJSONEncoder ¶
func NewJSONEncoder() EncoderInterface
NewJSONEncoder returns an object implementing EncoderInterface
type JSONEncoder ¶
type JSONEncoder struct{}
JSONEncoder is the default encoder for publihsers/producers it implements the EncoderInterface and simply marshals an interface to json
func (*JSONEncoder) Encode ¶
func (e *JSONEncoder) Encode(msg interface{}) ([]byte, error)
Encode is the only method, needs to return ([]byte, error), in this case simply a wrapper around the json.Marshal funcrton
Click to show internal directories.
Click to hide internal directories.