pub struct Service {
pub mutex_federation: MutexMap<OwnedRoomId, ()>,
services: Arc<OnceServices>,
db: Data,
state_local: Arc<StateLocalCounters>,
prev_walk: PrevWalkCounters,
prev_walks_in_flight: InFlightWalks,
backoff: BackoffCounters,
}Expand description
Handles incoming events: authorization, fetching missing events, state resolution and upgrade into the timeline.
Federation transactions, joins, invites and backfill all route their PDUs through it.
Fields§
§mutex_federation: MutexMap<OwnedRoomId, ()>Serializes room federation as the outermost per-room operation.
Acquire it before the state or timeline insertion mutex for the same room. The canonical order is federation, state, then insertion.
services: Arc<OnceServices>§db: Data§state_local: Arc<StateLocalCounters>§prev_walk: PrevWalkCounters§prev_walks_in_flight: InFlightWalksGapped incoming events whose passes are in flight.
An entry lives exactly as long as its pass. Top-level timeline passes run
under the room’s mutex_federation except for remote invites and a local
join’s federation fallback, so entries stay within one per room holding its
federation mutex, plus any passes those two callers have in flight.
backoff: BackoffCountersImplementations§
Source§impl Service
impl Service
Sourcepub fn backoff_metrics(&self) -> BackoffMetrics
pub fn backoff_metrics(&self) -> BackoffMetrics
Read a snapshot of backoff verdict totals.
Reading does not reset the totals.
Source§impl Service
impl Service
Sourcepub(super) fn record_attempt(&self, ctx: Context, event_id: &EventId) -> u32
pub(super) fn record_attempt(&self, ctx: Context, event_id: &EventId) -> u32
Record a federation attempt before a cancellable await, so a premature
cancellation still leaves a Pending row behind to rate-gate against.
Returns the attempt’s bucket for record_completion to settle.
Source§impl Service
impl Service
Sourcepub(super) async fn record_completion(
&self,
ctx: Context,
event_id: &EventId,
standing: Suppression,
attempt: Option<u32>,
appended: Result<bool, &Error>,
)
pub(super) async fn record_completion( &self, ctx: Context, event_id: &EventId, standing: Suppression, attempt: Option<u32>, appended: Result<bool, &Error>, )
Settle a step once its work has finished.
An appended event clears what the context holds for it: only the attempt’s
own row when nothing preceded it, every row otherwise. A failure is recorded
as Transient in the bucket of the attempt it settles, replacing that
attempt’s Pending row, or in the current bucket when rows preceded the
step but no attempt was written. A withheld event, a failure from an
interruption or shutdown, or a step with no rows and no attempt records
nothing. Rows an earlier gapped pass left behind outlive a later append
that found no gap, until the store reaps them.
Source§impl Service
impl Service
pub(super) fn record_outcome( &self, ctx: Context, event_id: &EventId, disposition: Disposition, )
Source§impl Service
impl Service
Sourcepub async fn clear_delivery_backoff(&self, event_id: &EventId)
pub async fn clear_delivery_backoff(&self, event_id: &EventId)
Clears the backoffs recorded against an event’s delivery.
The soft-fail marker and these backoffs gate the same retry, so operator recovery has to drop all of them before the event is next evaluated, whether by a redelivery or as the prev of a later event.
Source§impl Service
impl Service
pub(super) async fn record_success(&self, ctx: Context, event_id: &EventId)
Source§impl Service
impl Service
Sourcepub(super) fn is_suppressed(
&self,
ctx: Context,
event_id: &EventId,
range: Range<Duration>,
) -> impl Future<Output = Suppression> + Send
pub(super) fn is_suppressed( &self, ctx: Context, event_id: &EventId, range: Range<Duration>, ) -> impl Future<Output = Suppression> + Send
Consult the store before a federation step, counting the verdict.
The verdict is counted when the store answers, so a lookup dropped before then counts nothing.
Source§impl Service
impl Service
fn record_outcome_at( &self, ctx: Context, event_id: &EventId, bucket: u32, disposition: Disposition, )
Source§impl Service
impl Service
Sourcepub(super) async fn fetch_auth<'a, Events>(
&self,
origin: &ServerName,
room_id: &RoomId,
events: Events,
room_version: &RoomVersionId,
recursion_level: usize,
) -> Vec<(PduEvent, Option<CanonicalJsonObject>)>
pub(super) async fn fetch_auth<'a, Events>( &self, origin: &ServerName, room_id: &RoomId, events: Events, room_version: &RoomVersionId, recursion_level: usize, ) -> Vec<(PduEvent, Option<CanonicalJsonObject>)>
Find the event and auth it. Once the event is validated (steps 1 - 8) it is appended to the outliers Tree.
Returns pdu and if we fetched it over federation the raw json.
a. Look in the main timeline (pduid_pdu tree) b. Look at outlier pdu tree c. Ask origin server over federation d. TODO: Ask other servers over federation?
Source§impl Service
impl Service
async fn fetch_auth_chain( &self, origin: &ServerName, room_id: &RoomId, event_id: &EventId, room_version: &RoomVersionId, ) -> (OwnedEventId, Option<PduEvent>, Vec<(OwnedEventId, CanonicalJsonObject)>)
Source§impl Service
impl Service
Sourcepub(super) async fn fetch_prev<'a, Events>(
&self,
__arg1: PrevUpgrade<'_>,
initial_set: Events,
) -> Result<PrevFetch>
pub(super) async fn fetch_prev<'a, Events>( &self, __arg1: PrevUpgrade<'_>, initial_set: Events, ) -> Result<PrevFetch>
Walk an incoming event’s missing previous events backwards.
Each fetched event queues its own missing previous events in turn, until
they reach the timeline, predate the room, or exceed the
max_fetch_prev_events cap.
Source§impl Service
impl Service
Sourceasync fn prefetch_missing_events(
&self,
origin: &ServerName,
room_id: &RoomId,
incoming_event_id: &EventId,
room_version: &RoomVersionId,
recursion_level: usize,
)
async fn prefetch_missing_events( &self, origin: &ServerName, room_id: &RoomId, incoming_event_id: &EventId, room_version: &RoomVersionId, recursion_level: usize, )
Fill the prev gap below incoming_event_id with one /get_missing_events
batch, landing each returned event as a local outlier so the per-event walk
resolves it without a federation fetch. latest_events is the held event
the server walks back from, bounded by our forward extremities so it returns
only the gap; best effort, so a failed batch or rejected event just leaves
that id for the walk.
Source§impl Service
impl Service
Sourceasync fn land_missing_event(
&self,
origin: &ServerName,
room_id: &RoomId,
pdu: &RawJsonValue,
room_version: &RoomVersionId,
recursion_level: usize,
) -> Result
async fn land_missing_event( &self, origin: &ServerName, room_id: &RoomId, pdu: &RawJsonValue, room_version: &RoomVersionId, recursion_level: usize, ) -> Result
Authenticate and persist one event from the missing-events batch as an outlier, deriving its id from content rather than trusting a requested id.
Source§impl Service
impl Service
Sourcepub(super) async fn fetch_state(
&self,
origin: &ServerName,
room_id: &RoomId,
event_id: &EventId,
room_version: &RoomVersionId,
recursion_level: usize,
create_event_id: &EventId,
) -> Result<Option<HashMap<u64, OwnedEventId>>>
pub(super) async fn fetch_state( &self, origin: &ServerName, room_id: &RoomId, event_id: &EventId, room_version: &RoomVersionId, recursion_level: usize, create_event_id: &EventId, ) -> Result<Option<HashMap<u64, OwnedEventId>>>
Call /state_ids to find out what the state at this pdu is. We trust the server’s response to some extend (sic), but we still do a lot of checks on the events
Source§impl Service
impl Service
Sourcepub fn handle_incoming_pdu<'a>(
&'a self,
__arg1: &'a ServerName,
__arg2: &'a RoomId,
__arg3: &'a EventId,
__arg4: CanonicalJsonObject,
__arg5: bool,
) -> Pin<Box<dyn Future<Output = Result<Option<(RawPduId, bool)>>> + Send + 'a>>
pub fn handle_incoming_pdu<'a>( &'a self, __arg1: &'a ServerName, __arg2: &'a RoomId, __arg3: &'a EventId, __arg4: CanonicalJsonObject, __arg5: bool, ) -> Pin<Box<dyn Future<Output = Result<Option<(RawPduId, bool)>>> + Send + 'a>>
When receiving an event one needs to: 0. Check the server is in the room
- Skip the PDU if we already know about it 1.1. Remove unsigned field
- Check signatures, otherwise drop
- Check content hash, redact if doesn’t match
- Fetch any missing auth events doing all checks listed here starting at 1. These are not timeline events
- Reject “due to auth events” if can’t get all the auth events or some of the auth events are also rejected “due to auth events”
- Reject “due to auth events” if the event doesn’t pass auth based on the auth events
- Persist this event as an outlier
- If not timeline event: stop
- Fetch any missing prev events doing all checks listed here starting at 1. These are timeline events
- Fetch missing state and auth chain events by calling
/state_idsat backwards extremities doing all the checks in this list starting at- These are not timeline events
- Check the auth of the event passes based on the state of the event
- Ensure that the state is derived from the previous current state (i.e. we calculated by doing state res where one of the inputs was a previously trusted set of state, don’t just trust a set of state we got from a remote)
- Use state resolution to find new room state
- Check if the event passes auth based on the “current state” of the room, if not soft fail it
async fn __handle_incoming_pdu<'a>( &'a self, origin: &'a ServerName, room_id: &'a RoomId, event_id: &'a EventId, pdu: CanonicalJsonObject, is_timeline_event: bool, ) -> Result<Option<(RawPduId, bool)>>
Source§impl Service
impl Service
Sourceasync fn handle_rescinded_invite(
&self,
room_id: &RoomId,
pdu: &CanonicalJsonObject,
) -> Result<bool>
async fn handle_rescinded_invite( &self, room_id: &RoomId, pdu: &CanonicalJsonObject, ) -> Result<bool>
Apply a federated leave that rescinds an out-of-band invite for a local user.
We are not resident in the room, so the kick cannot be processed as a normal
timeline event for lack of room state; but it must still clear the invite so
the invited user’s /sync reflects the rescission. Mirrors Synapse’s
out-of-band membership handling: only a kick from the original inviter is
honored, since without the room state we cannot judge any other sender’s
authority. Returns true when a rescission was applied.
Source§impl Service
impl Service
Sourceasync fn handle_prev_events(
&self,
upgrade: PrevUpgrade<'_>,
sorted_prev_events: Vec<OwnedEventId>,
pdus: HashMap<OwnedEventId, (PduEvent, CanonicalJsonObject)>,
) -> Result<usize>
async fn handle_prev_events( &self, upgrade: PrevUpgrade<'_>, sorted_prev_events: Vec<OwnedEventId>, pdus: HashMap<OwnedEventId, (PduEvent, CanonicalJsonObject)>, ) -> Result<usize>
Upgrade an incoming PDU’s previous events, walking interior events after their parents so each derives state locally instead of refetching it.
Extremities upgrade concurrently up to prev_events_concurrency; interior
events upgrade one at a time. Returns how many previous events were upgraded.
Source§impl Service
impl Service
Sourceasync fn upgrade_prev_event(
&self,
upgrade: PrevUpgrade<'_>,
info: Option<(PduEvent, CanonicalJsonObject)>,
prev_id: &EventId,
) -> Result<Option<(RawPduId, bool)>>
async fn upgrade_prev_event( &self, upgrade: PrevUpgrade<'_>, info: Option<(PduEvent, CanonicalJsonObject)>, prev_id: &EventId, ) -> Result<Option<(RawPduId, bool)>>
Upgrade one previous event, folding a failure into a non-fatal skip so a single bad prev does not abort the batch.
A failure records a transient backoff for the prev. A shutdown propagates through the leading running check; an interruption surfacing from inside the upgrade is not a verdict on the prev and records nothing.
Source§impl Service
impl Service
pub(super) async fn handle_prev_pdu( &self, upgrade: PrevUpgrade<'_>, eventid_info: Option<(PduEvent, CanonicalJsonObject)>, prev_id: &EventId, ) -> Result<Option<(RawPduId, bool)>>
Source§impl Service
impl Service
Sourcepub(super) async fn cached_resolved_state(
&self,
event_id: &EventId,
) -> Result<Option<HashMap<u64, OwnedEventId>>>
pub(super) async fn cached_resolved_state( &self, event_id: &EventId, ) -> Result<Option<HashMap<u64, OwnedEventId>>>
Loads state resolved for an event outside the timeline by event id.
The value is a non-authoritative compressor pointer that avoids a repeat
/state_ids fetch. A successful positional check can later promote the
materialized state into the event’s authoritative state row.
A hit requires strict state materialization and a live create-event canary. Missing cache data remains a miss; materialization failures remain errors.
Source§impl Service
impl Service
Sourcepub(super) async fn cache_resolved_state(
&self,
room_id: &RoomId,
event_id: &EventId,
state: Arc<CompressedState>,
)
pub(super) async fn cache_resolved_state( &self, room_id: &RoomId, event_id: &EventId, state: Arc<CompressedState>, )
Persist the state resolved for event_id over federation so a later walk of
the same event resolves without another fetch. Best effort: a failed
compressor write leaves the next walk to refetch.
Source§impl Service
impl Service
pub async fn parse_incoming_pdu( &self, pdu: &RawJsonValue, ) -> Result<(OwnedRoomId, OwnedEventId, CanonicalJsonObject)>
Source§impl Service
impl Service
Sourceasync fn invited_room_version(&self, room_id: &RoomId) -> Option<RoomVersionId>
async fn invited_room_version(&self, room_id: &RoomId) -> Option<RoomVersionId>
Recover a room’s version from a locally-invited member’s stored stripped state, for a room we are not resident in (e.g. a rescinded out-of-band invite). The create event in the stripped state carries the version.
Source§impl Service
impl Service
Sourcepub fn clear_policy_signature_state(&self, event_id: &EventId)
pub fn clear_policy_signature_state(&self, event_id: &EventId)
Clears the cached policy server decision for an event.
A later validation can contact the policy server again.
Source§impl Service
impl Service
fn cache_policy_refused(&self, event_id: &EventId)
Source§impl Service
impl Service
async fn cached_policy_state( &self, event_id: &EventId, ) -> Option<PolicySigState>
Source§impl Service
impl Service
Sourcepub async fn lookup_policy_server(
&self,
room_id: &RoomId,
) -> Option<RoomPolicyEventContent>
pub async fn lookup_policy_server( &self, room_id: &RoomId, ) -> Option<RoomPolicyEventContent>
Returns the room’s policy event content when a policy server is in effect:
state event present (stable m.room.policy, falling back to MSC4284’s
unstable org.matrix.msc4284.policy), parses cleanly under either the
stable public_keys map or the unstable singular public_key field, and
the via server has a joined user in the room. Any failure returns None,
signalling “no policy server configured” so the caller skips the gate
entirely.
Source§impl Service
impl Service
Sourcepub async fn sign_outgoing_pdu<E>(
&self,
pdu_json: &mut CanonicalJsonObject,
pdu: &E,
) -> Resultwhere
E: Event,
pub async fn sign_outgoing_pdu<E>(
&self,
pdu_json: &mut CanonicalJsonObject,
pdu: &E,
) -> Resultwhere
E: Event,
MSC4284: ask the room’s policy server to sign an outgoing event. The
signature is folded into pdu_json["signatures"] so it persists with the
event and federates transitively to other servers in the room. Returns
Forbidden when the policy server explicitly refuses; network errors and
timeouts fail open with a warn log.
Source§impl Service
impl Service
Sourceasync fn fetch_policy_signature(
&self,
policy: &RoomPolicyEventContent,
pdu_json: &CanonicalJsonObject,
room_version: &RoomVersionId,
) -> FetchOutcome
async fn fetch_policy_signature( &self, policy: &RoomPolicyEventContent, pdu_json: &CanonicalJsonObject, room_version: &RoomVersionId, ) -> FetchOutcome
Calls the policy server’s /sign endpoint. The classification of the
response (Signed / Refused / RateLimited / FailOpen) lets each
caller choose its own reaction.
Source§impl Service
impl Service
Sourcepub async fn verify_or_fetch_inbound_policy_signature<E>(
&self,
pdu_json: &mut CanonicalJsonObject,
pdu: &E,
) -> PolicyCheckwhere
E: Event,
pub async fn verify_or_fetch_inbound_policy_signature<E>(
&self,
pdu_json: &mut CanonicalJsonObject,
pdu: &E,
) -> PolicyCheckwhere
E: Event,
MSC4284: verify the inbound PDU’s policy server signature.
Missing or invalid signatures are fetched again because the policy server’s key may have rotated. A fetched signature is folded into the event.
Source§impl Service
impl Service
Sourceasync fn fetch_inbound_policy_signature<E>(
&self,
pdu_json: &mut CanonicalJsonObject,
pdu: &E,
) -> PolicyCheckwhere
E: Event,
async fn fetch_inbound_policy_signature<E>(
&self,
pdu_json: &mut CanonicalJsonObject,
pdu: &E,
) -> PolicyCheckwhere
E: Event,
MSC4284: fetch a missing or invalid inbound policy server signature.
The signature is folded into pdu_json so it persists and federates
onward. Refusals map to Invalid; transient failures map to Pass.
Source§impl Service
impl Service
Sourcepub async fn check_inbound_policy_signature<E>(
&self,
pdu_json: &CanonicalJsonObject,
pdu: &E,
) -> PolicyCheckwhere
E: Event,
pub async fn check_inbound_policy_signature<E>(
&self,
pdu_json: &CanonicalJsonObject,
pdu: &E,
) -> PolicyCheckwhere
E: Event,
MSC4284: verify the policy server signature on an inbound PDU. Returns
NotApplicable for rooms without a configured policy server (the gate is
skipped); Pass when the signature verifies; Missing when no signature
is present for the configured server; Invalid when the signature is
present but cryptographic verification fails.
Source§impl Service
impl Service
Sourcepub(super) fn record_pass(&self, upgrade: &PrevUpgrade<'_>, pass: &Pass)
pub(super) fn record_pass(&self, upgrade: &PrevUpgrade<'_>, pass: &Pass)
Record a reported pass in its room’s history.
The row is keyed by the wall clock at the write, and passes ending in the same millisecond stay apart by event. The write is synchronous and panics on a read-only database, like the backoff attempt recorded on the same path.
Source§impl Service
impl Service
Sourcepub async fn prev_walk_rooms(
&self,
) -> impl ExactSizeIterator<Item = PrevWalkRoom> + Send
pub async fn prev_walk_rooms( &self, ) -> impl ExactSizeIterator<Item = PrevWalkRoom> + Send
Read the recorded prev walk totals of every room, grouped by room in key order.
The whole history is swept once, so the cost grows with the passes it keeps, at most three days of them and fewer under load. A row that fails to decode is skipped, or fails an assertion in a debug build.
Source§impl Service
impl Service
Sourcepub fn prev_walk_passes<'a>(
&'a self,
room_id: &'a RoomId,
) -> impl Stream<Item = PrevWalkPass> + Send + 'a
pub fn prev_walk_passes<'a>( &'a self, room_id: &'a RoomId, ) -> impl Stream<Item = PrevWalkPass> + Send + 'a
Stream the recorded passes of one room, latest first.
A row that fails to decode is skipped, or fails an assertion in a debug build.
Source§impl Service
impl Service
Sourcepub fn prev_walk_metrics(&self) -> PrevWalkMetrics
pub fn prev_walk_metrics(&self) -> PrevWalkMetrics
Read a snapshot of incoming previous-event walk totals.
Reading does not reset the totals.
Source§impl Service
impl Service
Sourcepub fn prev_walks_in_flight(
&self,
) -> impl ExactSizeIterator<Item = InFlightWalk> + Send + use<>
pub fn prev_walks_in_flight( &self, ) -> impl ExactSizeIterator<Item = InFlightWalk> + Send + use<>
Read the gapped incoming events whose passes are in flight, in registration order.
The entries are copied out under the registry lock, since an iterator over the registry itself could not outlive the lock.
Source§impl Service
impl Service
Sourcepub fn prev_walks_in_flight_count(&self) -> usize
pub fn prev_walks_in_flight_count(&self) -> usize
Count the gapped incoming events whose passes are in flight.
Counting copies nothing out of the registry.
Source§impl Service
impl Service
pub async fn resolve_state( &self, room_id: &RoomId, room_version: &RoomVersionId, incoming_state: HashMap<u64, OwnedEventId>, ) -> Result<Arc<CompressedState>>
Source§impl Service
impl Service
pub(super) async fn state_resolution<StateSets, AuthSets>( &self, _room_id: &RoomId, room_version: &RoomVersionId, state_sets: StateSets, auth_chains: AuthSets, complete: Option<&AtomicBool>, ) -> Result<StateMap<OwnedEventId>>
Source§impl Service
impl Service
async fn state_at_incoming_fork<Pdu>(
&self,
room_id: &RoomId,
room_version: &RoomVersionId,
sstatehash: ShortStateHash,
prev_event: Pdu,
) -> Result<(StateMap<OwnedEventId>, AuthSet<OwnedEventId>), ForkError>where
Pdu: Event,
Source§impl Service
impl Service
Sourcepub(super) async fn fork_state<'a, State>(
&'a self,
state: State,
) -> Result<StateMap<OwnedEventId>>
pub(super) async fn fork_state<'a, State>( &'a self, state: State, ) -> Result<StateMap<OwnedEventId>>
Converts one fork branch from short state keys to typed state keys.
A later duplicate state key replaces an earlier entry. Short state key lookup failures are returned without constructing a partial map.
Source§impl Service
impl Service
Sourcepub(super) async fn fork_chain<'a, Events>(
&'a self,
room_id: &'a RoomId,
room_version: &'a RoomVersionId,
starting_events: Events,
) -> Result<AuthSet<OwnedEventId>>
pub(super) async fn fork_chain<'a, Events>( &'a self, room_id: &'a RoomId, room_version: &'a RoomVersionId, starting_events: Events, ) -> Result<AuthSet<OwnedEventId>>
Collects the full auth chain for one fork branch.
The ids are distinct as AuthSet::from_distinct requires: the chain
walk dedups short ids and the short-to-event-id mapping is injective.
Iteration order is arbitrary.
Source§impl Service
impl Service
Sourcepub(super) async fn fork_chain_strict<'a, Events>(
&'a self,
room_id: &'a RoomId,
room_version: &'a RoomVersionId,
starting_events: Events,
complete: &'a AtomicBool,
) -> Result<AuthSet<OwnedEventId>>
pub(super) async fn fork_chain_strict<'a, Events>( &'a self, room_id: &'a RoomId, room_version: &'a RoomVersionId, starting_events: Events, complete: &'a AtomicBool, ) -> Result<AuthSet<OwnedEventId>>
Collects the strict full auth chain for one fork branch.
The shared completeness flag is cleared when a polled chain source cannot be loaded.
Source§impl Service
impl Service
Sourcepub(super) async fn state_at_incoming_local<Pdu>(
&self,
room_id: &RoomId,
incoming_pdu: &Pdu,
room_version: &RoomVersionId,
create_event_id: &EventId,
mode: WalkMode,
) -> Result<Option<HashMap<ShortStateKey, OwnedEventId>>>where
Pdu: Event,
pub(super) async fn state_at_incoming_local<Pdu>(
&self,
room_id: &RoomId,
incoming_pdu: &Pdu,
room_version: &RoomVersionId,
create_event_id: &EventId,
mode: WalkMode,
) -> Result<Option<HashMap<ShortStateKey, OwnedEventId>>>where
Pdu: Event,
Build the state before incoming_pdu from events we already hold, walking
locally held uncommitted ancestry down to committed or memoized ancestors
with an auth gate on every folded state event. Some(map) is a complete
gated build in the shape the sibling builders return; None falls back to
the federation state fetch, for any reason. Err propagates only server
shutdown and room-version failures.
Source§impl Service
impl Service
Sourceasync fn walk_task(
&self,
room_id: OwnedRoomId,
room_version: RoomVersionId,
create_event_id: OwnedEventId,
mode: WalkMode,
top_prevs: PrevEvents,
attempt: WalkAttempt,
) -> Result<Option<HashMap<ShortStateKey, OwnedEventId>>>
async fn walk_task( &self, room_id: OwnedRoomId, room_version: RoomVersionId, create_event_id: OwnedEventId, mode: WalkMode, top_prevs: PrevEvents, attempt: WalkAttempt, ) -> Result<Option<HashMap<ShortStateKey, OwnedEventId>>>
Walk body on its own task: a poll descends every combinator layer from the task root, and under /send intake, already the server’s deepest stack, the walk’s auth-gate subtree overflows the worker stack in debug builds.
Source§impl Service
impl Service
Sourcepub fn state_local_metrics(&self) -> StateLocalMetrics
pub fn state_local_metrics(&self) -> StateLocalMetrics
Read an observational snapshot of production local-build totals.
The values cover this process lifetime and do not reset when read.
Source§impl Service
impl Service
Sourcepub async fn local_state_report(
&self,
event_id: &EventId,
) -> Result<LocalBuildReport>
pub async fn local_state_report( &self, event_id: &EventId, ) -> Result<LocalBuildReport>
Run a diagnostic walk for one stored event and describe the outcome.
The walk does not write authoritative state, resolved-state memos, or production counters. It may allocate short IDs and warm auth-chain caches.
Source§impl Service
impl Service
Sourceasync fn walk_state(
&self,
walk: &mut Walk<'_>,
) -> Result<Option<HashMap<ShortStateKey, OwnedEventId>>>
async fn walk_state( &self, walk: &mut Walk<'_>, ) -> Result<Option<HashMap<ShortStateKey, OwnedEventId>>>
Drive discovery then the post-order build; any abnormality sets walk.fallback and yields None.
Source§impl Service
impl Service
Sourceasync fn walk_discover(&self, walk: &mut Walk<'_>) -> Result
async fn walk_discover(&self, walk: &mut Walk<'_>) -> Result
Classify the uncommitted ancestry below the incoming event with point reads only, emitting held nodes in post-order; every condition the build cannot survive sets walk.fallback here, before any state materializes.
Source§impl Service
impl Service
Sourceasync fn walk_auth_present(&self, walk: &Walk<'_>, pdu: &PduEvent) -> bool
async fn walk_auth_present(&self, walk: &Walk<'_>, pdu: &PduEvent) -> bool
The auth gate must stay evaluable: every auth event of a held node has to be present locally before the walk commits to building through it. Hydra rooms chain the create event implied by the room id.
Source§impl Service
impl Service
Sourceasync fn walk_build(
&self,
walk: &mut Walk<'_>,
) -> Result<Option<HashMap<ShortStateKey, OwnedEventId>>>
async fn walk_build( &self, walk: &mut Walk<'_>, ) -> Result<Option<HashMap<ShortStateKey, OwnedEventId>>>
Compute state through the walk sub-DAG in post-order, so every node’s prevs resolve before it, then combine at the incoming event’s own prevs.
Source§impl Service
impl Service
Sourceasync fn state_after(
&self,
walk: &mut Walk<'_>,
event_id: &EventId,
) -> Option<Arc<HashMap<ShortStateKey, OwnedEventId>>>
async fn state_after( &self, walk: &mut Walk<'_>, event_id: &EventId, ) -> Option<Arc<HashMap<ShortStateKey, OwnedEventId>>>
State after one prev: an already-resolved node or materialized frontier entry shares its map; otherwise the frontier materializes here.
Source§impl Service
impl Service
Sourceasync fn committed_state_after(
&self,
walk: &mut Walk<'_>,
event_id: &EventId,
shortstatehash: ShortStateHash,
) -> Option<Arc<HashMap<ShortStateKey, OwnedEventId>>>
async fn committed_state_after( &self, walk: &mut Walk<'_>, event_id: &EventId, shortstatehash: ShortStateHash, ) -> Option<Arc<HashMap<ShortStateKey, OwnedEventId>>>
State after a committed frontier event: its stored state plus its own key folded unguarded, exactly the degree-one builder’s shape.
Every event holding a shorteventid_shortstatehash row passed spec check 5
(auth against the state at its own position) as a hard reject; soft failure
(spec check 6) still writes the row, so soft-failed events are valid fold
inputs while positionally rejected events never gain a row.
Source§impl Service
impl Service
Sourceasync fn memoized_state_after(
&self,
walk: &mut Walk<'_>,
event_id: &EventId,
) -> Option<Arc<HashMap<ShortStateKey, OwnedEventId>>>
async fn memoized_state_after( &self, walk: &mut Walk<'_>, event_id: &EventId, ) -> Option<Arc<HashMap<ShortStateKey, OwnedEventId>>>
State after a memoized frontier event: the memo row is its complete state-before, so its own gated fold preserves that guarantee for descendants.
Source§impl Service
impl Service
Sourceasync fn gated_fold(
&self,
room_rules: &RoomVersionRules,
gate_drops: &mut usize,
pdu: &PduEvent,
before: &Arc<HashMap<ShortStateKey, OwnedEventId>>,
) -> Result<Arc<HashMap<ShortStateKey, OwnedEventId>>>
async fn gated_fold( &self, room_rules: &RoomVersionRules, gate_drops: &mut usize, pdu: &PduEvent, before: &Arc<HashMap<ShortStateKey, OwnedEventId>>, ) -> Result<Arc<HashMap<ShortStateKey, OwnedEventId>>>
Fold the event’s own state key over its state-before, only when the position-correct auth gate passes; a rejection leaves state unchanged.
Evaluation failures abort the local walk so federation can rebuild a complete input state.
Source§impl Service
impl Service
Sourceasync fn fork_resolve(
&self,
walk: &mut Walk<'_>,
prevs: &[OwnedEventId],
memo_event_id: Option<&EventId>,
) -> Option<Arc<HashMap<ShortStateKey, OwnedEventId>>>
async fn fork_resolve( &self, walk: &mut Walk<'_>, prevs: &[OwnedEventId], memo_event_id: Option<&EventId>, ) -> Option<Arc<HashMap<ShortStateKey, OwnedEventId>>>
State before a fork node, resolving the state after each of its prevs exactly as the committed-prev fork resolves today. Fork outputs are the artifacts worth memoizing; chain nodes are cheap to re-derive.
Source§impl Service
impl Service
pub(super) async fn upgrade_outlier_to_timeline_pdu( &self, __arg1: PrevUpgrade<'_>, incoming_pdu: PduEvent, pdu_json: CanonicalJsonObject, ) -> Result<Option<(RawPduId, bool)>>
Source§impl Service
impl Service
async fn current_state_auth_passes( &self, room_id: &RoomId, incoming_pdu: &PduEvent, room_rules: &RoomVersionRules, ) -> Result<bool>
Source§impl Service
impl Service
Sourceasync fn soft_fail_standing(
&self,
incoming_pdu: &PduEvent,
room_rules: &RoomVersionRules,
pdu_json: &mut CanonicalJsonObject,
) -> Result<Standing>
async fn soft_fail_standing( &self, incoming_pdu: &PduEvent, room_rules: &RoomVersionRules, pdu_json: &mut CanonicalJsonObject, ) -> Result<Standing>
Re-examines an event that already carries a soft-fail marker.
The marker is a standing verdict rather than a permanent rejection, so it lapses on the upgrade backoff and the event is weighed again. Asking before state resolution keeps a still-refused event cheap to decline, since a cached policy answer needs no round trip.
Source§impl Service
impl Service
async fn resolve_state_at_incoming_event( &self, origin: &ServerName, room_id: &RoomId, incoming_pdu: &PduEvent, room_version: &RoomVersionId, recursion_level: usize, create_event_id: &EventId, ) -> Result<(HashMap<u64, OwnedEventId>, ResolvedVia)>
Source§impl Service
impl Service
async fn compute_soft_fail( &self, incoming_pdu: &PduEvent, room_rules: &RoomVersionRules, pdu_json: &mut CanonicalJsonObject, ) -> Result<bool>
Source§impl Service
impl Service
async fn compute_remaining_extremities( &self, room_id: &RoomId, incoming_pdu: &PduEvent, ) -> Vec<OwnedEventId>
Source§impl Service
impl Service
async fn resolve_and_force_state_after( &self, room_id: &RoomId, room_version: &RoomVersionId, incoming_pdu: &PduEvent, state_at_incoming_event: &HashMap<u64, OwnedEventId>, state_lock: &RoomMutexGuard, ) -> Result
Trait Implementations§
Source§impl Service for Service
impl Service for Service
Source§fn build(args: &Args<'_>) -> Result<Arc<Self>>
fn build(args: &Args<'_>) -> Result<Arc<Self>>
Source§fn memory_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
out: &'life1 mut (dyn Write + Send),
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn memory_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
out: &'life1 mut (dyn Write + Send),
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn clear_cache<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear_cache<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn name(&self) -> &str
fn name(&self) -> &str
crate::service::make_name(std::module_path!())Source§fn worker<'async_trait>(
self: Arc<Self>,
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
fn worker<'async_trait>(
self: Arc<Self>,
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
Source§fn interrupt<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn interrupt<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn unconstrained(&self) -> bool
fn unconstrained(&self) -> bool
Auto Trait Implementations§
impl !Freeze for Service
impl !RefUnwindSafe for Service
impl !UnwindSafe for Service
impl Send for Service
impl Sync for Service
impl Unpin for Service
impl UnsafeUnpin for Service
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ExpectInto for T
impl<T> ExpectInto for T
Source§impl<T> Expected for T
impl<T> Expected for T
Source§fn expected_add(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedAdd,
fn expected_add(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedAdd,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_sub(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedSub,
fn expected_sub(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedSub,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_mul(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedMul,
fn expected_mul(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedMul,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_div(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedDiv,
fn expected_div(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedDiv,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_rem(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedRem,
fn expected_rem(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedRem,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> JsonCastable<CanonicalJsonValue> for T
impl<T> JsonCastable<Value> for T
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
§fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
§fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
§fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
500 Internal Server responses. Read moreSource§impl<T> Tried for T
impl<T> Tried for T
Source§fn try_add(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedAdd,
fn try_add(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedAdd,
rhs with checked arithmetic. Read moreSource§fn try_sub(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedSub,
fn try_sub(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedSub,
rhs with checked arithmetic. Read moreSource§fn try_mul(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedMul,
fn try_mul(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedMul,
rhs with checked arithmetic. Read more