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 implementingAsyncMakeService.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:
§One-Stage Deployment
This model creates and deploys a service in a single step:
PrepareAndCommit: Directly create and deploy a service.
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 implementingAsyncMakeService.
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>
impl<F: Clone, LF: Clone> Clone for ServiceCommand<F, LF>
Source§fn clone(&self) -> ServiceCommand<F, LF>
fn clone(&self) -> ServiceCommand<F, LF>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more