Skip to main content

group_order

Function group_order 

Source
pub fn group_order(parameters: &[KeyValuePair]) -> Result<GroupOrder, FillError>
Expand description

The Group Order a fill fetch stream’s Objects arrive in, given the parameters of the SUBSCRIBE (or REQUEST_UPDATE) that asked for the fill.

A fill fetch stream is “delivered as a FETCH response” (Section 5.1.3), and a FETCH response’s Group ID Deltas are read against a Group Order that is nowhere on the data stream — Section 11.4.4.1 makes a delta count upward under Ascending and downward under Descending. So a subscriber has to resolve the order from the control exchange before it reads the first Object, and this is that resolution. Hand the answer to begin_fetch_objects; accept_fill_stream already does.

Three steps, in the order the two sections put them:

  1. A GROUP_ORDER inside FILL_PARAMETERS. Section 10.2.8: “When it appears inside FILL_PARAMETERS, it governs the fill fetch stream and its ordering relative to subscription-delivered Objects”.
  2. Otherwise the GROUP_ORDER on the request itself. Section 5.1.3: “The fill fetch stream inherits the subscription’s parameters” and “parameters carried inside FILL_PARAMETERS override them for the fill fetch stream”.
  3. Otherwise Ascending.

§Step 3 is a choice the draft does not make

Section 10.2.8 gives two different defaults and a fill sits between them: “If omitted from SUBSCRIBE or SUBSCRIBE_TRACKS, the publisher’s preference from the Track is used. If omitted from FETCH, the receiver uses Ascending (0x1).” A fill is asked for by a SUBSCRIBE and delivered as a FETCH response, so both sentences reach it. This crate takes the FETCH default, because the publisher’s preference is not a thing a subscriber holds when the first Object arrives — it is a Track Property that arrives in SUBSCRIBE_OK at the earliest, and on this path may not arrive at all — while Ascending is a value the reader can be started with before the stream opens. A subscriber that does learn the publisher’s preference and finds it Descending can restart the reader with begin_fetch_objects before reading the first Object.

§Errors

FillError::MalformedValue for a GROUP_ORDER whose value is not a uint8 in {1, 2} or whose shape is not a bare number, and FillError::NotRoundTrippable for a FILL_PARAMETERS value the codec’s own decoder refuses. Neither is reachable from a block this module built.