pub struct NamespaceRecord {
pub name: String,
pub created_at: DateTime<Utc>,
pub last_seen: DateTime<Utc>,
pub origin: NamespaceOrigin,
pub config: NamespaceConfig,
pub placement: NamespacePlacement,
pub state: NamespaceState,
}Expand description
One durable namespace registry entry.
The control-plane source of truth for “this namespace exists”: listable, failover-survivable, and the anchor for future per-namespace policy (quotas, placement, retention).
Fields§
§name: StringThe namespace name. Free-form, exactly as carried on the wire
(StartWorkflowRequest.namespace / RegisterWorker.namespaces).
Primary key.
created_at: DateTime<Utc>When the registry first minted this namespace (first reference).
last_seen: DateTime<Utc>Most recent time a worker/start referenced it — refreshed on mint-touch. Drives staleness/observability; never drives reaping while durable state exists.
origin: NamespaceOriginHow it came to exist: worker-mint, explicit POST, or inferred-from-state.
config: NamespaceConfigReserved per-namespace policy blob (retention, quotas, auth scope).
Phase 1 writes NamespaceConfig::default; Phase 2 fills it. Present
day-one to avoid a later data migration.
placement: NamespacePlacementReserved placement directive (node/shard-range affinity). Phase 1 is
NamespacePlacement::Unplaced. Present day-one so physical isolation
is a later policy, not a migration.
state: NamespaceStateLifecycle state, so a namespace can be retired (deprecate-before-delete) without losing its durable history.
Implementations§
Source§impl NamespaceRecord
impl NamespaceRecord
Sourcepub fn new_minted(
name: &str,
origin: NamespaceOrigin,
now: DateTime<Utc>,
) -> Self
pub fn new_minted( name: &str, origin: NamespaceOrigin, now: DateTime<Utc>, ) -> Self
Builds a freshly minted record for name.
created_at and last_seen are both set to now (a brand-new
namespace has been seen exactly once, at creation), state is
NamespaceState::Active, and config/placement take their
reserved Phase-1 defaults.
Sourcepub fn bump_last_seen(&mut self, now: DateTime<Utc>)
pub fn bump_last_seen(&mut self, now: DateTime<Utc>)
Advances last_seen to now, leaving every other field untouched.
Used by the idempotent mint-touch path: re-referencing an existing
namespace refreshes its staleness signal without altering existence,
origin, or lifecycle state. now is applied unconditionally — callers
supply a monotonic clock.
Sourcepub fn encode(&self) -> Result<Vec<u8>, StoreError>
pub fn encode(&self) -> Result<Vec<u8>, StoreError>
Encodes the record to opaque bytes for store persistence.
Mirrors the package codec: serde_json over a stable on-disk form with
instants rendered as RFC 3339 text. The store backend never parses the
result beyond NamespaceRecord::decode.
§Errors
Returns StoreError::Serialization if the record cannot be encoded.
Sourcepub fn decode(bytes: &[u8]) -> Result<Self, StoreError>
pub fn decode(bytes: &[u8]) -> Result<Self, StoreError>
Decodes a record previously produced by NamespaceRecord::encode.
§Errors
Returns StoreError::Serialization if bytes is not a valid encoded
record (malformed JSON or an unparseable instant).
Trait Implementations§
Source§impl Clone for NamespaceRecord
impl Clone for NamespaceRecord
Source§fn clone(&self) -> NamespaceRecord
fn clone(&self) -> NamespaceRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more