READ BYTES · FRAME EVENTS · CONSUME

gRPC-style framing: length, payload and parser boundaries

Fragment real encoded bytes, inspect the parser buffer and follow complete events into an ordered text consumer.

60-second inspection · actual local parser

Text source and visible output

Appended output

Unparsed buffer: first 32 bytes in hex

Your experiment

Compare the length-prefixed and SSE encodings of the same local records. Observe different wire byte counts while the reconstructed text remains identical. Full A2A/gRPC services are not executed.

The text is split into six-code-point deltas, numbered from 1. A source fault targets event 3, or the last event when fewer than three exist. Output is appended only after a complete frame is parsed and consumer processing finishes.

In streaming mode a full application queue pauses reads; one additional event may be processing. In buffered mode all body bytes arrive before parsing begins. The same 60-second inspection maps proportionally to each scenario’s modeled duration; it is not a network performance measurement.

Recent parser and consumer events

Original event fixtures

Offline byte-framing lesson. SSE parsing supports only the generated LF-delimited id/data subset; this is not a complete EventSource implementation. The alternative uses a zero compression byte plus four-byte big-endian payload length and UTF-8 JSON, not Protobuf. No HTTP/2 frames, headers, trailers, grpc-status, compression, TLS, provider API, A2A envelope, retries or reconnect/resume are implemented. The queue policy is application backpressure, not transport flow control. Duplicate suppression and strict contiguous event IDs are explicit application policies, not guarantees supplied by SSE/gRPC. Missing IDs are rejected without reordering or replay. Empty source is complete with no output; an incomplete frame remains truncated. SSE specification · gRPC message framing.

Parse a prefix before consuming a payload

This lab serializes actual bytes rather than treating each network read as an application message. In the gRPC-style option, one flag byte and a four-byte big-endian length precede the JSON payload. The decoder waits until it has the header and the entire declared payload before validating UTF-8 and the application record. A read can contain part of the prefix, part of a multi-byte character, or pieces of several records. The decoder buffer and application queue therefore represent different kinds of incomplete work.

Control the byte and application boundaries

Local text supplies the payload, with the browser limiting entry to one hundred twenty UTF-16 code units. The model groups Unicode code points into records of up to six, each with a sequence identifier and delta string. Framing format selects the LF-delimited SSE subset or an uncompressed five-byte gRPC-style prefix around JSON. Application consumption either parses complete events incrementally or waits for the full body. Bytes per read changes fragmentation, Read interval changes scheduled arrival spacing, Processing per event changes consumer time, and Queued events bounds waiting records separately from the one active record. Parameter edits rebuild the scenario and start inspection unless reduced motion is requested.

Reproduce fragmentation without corruption

Choose the gRPC-style format, keep the default text containing an emoji and set Bytes per read to one. Inspect the early states: bytes accumulate before the first complete record appears. At the final state, the visible output must equal the original text without replacement characters. Increase read size to sixty-four; event boundaries remain the same even though read boundaries change. Select Truncate final three bytes and inspect the end: the final incomplete payload stays unparsed and the result is truncated rather than reported complete. Empty source has no events and completes without fabricated output.

Inject failures and inspect safely

Source event fault repeats, omits or corrupts the third event, or the last available event for a shorter source; truncation removes the final three wire bytes. Ignore already-applied event IDs affects duplicate records only. Missing or malformed records can leave a sequence gap, and later records are rejected rather than reordered or replayed. Play and Pause inspect sixty seconds of viewing time; Next event advances a recorded scheduler transition; Restart inspection rewinds; Speed adjusts viewing pace; Inspection time scrubs. Visible output, pending-byte hex and recent events reflect the inspected prefix. The complete-run preview and original event list describe the full scenario, not work already consumed.

Keep framing distinct from a working RPC stack

The payload is JSON, not generated protobuf, and there is no HTTP/2 connection, stream identifier, response trailer, status mapping or A2A endpoint. Compressed payloads are rejected, oversized declared frames above the teaching limit are rejected, and the SSE option implements only its stated LF/id/data subset. The exercise demonstrates a local framing boundary, not interoperability with a live gRPC server. It cannot validate flow-control windows, transport security, service discovery or an ADK transport adapter.

Views are my own and do not represent any employer, past or present.

Search