MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / register

Method register

nodedb/src/control/array_sync/outbound/subscriber_state.rs:94–112  ·  view source on GitHub ↗

Register a new subscriber (or restore an existing one from the store). Returns the current `ArraySubscriberState` (may have a non-ZERO `last_pushed_hlc` if the subscriber previously connected).

(
        &self,
        session_id: &str,
        array_name: &str,
        coord_range: Option<ArrayCoordRange>,
    )

Source from the content-addressed store, hash-verified

92 /// Returns the current `ArraySubscriberState` (may have a non-ZERO
93 /// `last_pushed_hlc` if the subscriber previously connected).
94 pub fn register(
95 &self,
96 session_id: &str,
97 array_name: &str,
98 coord_range: Option<ArrayCoordRange>,
99 ) -> ArraySubscriberState {
100 let key = (session_id.to_string(), array_name.to_string());
101
102 // Check persistent store for an existing cursor.
103 let persisted = self.store.load(session_id, array_name);
104
105 let state = persisted.unwrap_or_else(|| {
106 ArraySubscriberState::new(session_id.to_string(), array_name.to_string(), coord_range)
107 });
108
109 let mut map = self.inner.write().unwrap_or_else(|p| p.into_inner());
110 map.insert(key, state.clone());
111 state
112 }
113
114 /// Update the cursor for `(session_id, array_name)` to `new_hlc`.
115 ///

Calls 5

to_stringMethod · 0.80
loadMethod · 0.45
writeMethod · 0.45
insertMethod · 0.45
cloneMethod · 0.45