// Tracks the xDS protocol state of an individual ongoing delta xDS session, i.e. a single type_url.
// scenario is when we are subscribed to a wildcard resource, and other scenario is when we are not.
// Delta subscription state also divides the resources it cached into three categories: requested,
// The "requested" category is for resources that we have explicitly asked for (either through the
// initial set of resources or through the on-demand mechanism). Resources in this category are in
// "Complete" resources are resources about which the server sent us the information we need (for
// The "waiting for server" state is either for resources that we have just requested, but we still
// according to the server, are gone, but we are still interested in them - in such case we strip
// The "ambiguous" category is for resources that we stopped being interested in, but we may still
// be interested indirectly through the wildcard subscription. This situation happens because of the
// xDS protocol limitation - the server isn't able to tell us that the resource we subscribed to is
// also a part of our wildcard subscription. So when we unsubscribe from the resource, we need to
// receive a confirmation from the server whether to keep the resource (which means that it was a
// In the "no wildcard subscription" scenario all the cached resources should be in the "requested"
// explicitly unsubscribe from it. Transitions between "complete" and "waiting for server" happen
// when we receive messages from the server - if a resource in the message is in "added resources"
// list (thus contains version information), the resource becomes "complete". If the resource in the
// subscription" scenario, with one exception - the unsubscribed "complete" resource is not removed
// from the cache, but it's moved to the "ambiguous" resources instead. At this point we are waiting
// for the server to tell us that this resource should be either moved to the "wildcard" resources,
// or dropped. Resources in "wildcard" category are only added there or dropped from there by the
// The delta subscription state transitions between the two scenarios depending on whether we are
// wildcard subscription" to "wildcard subscription" scenario, but when transitioning in the other
envoy::service::discovery::v3::DeltaDiscoveryRequest getNextRequestWithAck(const UpdateAck& ack);
// A map from resource name to per-resource version. The keys of this map are exactly the resource
// names we are currently interested in. Those in the waitingForServer state currently don't have
// any version for that resource: we need to inform the server if we lose interest in them, but we
// an empty response, which is indistinguishable from a heartbeat in some cases. For now we just
// Tracks changes in our subscription interest since the previous DeltaDiscoveryRequest we sent.