Struct quilkin::components::proxy::SessionPool
source · pub struct SessionPool { /* private fields */ }
Expand description
A data structure that is responsible for holding sessions, and pooling sockets between them. This means that we only provide new unique sockets to new connections to the same gameserver, and we share sockets across multiple gameservers.
Traffic from different gameservers is then demuxed using their address to send back to the original client.
Implementations§
source§impl SessionPool
impl SessionPool
sourcepub fn new(
config: Arc<Config>,
downstream_sender: Sender<(PoolBuffer, Option<IpNetEntry>, SocketAddr)>,
buffer_pool: Arc<BufferPool>,
shutdown_rx: ShutdownRx
) -> Arc<Self>
pub fn new( config: Arc<Config>, downstream_sender: Sender<(PoolBuffer, Option<IpNetEntry>, SocketAddr)>, buffer_pool: Arc<BufferPool>, shutdown_rx: ShutdownRx ) -> Arc<Self>
Constructs a new session pool, it’s created with an Arc
as that’s
required for the pool to provide a reference to the children to be able
to release their sockets back to the parent.
sourcepub async fn get<'pool>(
self: &'pool Arc<Self>,
key: SessionKey,
asn_info: Option<IpNetEntry>
) -> Result<Sender<(FrozenPoolBuffer, Option<IpNetEntry>, SocketAddr)>, PipelineError>
pub async fn get<'pool>( self: &'pool Arc<Self>, key: SessionKey, asn_info: Option<IpNetEntry> ) -> Result<Sender<(FrozenPoolBuffer, Option<IpNetEntry>, SocketAddr)>, PipelineError>
Returns a reference to an existing session mapped to key
, otherwise
creates a new session either from a fresh socket, or if there are sockets
allocated that are not reserved by an existing destination, using the
existing socket.
sourcepub async fn send(
self: &Arc<Self>,
key: SessionKey,
asn_info: Option<IpNetEntry>,
packet: FrozenPoolBuffer
) -> Result<(), PipelineError>
pub async fn send( self: &Arc<Self>, key: SessionKey, asn_info: Option<IpNetEntry>, packet: FrozenPoolBuffer ) -> Result<(), PipelineError>
Sends packet data to the appropiate session based on its key
.
Trait Implementations§
source§impl Debug for SessionPool
impl Debug for SessionPool
Auto Trait Implementations§
impl !RefUnwindSafe for SessionPool
impl Send for SessionPool
impl Sync for SessionPool
impl Unpin for SessionPool
impl !UnwindSafe for SessionPool
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request