Documentation
¶
Overview ¶
Package createbody reads a create command's private body, which is Core's CreateRequest, and re-presents the session's first message in the shape a Host's block decoder reads.
IT IS A PACKAGE FOR internal/gateresponse's REASON, not for tidiness. Host carries a command's body opaque on purpose — department.RuntimeCommand says so in as many words, because "Host is not the semantic validator of a command body — Harness is" — so every place that DOES read one is a deliberate exception with a rule of its own, and each such rule lives in a package that can be read and tested without the runtime edge around it. The gate response has two readers; this one has two: the applier checks the Core envelope before an attempt, and the harness adapter presents its blocks to the decoder.
IT DECODES NOTHING ONTO A WIRE. The records here are Core's, read from a durable body the store already holds; no frame crosses HostLink from this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyBody = errors.New("createbody: the command carries no inline body")
ErrEmptyBody is the cause of a MalformedError for a create with no inline body. A body stored behind an object reference is not this error: its bytes exist, this Host does not dereference them, and that is the caller's to say.
Functions ¶
func Check ¶ added in v0.6.0
func Check(body []byte, session sessionwire.SessionID, command sessionwire.CommandID) (bodyclass.Members, error)
Check validates the immutable create body against the durable command's identities before an attempt can be written.
func FirstMessage ¶
FirstMessage reads one create's stored body and returns its first message in the INPUT-SHAPED body a block decoder reads, or nil when the create carries none.
ONE ENCODING, NOT TWO, AND THAT IS THE WHOLE POINT OF THE RE-PRESENTATION. A composition names the encoding of a command's private content exactly once (harnessruntime's finding H7), and a create's first message is the same content an input carries — Core spells both as a JSON block array, and CreateRequest.Blocks and InputRequest.Blocks are the same raw member. The blocks are therefore returned inside the record an input would have arrived in, so a decoder sees exactly the bytes it would have seen had the same message been sent as an input a moment later. A second decoder option for a create's shape would let one composition decode every input and silently drop every create's first words, which is the failure this package exists to make impossible rather than to relocate.
A BARE CREATE IS NOT AN ERROR. Core's CreateRequest.Blocks is omitempty and its own doc says "Blocks are optional for an idle create"; refusing one would make every idle session's first command unsettleable, which is the wedge harness v0.36.0 exists to end, reinstated for a subset of sessions.
Types ¶
type MalformedError ¶
type MalformedError struct{ Cause error }
MalformedError reports a create body no Host can read as Core's create request. It is PERMANENT: the body is immutable once admitted, so a retry, or another Host, reads the same bytes and reaches the same answer.
func (*MalformedError) Error ¶
func (e *MalformedError) Error() string
func (*MalformedError) Unwrap ¶
func (e *MalformedError) Unwrap() error
Unwrap returns the decode failure.
type UnsupportedError ¶ added in v0.6.0
type UnsupportedError struct{ Cause error }
UnsupportedError reports bytes this Host cannot interpret but a newer Host may. The caller must leave the command claimed without an attempt, so a capable successor or Factory's deadline sweep can decide it later.
func (*UnsupportedError) Error ¶ added in v0.6.0
func (e *UnsupportedError) Error() string
func (*UnsupportedError) Unwrap ¶ added in v0.6.0
func (e *UnsupportedError) Unwrap() error