pub struct CreditHeader {
pub endpoint: String,
pub filter: String,
pub limit: u64,
}Expand description
CREDIT header (kind 5).
The L2 credit of
decisions/0003 §4.2-§4.3:
which subscription, and how many messages that subscription will accept in
total. Three keys, all required — a subscription is (endpoint, filter)
on the connection the frame arrives on, and an absent limit would be
indistinguishable from a limit of zero, which is the pause.
The limit is absolute and cumulative, not a delta. It counts messages
delivered on that subscription since it was created, so a lost frame costs
nothing and a duplicated one changes nothing. It is also monotone at the
receiver: a broker keeps the highest limit it has seen, which is what
makes a reordered frame harmless on a transport that does not order the
streams control frames ride. Monotone is the whole rule: a receiver
ignores any limit that is not strictly greater than the standing one, so
restating a number already delivered changes nothing unless the
subscription had exhausted its credit anyway. v0 offers no way to lower
a standing limit. The only pause is the 0 a fresh subscription starts
at, so a consumer that wants to stay in control grants in increments it
is willing to receive. AMQP 1.0 can shrink link-credit against an
absolute baseline [amqp10 §5.1]; this frame cannot, and a peer that reads
it as if it could would wait for a stop no broker can deliver.
Fields§
§endpoint: StringEndpoint path of the queue the subscription is on.
filter: StringTopic filter of the subscription. A decoded header’s filter has passed
filter::validate.
limit: u64Messages this subscription will accept in total, counted from its creation.
Implementations§
Source§impl CreditHeader
impl CreditHeader
Sourcepub fn new(
endpoint: impl Into<String>,
filter: impl Into<String>,
limit: u64,
) -> CreditHeader
pub fn new( endpoint: impl Into<String>, filter: impl Into<String>, limit: u64, ) -> CreditHeader
A header granting limit to the subscription (endpoint, filter).
Sourcepub fn encode_into(&self, out: &mut Vec<u8>)
pub fn encode_into(&self, out: &mut Vec<u8>)
Appends the encoded header to out, for a send path that reuses a
buffer (B-250). The canonical form has one implementation and this is
it; Self::encode is a wrapper.
Sourcepub fn decode(bytes: &[u8]) -> Result<CreditHeader, HeaderError>
pub fn decode(bytes: &[u8]) -> Result<CreditHeader, HeaderError>
Decodes the header.