pub struct Scheduler<Creds> { /* private fields */ }
Expand description
A scheduler client to interact with the scheduler service. It has different implementations depending on the implementations
Implementations§
Source§impl<Creds> Scheduler<Creds>where
Creds: TlsConfigProvider,
impl<Creds> Scheduler<Creds>where
Creds: TlsConfigProvider,
Sourcepub async fn new(network: Network, creds: Creds) -> Result<Scheduler<Creds>>
pub async fn new(network: Network, creds: Creds) -> Result<Scheduler<Creds>>
Creates a new scheduler client with the provided parameters. A scheduler created this way is considered unauthenticated and limited in its scope.
§Example
let node_id = vec![0, 1, 2, 3];
let network = Network::Regtest;
let creds = Nobody::new();
let scheduler = Scheduler::new(network, creds).await.unwrap();
Sourcepub async fn with(
network: Network,
creds: Creds,
uri: impl Into<String>,
) -> Result<Scheduler<Creds>>
pub async fn with( network: Network, creds: Creds, uri: impl Into<String>, ) -> Result<Scheduler<Creds>>
Creates a new scheduler client with the provided parameters and custom URI. A scheduler created this way is considered unauthenticated and limited in its scope.
§Example
let node_id = vec![0, 1, 2, 3];
let network = Network::Regtest;
let creds = Nobody::new();
let uri = "https://example.com".to_string();
let scheduler = Scheduler::with(network, creds, uri).await.unwrap();
Source§impl<Creds> Scheduler<Creds>
impl<Creds> Scheduler<Creds>
Sourcepub async fn register(
&self,
signer: &Signer,
invite_code: Option<String>,
) -> Result<RegistrationResponse>
pub async fn register( &self, signer: &Signer, invite_code: Option<String>, ) -> Result<RegistrationResponse>
Registers a new node with the scheduler service.
§Arguments
signer
- The signer instance bound to the node.invite_code
- Optional invite code to register the node.
§Example
let node_id = vec![0, 1, 2, 3];
let network = Network::Regtest;
let creds = Nobody::new();
let scheduler = Scheduler::new(network, creds.clone()).await.unwrap();
let secret = vec![0, 0, 0, 0];
let signer = Signer::new(secret, network, creds).unwrap(); // Create or obtain a signer instance
let registration_response = scheduler.register(&signer, None).await.unwrap();
Sourcepub async fn recover(&self, signer: &Signer) -> Result<RecoveryResponse>
pub async fn recover(&self, signer: &Signer) -> Result<RecoveryResponse>
Recovers a previously registered node with the scheduler service.
§Arguments
signer
- The signer instance used to sign the recovery challenge.
§Example
let node_id = vec![0, 1, 2, 3];
let network = Network::Regtest;
let creds = Nobody::new();
let scheduler = Scheduler::new(network, creds.clone()).await.unwrap();
let secret = vec![0, 0, 0, 0];
let signer = Signer::new(secret, network, creds).unwrap(); // Create or obtain a signer instance
let recovery_response = scheduler.recover(&signer).await.unwrap();
Sourcepub async fn authenticate<Auth>(&self, creds: Auth) -> Result<Scheduler<Auth>>where
Auth: TlsConfigProvider + RuneProvider,
pub async fn authenticate<Auth>(&self, creds: Auth) -> Result<Scheduler<Auth>>where
Auth: TlsConfigProvider + RuneProvider,
Elevates the scheduler client to an authenticated scheduler client that is able to schedule a node for example.
§Arguments
creds
- Credentials that carry a TlsConfig and a Rune. These are credentials returned during registration or recovery.
§Example
let node_id = vec![0, 1, 2, 3];
let network = Network::Regtest;
let creds = Nobody::new();
let scheduler_unauthed = Scheduler::new(network, creds.clone()).await.unwrap();
let secret = vec![0, 0, 0, 0];
let signer = Signer::new(secret, network, creds).unwrap(); // Create or obtain a signer instance
let registration_response = scheduler_unauthed.register(&signer, None).await.unwrap();
let creds = Device::from_bytes(registration_response.creds);
let scheduler_authed = scheduler_unauthed.authenticate(creds);
Source§impl<Creds> Scheduler<Creds>
impl<Creds> Scheduler<Creds>
Sourcepub async fn schedule(&self) -> Result<NodeInfoResponse>
pub async fn schedule(&self) -> Result<NodeInfoResponse>
Schedules a node at the scheduler service. Once a node is scheduled one can access it through the node client.
§Example
let node_id = vec![0, 1, 2, 3];
let network = Network::Regtest;
let creds = Device::from_path("my/path/to/credentials.glc");
let scheduler = Scheduler::new(network, creds.clone()).await.unwrap();
let info = scheduler.schedule().await.unwrap();
let node_client: Client = Node::new(node_id, creds).unwrap().connect(info.grpc_uri).await.unwrap();
Sourcepub async fn node<T>(&self) -> Result<T>where
T: GrpcClient,
pub async fn node<T>(&self) -> Result<T>where
T: GrpcClient,
Schedules a node at the scheduler service and returns a node client.
§Example
let node_id = vec![0, 1, 2, 3];
let network = Network::Regtest;
let creds = Device::from_path("my/path/to/credentials.glc");
let scheduler = Scheduler::new(network, creds.clone()).await.unwrap();
let node_client: Client = scheduler.node().await.unwrap();
pub async fn get_node_info(&self, wait: bool) -> Result<NodeInfoResponse>
pub async fn export_node(&self) -> Result<ExportNodeResponse>
pub async fn get_invite_codes(&self) -> Result<ListInviteCodesResponse>
pub async fn add_outgoing_webhook( &self, uri: String, ) -> Result<AddOutgoingWebhookResponse>
pub async fn list_outgoing_webhooks( &self, ) -> Result<ListOutgoingWebhooksResponse>
pub async fn delete_webhooks(&self, webhook_ids: Vec<i64>) -> Result<Empty>
pub async fn rotate_outgoing_webhook_secret( &self, webhook_id: i64, ) -> Result<WebhookSecretResponse>
Trait Implementations§
Auto Trait Implementations§
impl<Creds> !Freeze for Scheduler<Creds>
impl<Creds> !RefUnwindSafe for Scheduler<Creds>
impl<Creds> Send for Scheduler<Creds>where
Creds: Send,
impl<Creds> Sync for Scheduler<Creds>where
Creds: Sync,
impl<Creds> Unpin for Scheduler<Creds>where
Creds: Unpin,
impl<Creds> !UnwindSafe for Scheduler<Creds>
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> Downcast for T
impl<T> Downcast for 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