Documentation ¶
Overview ¶
Package datacodec holds the data codec registry and adds known encoders and decoders supporting media types such as `application/json` and `application/xml`.
Index ¶
- Variables
- func AddDecoder(contentType string, fn Decoder)
- func AddEncoder(contentType string, fn Encoder)
- func Decode(ctx context.Context, contentType string, in, out interface{}) error
- func DecodeObserved(ctx context.Context, contentType string, in, out interface{}) error
- func Encode(ctx context.Context, contentType string, in interface{}) ([]byte, error)
- func EncodeObserved(ctx context.Context, contentType string, in interface{}) ([]byte, error)
- func SetObservedCodecs()
- type Decoder
- type Encoder
Constants ¶
This section is empty.
Variables ¶
var ( // LatencyMs measures the latency in milliseconds for the CloudEvents generic // codec data methods. LatencyMs = stats.Float64("cloudevents.io/sdk-go/datacodec/latency", "The latency in milliseconds for the CloudEvents generic data codec methods.", "ms") )
var ( // LatencyView is an OpenCensus view that shows data codec method latency. LatencyView = &view.View{ Name: "datacodec/latency", Measure: LatencyMs, Description: "The distribution of latency inside of the generic data codec for CloudEvents.", Aggregation: view.Distribution(0, .01, .1, 1, 10, 100, 1000, 10000), TagKeys: observability.LatencyTags(), } )
Functions ¶
func AddDecoder ¶
AddDecoder registers a decoder for a given content type. The codecs will use these to decode the data payload from a cloudevent.Event object.
func AddEncoder ¶
AddEncoder registers an encoder for a given content type. The codecs will use these to encode the data payload for a cloudevent.Event object.
func Decode ¶
Decode looks up and invokes the decoder registered for the given content type. An error is returned if no decoder is registered for the given content type.
func DecodeObserved ¶
DecodeObserved calls Decode and records the result.
func Encode ¶
Encode looks up and invokes the encoder registered for the given content type. An error is returned if no encoder is registered for the given content type.
func EncodeObserved ¶
EncodeObserved calls Encode and records the result.
func SetObservedCodecs ¶
func SetObservedCodecs()
Types ¶
Directories ¶
Path | Synopsis |
---|---|
Package json holds the encoder/decoder implementation for `application/json`.
|
Package json holds the encoder/decoder implementation for `application/json`. |
Text codec converts []byte or string to string and vice-versa.
|
Text codec converts []byte or string to string and vice-versa. |
Package xml holds the encoder/decoder implementation for `application/xml`.
|
Package xml holds the encoder/decoder implementation for `application/xml`. |