Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Difference From lstngrp-0.0.3 To lstngrp-0.0.4
2024-10-02
| ||
15:49 | Update change log. check-in: 77a8709ec0 user: jan tags: trunk | |
2024-09-20
| ||
13:04 | Fix docs. check-in: 328cbfb7c7 user: jan tags: lstngrp-0.0.4, trunk | |
12:56 | Update idbag to 0.2.0. check-in: 45e048243f user: jan tags: trunk | |
2024-09-18
| ||
10:23 | Generate links to definition on docs.rs. check-in: ea1e0ea1f0 user: jan tags: trunk | |
10:21 | Release maintenance. check-in: 86bd36e830 user: jan tags: lstngrp-0.0.3, trunk | |
10:13 | Exclude examples from packaging. check-in: 2b0bfea373 user: jan tags: trunk | |
Changes to Cargo.toml.
1 2 | 1 2 3 4 5 6 7 8 9 10 | - + | [package] name = "lstngrp" |
︙ | |||
21 22 23 24 25 26 27 | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | - + + + + | # https://doc.rust-lang.org/cargo/reference/manifest.html#the-badges-section [badges] maintenance = { status = "experimental" } [dependencies] hashbrown = { version = "0.14.5" } |
Changes to examples/per_listener_ctx.rs.
︙ | |||
13 14 15 16 17 18 19 | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | - - + + | use std::{str::FromStr, sync::Arc}; use parking_lot::Mutex; use hashbrown::HashMap; use lstngrp::{ |
︙ | |||
129 130 131 132 133 134 135 | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | - + - - - - + + + + + + + + - - - - + + + + + + + + - - - - + + + + + + + + | // accessible to all the callbacks. let handler = MyHandler { lmap: Arc::clone(&lmap) }; // Create a listener group that will use an instance of MyHandler to process // callbacks. |
︙ | |||
196 197 198 199 200 201 202 | 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | - + | } } */ tokio::time::sleep(std::time::Duration::from_secs(1)).await; |
Changes to examples/simple.rs.
1 2 3 | 1 2 3 4 5 6 7 8 9 10 11 12 | - - + + | use std::str::FromStr; use lstngrp::{ |
︙ | |||
82 83 84 85 86 87 88 | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | - + - + - + - + | #[tokio::main] async fn main() { // Create handler object let handler = MyHandler {}; // Create a listener group that will use an instance of MyHandler to process // callbacks. |
︙ | |||
138 139 140 141 142 143 144 | 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | - + | } } */ tokio::time::sleep(std::time::Duration::from_secs(1)).await; |
Changes to src/conn.rs.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | - + | use std::sync::Arc; use parking_lot::Mutex; use hashbrown::HashMap; use tokio::{sync::oneshot, task::JoinHandle}; pub use protwrap::tokio::server::{ listener::{Acceptor, SockAddr}, Stream }; |
︙ |
Changes to src/lib.rs.
1 2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | - + - - + + - - + + - - + + - + | //! Abstraction over a group of listeners and connections generated by them. //! |
︙ | |||
55 56 57 58 59 60 61 | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | - - + + | use hashbrown::HashMap; pub use protwrap::tokio::server::{ listener::{async_trait, Listener, SockAddr}, Stream }; |
︙ | |||
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + | /// that is relatively fast. When a connection termination request is made /// the termination call will not return to the application until the /// background connection task has terminated. In order to avoid holding up /// the shutdown process, termination should be quick. fn kill(&self); } /// Builder for listeners to be added to a [`ListenGroup`]. pub struct ListenerSpec<LI> { id: LI, listener: Listener, autokill: bool, bound_cb: Option<Box<dyn FnOnce(LI) + Send>> } impl<LI> ListenerSpec<LI> { /// Create a new listener spec. pub fn new(id: LI, listener: Listener) -> Self { Self { id, listener, autokill: false, bound_cb: None } } /// Automatically request that connections terminate once the listener is /// terminated. #[must_use] pub const fn autokill_conns(mut self) -> Self { self.autokill = true; self } /// Add a post-successful-bound callback. /// /// The callback can be useful to register a listener-specific context in the /// listen group handler's object since it is only called on success. This /// way the application does not need to deregister the listener context for /// the failure case. #[must_use] pub fn bound_callback( mut self, f: impl FnOnce(LI) + Send + 'static ) -> Self { self.bound_cb = Some(Box::new(f)); self } } /// Representation of a group of listeners. /// /// Each listener will use the same connection handler. /// /// Generics: /// - `LI` - Listener identifier. Used by the application to uniquely identify /// a specific listener. /// - `CI` - Connection information. Each connection is allicated a connection /// information context. |
︙ | |||
213 214 215 216 217 218 219 | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | - - - - - - + + - + - - + + - + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - | cmap: Arc::new(Mutex::new(HashMap::new())), idbag, shutdown: Arc::new(AtomicBool::new(false)) } } /// Register a new listener within this group. |
︙ | |||
407 408 409 410 411 412 413 | 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 | - + | let lids: Vec<LI> = self .lmap .lock() .iter() .map(|(lid, _)| lid.clone()) .collect(); for lid in lids { |
︙ |
Changes to src/listener.rs.
︙ | |||
18 19 20 21 22 23 24 | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | - + | pub use killswitch::KillSwitch; pub use protwrap::tokio::server::{ listener::{async_trait, Acceptor, Listener, SockAddr}, Stream }; |
︙ | |||
59 60 61 62 63 64 65 | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | - + + + | /// `IdBag` used to allocate unique connection id's. idbag: Arc<IdBag>, /// Optional post-successful-bind callback. cb: Option<Box<dyn FnOnce(LI) + Send>>, |
︙ | |||
87 88 89 90 91 92 93 | 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | - + | let jh = self.jh.take(); // Allocate the buffer used to store listener data in the listners map let ldata = ListenData { ks: self.ks.clone(), jh, addr, |
︙ | |||
156 157 158 159 160 161 162 | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | - + + | { pub(crate) lid: LI, pub(crate) listener: Listener, pub(crate) lmap: Arc<Mutex<HashMap<LI, ListenData>>>, pub(crate) lhandler: Arc<LCHandler<LI, CC>>, pub(crate) cmap: Arc<Mutex<HashMap<ArcId, ConnectionData<LI, CC>>>>, pub(crate) idbag: Arc<IdBag>, |
︙ | |||
190 191 192 193 194 195 196 | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | - + + + - - - - - - + + + + + + + + + - - - - + + + + + + + - + - + + + + | cmap: Arc::clone(<p.cmap), lid: ltp.lid.clone(), ks: ks.clone(), lhandler: Arc::clone(<p.lhandler), idbag: ltp.idbag, cb: Some(Box::new(cb)), jh: Some(jh), |
Changes to www/changelog.md.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | + + + + + + + + + + + + | # Change Log ⚠️ indicates a breaking change. ## [Unreleased] [Details](/vdiff?from=lstngrp-0.0.3&to=trunk) ### Added - Support automatically closing connections when a listener is removed. ### Changed - ⚠️ Rather than have two different functions to add listeners, unify to a single function, and use a builder-type `ListenerSpec` to pass to the `add_listener()` method instead. - Update `idbag` to `0.2.0`. ### Removed - ⚠️ No longer allow `kill_conns` to be specified when killing a listener. Rely on the `ListenerSpec` setting instead. --- ## [0.0.3] - 2024-09-18 [Details](/vdiff?from=lstngrp-0.0.2&to=lstngrp-0.0.3) |
︙ |