pub struct GatewayConnect {
pub client: Option<BasiliskClient>,
}Expand description
Gateway connection handle. Wraps the connected Basilisk client, if any.
Fields§
§client: Option<BasiliskClient>The connected client. Always Some on instances returned by GatewayConnect::set_up.
Implementations§
Source§impl GatewayConnect
impl GatewayConnect
Sourcepub fn instance() -> Option<Arc<Self>>
pub fn instance() -> Option<Arc<Self>>
Returns the process-wide instance if GatewayConnect::set_up has succeeded.
Sourcepub fn get_client(&self) -> Option<&BasiliskClient>
pub fn get_client(&self) -> Option<&BasiliskClient>
Returns the connected client, or None when there is no connection.
Sourcepub fn require_client(&self) -> Result<&BasiliskClient>
pub fn require_client(&self) -> Result<&BasiliskClient>
Returns the connected client. Errors when there is no connection (e.g. setup was skipped for empty mount paths).
Sourcepub async fn set_up(
mount_paths: Vec<String>,
scheme: impl Into<String>,
weight: i32,
auth_type: impl Into<String>,
) -> Result<Option<Arc<Self>>>
pub async fn set_up( mount_paths: Vec<String>, scheme: impl Into<String>, weight: i32, auth_type: impl Into<String>, ) -> Result<Option<Arc<Self>>>
Registers with the gateway and connects the service bus with exponential-backoff retries.
Reads BASILISK_HOST, BASILISK_BUS_PORT, BASILISK_TOKEN,
BASILISK_GATEWAY_URL, BASILISK_SERVICE_ID, and SERVICE_KEY from
AppEnvironment (falling back to the process
environment), and SERVER_PORT for the service port (defaults to 8080).
mount_paths are registered as the service path prefixes; scheme,
weight, and auth_type go into the registration. Returns Ok(None)
without connecting when mount_paths is empty. Errors when already
initialized, when required env is missing, or after 5 failed connect attempts.
Sourcepub async fn set_up_with_config(
config: BasiliskClientConfig,
) -> Result<Arc<Self>>
pub async fn set_up_with_config( config: BasiliskClientConfig, ) -> Result<Arc<Self>>
Connects with an explicit client config and the same retry policy as GatewayConnect::set_up.
Errors when already initialised or after 5 failed connect attempts.
Sourcepub async fn deregister(&self) -> Result<()>
pub async fn deregister(&self) -> Result<()>
Deregisters this service from the gateway. No-ops when there is no connected client.
Trait Implementations§
Source§impl Clone for GatewayConnect
impl Clone for GatewayConnect
Source§fn clone(&self) -> GatewayConnect
fn clone(&self) -> GatewayConnect
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for GatewayConnect
impl !UnwindSafe for GatewayConnect
impl Freeze for GatewayConnect
impl Send for GatewayConnect
impl Sync for GatewayConnect
impl Unpin for GatewayConnect
impl UnsafeUnpin for GatewayConnect
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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