Compose cold-start resources under Runtime Supervisor ownership
This commit is contained in:
parent
510dfccf5a
commit
33ac0ba4ee
1 changed files with 1827 additions and 139 deletions
|
|
@ -45,6 +45,18 @@ pub trait LifecycleAdapter {
|
|||
action: LifecycleAction,
|
||||
generation: &Generation,
|
||||
) -> Result<(), Self::Error>;
|
||||
|
||||
/// Completes a physical boundary that must follow its durable lifecycle commit.
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns the adapter's post-commit publication or cleanup failure.
|
||||
fn after_commit(
|
||||
&mut self,
|
||||
_action: LifecycleAction,
|
||||
_generation: &Generation,
|
||||
) -> Result<(), Self::Error> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
|
|
@ -209,6 +221,16 @@ where
|
|||
self.registered.len()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn adapter(&self) -> &A {
|
||||
&self.adapter
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn adapter_mut(&mut self) -> &mut A {
|
||||
&mut self.adapter
|
||||
}
|
||||
|
||||
/// # Errors
|
||||
/// Refuses a non-absent Domain, invalid initial records, or adapter/store failure.
|
||||
pub fn start_new_domain(
|
||||
|
|
@ -251,6 +273,28 @@ where
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Drives one cold-start leader through the complete normal publication boundary.
|
||||
///
|
||||
/// # Errors
|
||||
/// Returns the first invalid transition, durable update, or production adapter failure.
|
||||
pub fn bootstrap_new_domain(
|
||||
&mut self,
|
||||
generation: Generation,
|
||||
session: Session,
|
||||
) -> Result<(), LifecycleError<A::Error>> {
|
||||
self.start_new_domain(generation, session)?;
|
||||
self.create_trust_anchor()?;
|
||||
self.start_runtime_supervisor()?;
|
||||
self.lease_prepared_lower()?;
|
||||
self.mount_state_anchor()?;
|
||||
self.start_sidecar()?;
|
||||
self.start_connectivity_helper()?;
|
||||
self.mark_network_ready()?;
|
||||
self.arm_runtime_causal_edge()?;
|
||||
self.start_sandbox()?;
|
||||
self.publish_domain()
|
||||
}
|
||||
|
||||
/// # Errors
|
||||
/// Refuses an unpublished, stale, mismatched, duplicate, or unauthenticated session.
|
||||
pub fn admit_session(
|
||||
|
|
@ -529,7 +573,16 @@ where
|
|||
generation.durable_decision = DurableDecision::Published;
|
||||
self.store
|
||||
.apply(&[DomainStoreMutation::PutGeneration(generation.clone())])?;
|
||||
self.generation = Some(generation);
|
||||
self.generation = Some(generation.clone());
|
||||
if let Err(error) = self
|
||||
.adapter
|
||||
.after_commit(LifecycleAction::PublishDomain, &generation)
|
||||
{
|
||||
self.phase = DomainPhase::Failed;
|
||||
self.bootstrap_owner = None;
|
||||
self.published = false;
|
||||
return Err(LifecycleError::Adapter(error));
|
||||
}
|
||||
self.phase = DomainPhase::Ready;
|
||||
self.bootstrap_owner = None;
|
||||
self.published = true;
|
||||
|
|
|
|||
Loading…
Reference in a new issue