Documentation
¶
Overview ¶
Package protocol is the pure stream-protocol layer of agentboot. It has no knowledge of how the agent process is started or how its events are routed — it only understands bytes flowing in and out of an io.Reader/io.Writer.
This isolation makes the decoder testable against fixed JSON inputs without any process or goroutine plumbing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder reads a stream of JSON-encoded values from an io.Reader and emits them as Events on the channel returned by Stream.
func NewDecoder ¶
NewDecoder constructs a Decoder reading from r.
func (*Decoder) Stream ¶
Stream consumes the decoder's input on a goroutine and returns the event channel together with an Err accessor.
Channel-close semantics:
- The channel is closed exactly once, when the source reaches EOF, ctx is canceled, or a non-recoverable decode error occurs.
- Err must only be called after the channel has been observed closed. The Go memory model guarantees the terminal error is visible to readers after channel-close synchronization.
- If the source implements io.Closer, it is closed on ctx cancel so that an in-flight blocking Decode unblocks promptly. Callers that pass a non-closer reader must close it themselves to abort decoding.
If decoding succeeds and the source ends cleanly with EOF, Err returns nil.
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder writes control responses (and other outbound messages) as newline-delimited JSON to a destination io.Writer. It is safe for concurrent use; concurrent Encode calls are serialized so that no two JSON values interleave on the wire.
func NewEncoder ¶
NewEncoder constructs an Encoder targeting w.