Struct Pool

Source
pub struct Pool { /* private fields */ }
Expand description

udp连接池 连接池中的连接受max_conn数据限制 默认的keepalive是5分钟 有两种行为会导致连接池中的连接被释放 1. remove_backend被调用清除后端地址, 这会导致该地址的所有连接失效 2. 连接keepalive时间后没有数据发送

Implementations§

Source§

impl Pool

Source

pub fn new(strategy: Arc<dyn LbStrategy>) -> Self

Trait Implementations§

Source§

impl Default for Pool

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<L: LbStrategy + 'static> From<L> for Pool

Source§

fn from(value: L) -> Self

Converts to this type from the input type.
Source§

impl Pool for Pool

Source§

fn set_max_conn(&self, max: Option<usize>)

设置最大连接数
Source§

fn get_max_conn(&self) -> Option<usize>

获取最大连接数
Source§

fn get_cur_conn(&self) -> usize

获取当前的连接数
Source§

fn set_keepalive(&self, duration: Option<Duration>)

设置空闲连接保留时长
Source§

fn get_keepalive(&self) -> Option<Duration>

获取空闲连接保留时长
Source§

fn get_strategy(&self) -> Arc<dyn LbStrategy>

获取转发策略
Source§

fn remove_backend(&self, addr: &Address) -> bool

移除一个后端地址
Source§

fn id(&self) -> &str

id
Source§

fn add_backend(&self, addr: Address)

添加一个后端地址
Source§

fn get_backends(&self) -> Vec<BackendState>

获取所有后端地址切片
Source§

fn use_tls(&self, _: bool)

Source§

fn tls(&self) -> bool

Source§

impl UdpPool for Pool

Source§

async fn get( self: Arc<Self>, a: SocketAddr, send: Option<Arc<UdpSocket>>, ) -> Result<Sender, Error>

Auto Trait Implementations§

§

impl !Freeze for Pool

§

impl !RefUnwindSafe for Pool

§

impl Send for Pool

§

impl Sync for Pool

§

impl Unpin for Pool

§

impl !UnwindSafe for Pool

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.