net_pool/strategy/
strategy.rs1use crate::backend::{Address, BackendState};
2
3pub trait Strategy: Send + Sync {
5 fn contain(&self, addr: &Address) -> bool;
7
8 fn add_backend(&self, id: Option<u32>, addr: Address);
10
11 fn remove_backend(&self, addr: &Address) -> bool;
13
14 fn get_backend(&self, key: &str) -> Option<BackendState>;
16
17 fn get_backend_by_id(&self, id: u32) -> Option<BackendState>;
19
20 fn get_backend_by_code(&self, code: u64) -> Option<BackendState>;
21
22 fn get_backends(&self) -> Vec<BackendState>;
24
25 fn backend<KEY: AsRef<str>>(this: Box<dyn Strategy>, key: KEY) -> Option<BackendState>
27 where
28 Self: Sized,
29 {
30 this.get_backend(key.as_ref())
31 }
32}