Documentation
¶
Overview ¶
Package gob provides a streaming gob github.com/alexfalkowski/go-service/v2/encoding/stream.Encoder/ github.com/alexfalkowski/go-service/v2/encoding/stream.Decoder pair used by go-service.
It wraps the standard library encoding/gob package's own NewEncoder/NewDecoder types with one persistent encoder/decoder bound to the writer/reader for the lifetime of the stream, unlike github.com/alexfalkowski/go-service/v2/encoding/gob, which constructs and discards a fresh encoder/decoder per call and rejects trailing values because it models exactly one value per call.
Start with the package-level constructors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
Decoder streams gob values from a reader bound at construction.
Decoder embeds the standard library's encoding/gob.Decoder, so [Decoder.Decode] is the embedded decoder's own method. Decoder satisfies github.com/alexfalkowski/go-service/v2/encoding/stream.Decoder structurally, without this package importing that package.
func NewDecoder ¶
NewDecoder constructs a streaming gob Decoder bound to r.
Unlike github.com/alexfalkowski/go-service/v2/encoding/gob.Encoder's Decode, the returned decoder allows additional gob values after the first: it does not enforce single-value trailing-data rejection, since a stream is expected to carry many values.
type Encoder ¶
Encoder streams gob values to a writer bound at construction.
Encoder embeds the standard library's encoding/gob.Encoder, so [Encoder.Encode] is the embedded encoder's own method. Encoder satisfies github.com/alexfalkowski/go-service/v2/encoding/stream.Encoder structurally, without this package importing that package: github.com/alexfalkowski/go-service/v2/encoding/stream.NewMap imports this package to pre-register the default "gob" kind, and this package importing that one back would be a compile-time import cycle.
func NewEncoder ¶
NewEncoder constructs a streaming gob Encoder bound to w.
Unlike github.com/alexfalkowski/go-service/v2/encoding/gob.Encoder, which constructs a fresh standard library encoder per Encode call, the returned encoder wraps one persistent encoding/gob.Encoder bound to w for the lifetime of the stream — the intended way to use gob for more than one value on the same connection.