pub struct GuardedClient { /* private fields */ }Expand description
Go guardedPluginClient.
Implementations§
Source§impl GuardedClient
impl GuardedClient
pub fn new( inner: Arc<dyn PluginClient>, instance: Arc<CallbackInstance>, ) -> Arc<Self> ⓘ
pub fn instance(&self) -> &Arc<CallbackInstance> ⓘ
Sourcepub async fn call(
self: &Arc<Self>,
method: &str,
request: Vec<u8>,
) -> Result<Bytes, GuardError>
pub async fn call( self: &Arc<Self>, method: &str, request: Vec<u8>, ) -> Result<Bytes, GuardError>
Runs one call on the blocking pool.
Sourcepub fn call_blocking(
self: &Arc<Self>,
method: &str,
request: &[u8],
) -> Result<Bytes, GuardError>
pub fn call_blocking( self: &Arc<Self>, method: &str, request: &[u8], ) -> Result<Bytes, GuardError>
GuardedClient::call for synchronous callers (translator hooks and thinking
appliers run inside the translation that needs them, as Go’s do). The call runs
on this thread, inside block_in_place on a multi-threaded runtime so plugin
callbacks may block on it. From a current-thread runtime it runs on a scoped
thread while the runtime waits, so callbacks that need the runtime
(host.http.*, host.model.*) fail during the call instead of hanging.
Sourcepub fn call_blocking_in<G>(
self: &Arc<Self>,
method: &str,
request: &[u8],
scope: impl FnOnce() -> G + Send,
) -> Result<Bytes, GuardError>
pub fn call_blocking_in<G>( self: &Arc<Self>, method: &str, request: &[u8], scope: impl FnOnce() -> G + Send, ) -> Result<Bytes, GuardError>
Self::call_blocking with scope entered, for the call’s duration, on the
thread that makes the plugin call: from a current-thread runtime that is not this
thread, and a native plugin’s synchronous callbacks arrive on it.
Sourcepub async fn shutdown(self: &Arc<Self>, wait: Option<Duration>)
pub async fn shutdown(self: &Arc<Self>, wait: Option<Duration>)
Detaches the client at once, then waits up to wait for running calls to drain
and the plugin to shut down. Shutdown itself always completes on a dedicated
thread (Go ShutdownContext). None waits indefinitely.
Sourcepub fn is_shut_down(&self) -> bool
pub fn is_shut_down(&self) -> bool
Whether shutdown has finished (the library is closed).
pub fn active_calls(&self) -> usize
Auto Trait Implementations§
impl !Freeze for GuardedClient
impl !RefUnwindSafe for GuardedClient
impl !UnwindSafe for GuardedClient
impl Forget for GuardedClient
impl Move for GuardedClient
impl Send for GuardedClient
impl Sync for GuardedClient
impl Unpin for GuardedClient
impl UnsafeUnpin for GuardedClient
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
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 more