Skip to main content

Provider

Trait Provider 

Source
pub trait Provider: Send + Sync {
    // Required methods
    fn capabilities(&self) -> Capabilities;
    fn wake<'a>(
        &'a self,
        deployment: &'a DeploymentRef,
        replicas: u32,
    ) -> BoxFuture<'a, Result<Vec<Endpoint>, ProviderError>>;
    fn release<'a>(
        &'a self,
        replica: &'a ReplicaRef,
        mode: ReleaseMode,
    ) -> BoxFuture<'a, Result<(), ProviderError>>;
    fn list<'a>(
        &'a self,
        deployment: &'a DeploymentRef,
    ) -> BoxFuture<'a, Result<Vec<ReplicaState>, ProviderError>>;

    // Provided method
    fn invoke<'a>(
        &'a self,
        _endpoint: &'a Endpoint,
        _request: InvokeRequest,
    ) -> Option<BoxFuture<'a, Result<InvokeResponse, ProviderError>>> { ... }
}
Expand description

Run-time operations only: wake, release, list. Creating or updating a deployment is graphrt deploy’s job with deploy-time credentials (DeployDriver); the gateway’s credentials can only wake / scale / stop / list.

Contract (checked by the conformance harness):

  • wake(d, n) is idempotent and absolute: it makes at least n replicas of d ready and returns the endpoints of all ready replicas (≥ n). Twenty concurrent wake(d, 1) from zero end with one replica (C1). For Addressing::Url it may be a no-op returning the one URL.
  • release(r, mode) gives back exactly r; releasing a replica that is already gone is Ok. For Addressing::Url it is a no-op.
  • list(d) reports every replica the provider knows for d, including ones the gateway did not start (reconciliation, C5 and C12).
  • Errors are classified (crate::ProviderErrorKind); credentials never appear in errors or logs (C8, C10).

Required Methods§

Source

fn capabilities(&self) -> Capabilities

Static capabilities.

Source

fn wake<'a>( &'a self, deployment: &'a DeploymentRef, replicas: u32, ) -> BoxFuture<'a, Result<Vec<Endpoint>, ProviderError>>

Ensures at least replicas ready replicas and returns their endpoints.

Source

fn release<'a>( &'a self, replica: &'a ReplicaRef, mode: ReleaseMode, ) -> BoxFuture<'a, Result<(), ProviderError>>

Releases one replica (Suspend, Stop or ScaleIn).

Source

fn list<'a>( &'a self, deployment: &'a DeploymentRef, ) -> BoxFuture<'a, Result<Vec<ReplicaState>, ProviderError>>

Lists the replicas of a deployment version for reconciliation.

Provided Methods§

Source

fn invoke<'a>( &'a self, _endpoint: &'a Endpoint, _request: InvokeRequest, ) -> Option<BoxFuture<'a, Result<InvokeResponse, ProviderError>>>

Sends a gateway → agent request through the platform instead of HTTP (see crate::invoke). None (the default) means the endpoint is reached over HTTP at its address.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<P: Provider + ?Sized> Provider for Arc<P>

Source§

fn capabilities(&self) -> Capabilities

Source§

fn wake<'a>( &'a self, deployment: &'a DeploymentRef, replicas: u32, ) -> BoxFuture<'a, Result<Vec<Endpoint>, ProviderError>>

Source§

fn release<'a>( &'a self, replica: &'a ReplicaRef, mode: ReleaseMode, ) -> BoxFuture<'a, Result<(), ProviderError>>

Source§

fn list<'a>( &'a self, deployment: &'a DeploymentRef, ) -> BoxFuture<'a, Result<Vec<ReplicaState>, ProviderError>>

Source§

fn invoke<'a>( &'a self, endpoint: &'a Endpoint, request: InvokeRequest, ) -> Option<BoxFuture<'a, Result<InvokeResponse, ProviderError>>>

Implementors§