ServiceCommand

Enum ServiceCommand 

Source
pub enum ServiceCommand<F, LF> {
    Precommit(Arc<String>, F),
    Update(Arc<String>),
    Commit(Arc<String>, LF),
    PrepareAndCommit(Arc<String>, F, LF),
    Abort(Arc<String>),
    Remove(Arc<String>),
}
Expand description

Represents commands for managing service deployment in a worker.

This enum encapsulates the various operations that can be performed on services, supporting both two-stage and one-stage deployment processes. It works in conjunction with the ServiceExecutor to facilitate the lifecycle management of services.

The commands align with the concepts introduced in the service_async crate, particularly leveraging the AsyncMakeService trait for efficient service creation and updates.

§Type Parameters

  • F: The service factory type, typically implementing AsyncMakeService.
  • LF: The listener factory type, used for creating service listeners.

§Deployment Models

§Two-Stage Deployment

This model allows for state transfer and careful preparation before deployment:

  1. Precommit: Prepare a service for deployment.
  2. Either Update or Commit: Complete the deployment.

§One-Stage Deployment

This model creates and deploys a service in a single step:

Each variant of this enum represents a specific action in the service lifecycle, providing fine-grained control over service deployment and management.

Variants§

§

Precommit(Arc<String>, F)

Precommits a service for deployment without actually deploying it.

This is the first step in a two-stage deployment process. It leverages the make_via_ref method of AsyncMakeService to potentially transfer state from an existing service instance.

§Arguments

  • Arc<String> - The identifier for the service.
  • F - The factory for creating the service, typically implementing AsyncMakeService.
§

Update(Arc<String>)

Updates an existing deployed service with the version that was previously precommitted.

This is the second step in a two-stage deployment process for updating existing services. It allows for a seamless transition from the old service instance to the new one, potentially preserving state and resources.

§Arguments

  • Arc<String> - The identifier for the service to update.
§

Commit(Arc<String>, LF)

Commits a previously precommitted service for the first time.

This is the second step in a two-stage deployment process for new services. It’s used when a new service has been precommitted and needs to be activated with its corresponding listener.

§Arguments

  • Arc<String> - The identifier for the service to commit.
  • LF - The listener factory for the service.
§

PrepareAndCommit(Arc<String>, F, LF)

Prepares and commits a service in a single operation.

This is used for the one-stage deployment process, suitable for initial deployments or when state preservation isn’t necessary. It combines service creation and listener setup in one step.

§Arguments

  • Arc<String> - The identifier for the service.
  • F - The factory for creating the service.
  • LF - The listener factory for the service.
§

Abort(Arc<String>)

Aborts the precommit process, removing any precommitted service that hasn’t been deployed.

This is useful for cleaning up precommitted services that are no longer needed or were prepared incorrectly.

§Arguments

  • Arc<String> - The identifier for the precommitted service to abort.
§

Remove(Arc<String>)

Removes a deployed service entirely.

This directive is used to completely remove a service from the system, cleaning up all associated resources.

§Arguments

  • Arc<String> - The identifier for the service to remove.

Trait Implementations§

Source§

impl<F: Clone, LF: Clone> Clone for ServiceCommand<F, LF>

Source§

fn clone(&self) -> ServiceCommand<F, LF>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F, LF, A, E, S> Execute<A, S> for ServiceCommand<F, LF>
where F: AsyncMakeService<Service = S>, F::Error: Debug + Send + Sync + 'static, LF: AsyncMakeService, LF::Service: Stream<Item = Result<A, E>> + 'static, E: Debug + Send + Sync + 'static, LF::Error: Debug + Send + Sync + 'static, S: Service<A> + 'static, S::Error: Debug, A: 'static,

Source§

type Error = CommandError<<F as AsyncMakeService>::Error, <LF as AsyncMakeService>::Error>

Source§

async fn execute( self, controller: &ServiceExecutor<S>, ) -> Result<(), Self::Error>

Auto Trait Implementations§

§

impl<F, LF> Freeze for ServiceCommand<F, LF>
where F: Freeze, LF: Freeze,

§

impl<F, LF> RefUnwindSafe for ServiceCommand<F, LF>

§

impl<F, LF> Send for ServiceCommand<F, LF>
where F: Send, LF: Send,

§

impl<F, LF> Sync for ServiceCommand<F, LF>
where F: Sync, LF: Sync,

§

impl<F, LF> Unpin for ServiceCommand<F, LF>
where F: Unpin, LF: Unpin,

§

impl<F, LF> UnwindSafe for ServiceCommand<F, LF>
where F: UnwindSafe, LF: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Param<T> for T
where T: Clone,

Source§

fn param(&self) -> T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more