Skip to main content

NamespaceMinter

Struct NamespaceMinter 

Source
pub struct NamespaceMinter { /* private fields */ }
Expand description

Minted-on-use hook pairing the durable namespace registry with its AutoCreate policy.

Holds an Arc<dyn NamespaceStore> and the policy, so it is cheap to clone and share between the worker-registration and workflow-start mint seams. The hook is the only place the auto-create policy is implemented; both seams call NamespaceMinter::mint_or_gate, so the behaviour can never diverge across transports or call sites.

Implementations§

Source§

impl NamespaceMinter

Source

pub fn new(store: Arc<dyn NamespaceStore>, policy: AutoCreate) -> Self

Build a minter over a durable namespace store and an auto-create policy.

Source

pub fn with_routing(self, routing: NamespaceRouting) -> Self

Attach the namespace-mint routing context a clustered boot builds, so a namespace whose registry shard this node does not own is minted by the node that does instead of being fenced forever.

Pure builder addition: without it the minter mints locally exactly as before, which is what every single-node boot and every unit test does.

Source

pub fn without_routing(self) -> Self

Drop the routing context, pinning every mint to THIS node.

Used by the owner-side MintNamespace handler: a mint that already travelled must not travel again, so an arrival whose shard has moved on is answered with the local fence’s typed refusal rather than a re-forward chain. The refusal returns to the initiator, which surfaces it; nothing retries internally.

Source

pub fn with_caller_credentials(self, credentials: MintCredentials) -> Self

Carry the inbound request’s caller credentials onto any forwarded mint, so the owning node authorizes the caller exactly as this node did.

A no-op with no routing context attached (nothing can be forwarded).

Source

pub fn with_cluster_publisher(self, publisher: ClusterEventPublisher) -> Self

Attach the WS3 cluster-event publisher so a first mint pushes a live namespace created delta to the ops console (Control-Plane Phase 1, S8).

Pure builder addition: without it the minter behaves exactly as before (durable record + the tracing audit event only). The publisher is the deployment-global cluster channel — the same one the worker registry and supervisor emit on — so the delta reuses the existing browser push path rather than inventing a parallel channel.

Source

pub fn policy(&self) -> AutoCreate

The auto-create policy this minter applies.

Source

pub async fn mint_or_gate( &self, namespaces: &[String], origin: NamespaceOrigin, ) -> Result<(), ServerError>

Apply the minted-on-use policy to an already-authorized namespace set.

The caller MUST have authorized every namespace in namespaces before calling this — the mint is auth-scoped by construction, never a path to create a namespace the caller cannot use.

A aion_store::StoreError::NotOwner from a quorum mint (this node is not the namespace shard’s owner) propagates unchanged through ? as ServerError::StoreBackend, which surfaces as the typed, retryable NotOwner wire code — never a silent success.

Closed-policy existence check (Phase 1). Existence is probed by registry-row presence (NamespaceStore::get_namespace). In a fresh Phase-1 deployment every used namespace already has a row minted on first register/start, so a missing row correctly means “never referenced”.

§Errors

Returns ServerError::StoreBackend if a durable upsert/lookup fails (including a retryable NotOwner fence), or ServerError::Namespace when closed rejects an unknown namespace.

Source

pub async fn create_explicit( &self, name: &str, ) -> Result<MintOutcome, ServerError>

Explicit operator create (POST /namespaces, S7) routed through the SAME MintOutcome::Created choke-point so the live “namespace created” delta fires once for an operator-minted namespace exactly as it does for a worker- or start-minted one.

Unlike NamespaceMinter::mint_or_gate this never gates on the AutoCreate::Closed policy: an explicit operator create is the documented escape hatch that brings a namespace into being in a locked-down deployment. The caller MUST have authorized name first (the HTTP handler runs the grant check), so the create is auth-scoped by construction.

Returns the MintOutcome so the handler can report created-vs-existing to the operator. Idempotent: a re-create observes AlreadyExisted and emits no second delta.

§Errors

Returns ServerError::StoreBackend if the durable upsert/lookup fails (including a retryable NotOwner fence).

Source

pub async fn set_placement( &self, name: &str, placement: NamespacePlacement, ) -> Result<bool, ServerError>

Set an existing namespace’s durable placement directive and emit the placement-changed socket delta (Control-Plane Phase 2, P2-P2).

The caller MUST have authorized name first (the HTTP handler runs the SAME grant check POST /namespaces does), so the placement change is auth-scoped by construction — a caller can never place a namespace it cannot access. The durable write is the idempotent quorum value-CAS update of the record’s placement field (NamespaceStore::set_namespace_placement): re-applying the same placement is a successful no-op.

Returns true when the placement was durably set, or false when no registry row exists for name (placement targets an already-minted namespace, so the handler surfaces a not-found rather than minting here). The placement-changed delta fires only on a real set (never on the not-found path), mirroring the Created-edge discipline of Self::announce_created.

§Errors

Returns ServerError::StoreBackend if the durable update fails (including a retryable NotOwner fence).

Source

pub async fn placement_of( &self, name: &str, ) -> Result<NamespacePlacement, ServerError>

Read a namespace’s durable placement directive, for the worker-admission gate (Control-Plane Phase 2, P2-I1). Reads the SAME registry record Self::set_placement writes — the single source of truth — so admission and dispatch can never disagree on a namespace’s placement.

An absent registry row means no placement applies: NamespacePlacement::Unplaced (any worker), so a namespace that has not yet been minted never gates a registration.

§Errors

Returns ServerError::StoreBackend if the durable lookup fails (including a retryable NotOwner fence).

Trait Implementations§

Source§

impl Clone for NamespaceMinter

Source§

fn clone(&self) -> NamespaceMinter

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for NamespaceMinter

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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