pub struct WaitUntilContext { /* private fields */ }Expand description
A context for managing wait_until tasks within an application. This handles local task execution and coordinates with the runtime via gRPC.
Implementations§
Source§impl WaitUntilContext
impl WaitUntilContext
Sourcepub fn new(application_id: Option<String>) -> WaitUntilContext
pub fn new(application_id: Option<String>) -> WaitUntilContext
Creates a new WaitUntilContext.
Sourcepub async fn from_env(
application_id: Option<String>,
) -> Result<WaitUntilContext, AlienError<ErrorData>>
pub async fn from_env( application_id: Option<String>, ) -> Result<WaitUntilContext, AlienError<ErrorData>>
Creates a new WaitUntilContext and connects to gRPC endpoint from environment variables. This is the recommended way to create a WaitUntilContext in production.
Sourcepub async fn from_env_with_vars(
application_id: Option<String>,
env_vars: &HashMap<String, String>,
) -> Result<WaitUntilContext, AlienError<ErrorData>>
pub async fn from_env_with_vars( application_id: Option<String>, env_vars: &HashMap<String, String>, ) -> Result<WaitUntilContext, AlienError<ErrorData>>
Creates a new WaitUntilContext and connects to gRPC endpoint from provided environment variables.
Sourcepub fn new_with_grpc_client(
application_id: Option<String>,
grpc_client: WaitUntilServiceClient<Channel>,
) -> WaitUntilContext
pub fn new_with_grpc_client( application_id: Option<String>, grpc_client: WaitUntilServiceClient<Channel>, ) -> WaitUntilContext
Creates a new WaitUntilContext with a gRPC client.
Sourcepub fn set_grpc_client(&mut self, client: WaitUntilServiceClient<Channel>)
pub fn set_grpc_client(&mut self, client: WaitUntilServiceClient<Channel>)
Sets the gRPC client for communicating with the runtime.
Sourcepub fn application_id(&self) -> &str
pub fn application_id(&self) -> &str
Gets the application ID.
Sourcepub async fn start_drain_listener(&self) -> Result<(), AlienError<ErrorData>>
pub async fn start_drain_listener(&self) -> Result<(), AlienError<ErrorData>>
Starts a background task that waits for drain signals from the runtime. This should be called once when the application starts.
Source§impl WaitUntilContext
impl WaitUntilContext
Sourcepub fn wait_until<F, Fut>(
&self,
task_fn: F,
) -> Result<(), AlienError<ErrorData>>
pub fn wait_until<F, Fut>( &self, task_fn: F, ) -> Result<(), AlienError<ErrorData>>
Registers a new wait_until task that will be executed immediately. The task runs in the application process but is tracked by the runtime.
Trait Implementations§
Source§impl Debug for WaitUntilContext
impl Debug for WaitUntilContext
Source§impl WaitUntil for WaitUntilContext
impl WaitUntil for WaitUntilContext
Source§fn wait_for_drain_signal<'life0, 'async_trait>(
&'life0 self,
timeout_duration: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<DrainConfig, AlienError<ErrorData>>> + Send + 'async_trait>>where
'life0: 'async_trait,
WaitUntilContext: 'async_trait,
fn wait_for_drain_signal<'life0, 'async_trait>(
&'life0 self,
timeout_duration: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<DrainConfig, AlienError<ErrorData>>> + Send + 'async_trait>>where
'life0: 'async_trait,
WaitUntilContext: 'async_trait,
Source§fn drain_all<'life0, 'async_trait>(
&'life0 self,
config: DrainConfig,
) -> Pin<Box<dyn Future<Output = Result<DrainResponse, AlienError<ErrorData>>> + Send + 'async_trait>>where
'life0: 'async_trait,
WaitUntilContext: 'async_trait,
fn drain_all<'life0, 'async_trait>(
&'life0 self,
config: DrainConfig,
) -> Pin<Box<dyn Future<Output = Result<DrainResponse, AlienError<ErrorData>>> + Send + 'async_trait>>where
'life0: 'async_trait,
WaitUntilContext: 'async_trait,
Source§fn get_task_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u32, AlienError<ErrorData>>> + Send + 'async_trait>>where
'life0: 'async_trait,
WaitUntilContext: 'async_trait,
fn get_task_count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u32, AlienError<ErrorData>>> + Send + 'async_trait>>where
'life0: 'async_trait,
WaitUntilContext: 'async_trait,
Source§fn notify_drain_complete<'life0, 'async_trait>(
&'life0 self,
response: DrainResponse,
) -> Pin<Box<dyn Future<Output = Result<(), AlienError<ErrorData>>> + Send + 'async_trait>>where
'life0: 'async_trait,
WaitUntilContext: 'async_trait,
fn notify_drain_complete<'life0, 'async_trait>(
&'life0 self,
response: DrainResponse,
) -> Pin<Box<dyn Future<Output = Result<(), AlienError<ErrorData>>> + Send + 'async_trait>>where
'life0: 'async_trait,
WaitUntilContext: 'async_trait,
impl Binding for WaitUntilContext
Auto Trait Implementations§
impl !Freeze for WaitUntilContext
impl !RefUnwindSafe for WaitUntilContext
impl Send for WaitUntilContext
impl Sync for WaitUntilContext
impl Unpin for WaitUntilContext
impl UnsafeUnpin for WaitUntilContext
impl !UnwindSafe for WaitUntilContext
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
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