pub(super) struct Namespace {
pub(super) path: PathBuf,
linger: Duration,
requests: Mutex<Option<Sender<Sender<Result<Vec<(IpAddr, Result<TcpStream>)>>>>>>,
pub(super) connect_budget: Budget,
}Expand description
Creates the sockets of a session in its network namespace, which stay in the namespace they got created in. The runtime connects them. A thread enters the namespace and serves the connections which follow within the linger time, then it ends and leaves the namespace, at once when the session ends. Failures are not kept, every connection which fails gets its own error.
Fields§
§path: PathBuf§linger: Duration§requests: Mutex<Option<Sender<Sender<Result<Vec<(IpAddr, Result<TcpStream>)>>>>>>The requests of the thread which got started last.
connect_budget: BudgetWhat the connections which get established hold, see
CONNECT_BUDGET.
Implementations§
Source§impl Namespace
impl Namespace
Sourcepub(super) fn new(path: PathBuf) -> Arc<Self> ⓘ
pub(super) fn new(path: PathBuf) -> Arc<Self> ⓘ
The network namespace at path, whose thread lingers for
SOCKET_THREAD_LINGER.
Sourcepub(super) fn with_linger(path: PathBuf, linger: Duration) -> Arc<Self> ⓘ
pub(super) fn with_linger(path: PathBuf, linger: Duration) -> Arc<Self> ⓘ
The network namespace at path, whose thread lingers for linger.
Sourcepub(super) async fn sockets(&self) -> Result<Vec<(IpAddr, Result<TcpStream>)>>
pub(super) async fn sockets(&self) -> Result<Vec<(IpAddr, Result<TcpStream>)>>
New sockets in the namespace from its thread, which gets started if it ended.
Sourcefn send(
&self,
reply: Sender<Result<Vec<(IpAddr, Result<TcpStream>)>>>,
) -> Result<()>
fn send( &self, reply: Sender<Result<Vec<(IpAddr, Result<TcpStream>)>>>, ) -> Result<()>
Send a request to the thread, which gets started if it ended.
fn lock( &self, ) -> MutexGuard<'_, Option<Sender<Sender<Result<Vec<(IpAddr, Result<TcpStream>)>>>>>>
fn start( &self, ) -> Result<Sender<Sender<Result<Vec<(IpAddr, Result<TcpStream>)>>>>>
Sourcefn serve(
path: &Path,
linger: Duration,
requests: &Receiver<Sender<Result<Vec<(IpAddr, Result<TcpStream>)>>>>,
)
fn serve( path: &Path, linger: Duration, requests: &Receiver<Sender<Result<Vec<(IpAddr, Result<TcpStream>)>>>>, )
Create sockets until no request arrived for the linger time or the session is gone. The thread enters the namespace for its first request, a request which finds it outside of the namespace tries again and gets its own error.
Auto Trait Implementations§
impl !Freeze for Namespace
impl RefUnwindSafe for Namespace
impl Send for Namespace
impl Sync for Namespace
impl Unpin for Namespace
impl UnsafeUnpin for Namespace
impl UnwindSafe for Namespace
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].