Struct mz_compute_client::controller::ComputeController
source · pub struct ComputeController<T> {
instances: BTreeMap<ComputeInstanceId, Instance<T>>,
build_info: &'static BuildInfo,
initialized: bool,
config: ComputeParameters,
stashed_response: Option<(ComputeInstanceId, ReplicaId, ComputeResponse<T>)>,
replica_heartbeats: BTreeMap<ReplicaId, DateTime<Utc>>,
replica_metrics: BTreeMap<ReplicaId, Vec<ServiceProcessMetrics>>,
envd_epoch: NonZeroI64,
stats_update_ticker: Interval,
stats_update_pending: bool,
metrics: ComputeControllerMetrics,
}
Expand description
A controller for the compute layer.
Fields§
§instances: BTreeMap<ComputeInstanceId, Instance<T>>
§build_info: &'static BuildInfo
§initialized: bool
Set to true
once initialization_complete
has been called.
config: ComputeParameters
Compute configuration to apply to new instances.
stashed_response: Option<(ComputeInstanceId, ReplicaId, ComputeResponse<T>)>
A response to handle on the next call to ActiveComputeController::process
.
replica_heartbeats: BTreeMap<ReplicaId, DateTime<Utc>>
Times we have last received responses from replicas.
replica_metrics: BTreeMap<ReplicaId, Vec<ServiceProcessMetrics>>
§envd_epoch: NonZeroI64
A number that increases on every environmentd
restart.
stats_update_ticker: Interval
Periodic notification to produce a ReplicaWriteFrontiers
response.
stats_update_pending: bool
Set to true
if process
should produce a ReplicaWriteFrontiers
next.
metrics: ComputeControllerMetrics
The compute controller metrics
Implementations§
source§impl<T> ComputeController<T>
impl<T> ComputeController<T>
sourcepub fn new(
build_info: &'static BuildInfo,
envd_epoch: NonZeroI64,
metrics_registry: MetricsRegistry
) -> Self
pub fn new(
build_info: &'static BuildInfo,
envd_epoch: NonZeroI64,
metrics_registry: MetricsRegistry
) -> Self
Construct a new ComputeController
.
pub fn instance_exists(&self, id: ComputeInstanceId) -> bool
sourcefn instance(
&self,
id: ComputeInstanceId
) -> Result<&Instance<T>, InstanceMissing>
fn instance(
&self,
id: ComputeInstanceId
) -> Result<&Instance<T>, InstanceMissing>
Return a reference to the indicated compute instance.
sourcefn instance_mut(
&mut self,
id: ComputeInstanceId
) -> Result<&mut Instance<T>, InstanceMissing>
fn instance_mut(
&mut self,
id: ComputeInstanceId
) -> Result<&mut Instance<T>, InstanceMissing>
Return a mutable reference to the indicated compute instance.
sourcepub fn instance_ref(
&self,
id: ComputeInstanceId
) -> Result<ComputeInstanceRef<'_, T>, InstanceMissing>
pub fn instance_ref(
&self,
id: ComputeInstanceId
) -> Result<ComputeInstanceRef<'_, T>, InstanceMissing>
Return a read-only handle to the indicated compute instance.
sourcepub fn collection(
&self,
instance_id: ComputeInstanceId,
collection_id: GlobalId
) -> Result<&CollectionState<T>, CollectionLookupError>
pub fn collection(
&self,
instance_id: ComputeInstanceId,
collection_id: GlobalId
) -> Result<&CollectionState<T>, CollectionLookupError>
Return a read-only handle to the indicated collection.
sourcepub fn activate<'a>(
&'a mut self,
storage: &'a mut dyn StorageController<Timestamp = T>
) -> ActiveComputeController<'a, T>
pub fn activate<'a>(
&'a mut self,
storage: &'a mut dyn StorageController<Timestamp = T>
) -> ActiveComputeController<'a, T>
Acquire an ActiveComputeController
by supplying a storage connection.
source§impl<T> ComputeController<T>where
T: Timestamp + Lattice,
ComputeGrpcClient: ComputeClient<T>,
impl<T> ComputeController<T>where
T: Timestamp + Lattice,
ComputeGrpcClient: ComputeClient<T>,
sourcepub fn create_instance(
&mut self,
id: ComputeInstanceId,
arranged_logs: BTreeMap<LogVariant, GlobalId>
) -> Result<(), InstanceExists>
pub fn create_instance(
&mut self,
id: ComputeInstanceId,
arranged_logs: BTreeMap<LogVariant, GlobalId>
) -> Result<(), InstanceExists>
Create a compute instance.
sourcepub fn drop_instance(&mut self, id: ComputeInstanceId)
pub fn drop_instance(&mut self, id: ComputeInstanceId)
sourcepub fn update_configuration(&mut self, config_params: ComputeParameters)
pub fn update_configuration(&mut self, config_params: ComputeParameters)
Update compute configuration.
sourcepub fn initialization_complete(&mut self)
pub fn initialization_complete(&mut self)
Mark the end of any initialization commands.
The implementor may wait for this method to be called before implementing prior commands, and so it is important for a user to invoke this method as soon as it is comfortable. This method can be invoked immediately, at the potential expense of performance.
sourcepub async fn ready(&mut self)
pub async fn ready(&mut self)
Wait until the controller is ready to do some processing.
This method may block for an arbitrarily long time.
When the method returns, the caller should call ActiveComputeController::process
.
This method is cancellation safe.
sourcepub fn set_subscribe_target_replica(
&mut self,
instance_id: ComputeInstanceId,
subscribe_id: GlobalId,
target_replica: ReplicaId
) -> Result<(), SubscribeTargetError>
pub fn set_subscribe_target_replica(
&mut self,
instance_id: ComputeInstanceId,
subscribe_id: GlobalId,
target_replica: ReplicaId
) -> Result<(), SubscribeTargetError>
Assign a target replica to the identified subscribe.
If a subscribe has a target replica assigned, only subscribe responses sent by that replica are considered.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for ComputeController<T>
impl<T> Send for ComputeController<T>where
T: Send,
impl<T> Sync for ComputeController<T>where
T: Send + Sync,
impl<T> Unpin for ComputeController<T>where
T: Unpin,
impl<T> !UnwindSafe for ComputeController<T>
Blanket Implementations§
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> 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
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.