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>,
)
| 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 | /// |