Skip to main content

PlacementStrategy

Enum PlacementStrategy 

Source
pub enum PlacementStrategy {
    SingleNode,
    Replicated,
    Sharded,
}
Expand description

How the Aplicacao distributes across clusters. Three options:

  • SingleNode — one cluster runs the app at a time; takeover on death (Erlang/OTP distributed-app semantics).
  • Replicated — every named cluster runs an instance (active-active).
  • Sharded — entities distribute by hash key across clusters (Akka cluster sharding).

Variants§

§

SingleNode

§

Replicated

§

Sharded

Implementations§

Source§

impl PlacementStrategy

Source

pub const fn is_single_node(&self) -> bool

Source

pub const fn is_replicated(&self) -> bool

Source

pub const fn is_sharded(&self) -> bool

Source§

impl PlacementStrategy

Source

pub const ALL: &'static [Self]

Exhaustive iteration surface for every consumer that reads the full closed-set (the future M4 admission-webhook’s accepted- strategy listing in its rejection body, a future feira app placement --list CLI-side surfacing of the accepted arm-set, any future round-trip fuzz harness). A future variant addition (an Anycast mesh-anycast arm the MESH-COMPOSITION §II.5 hint names as a trajectory item) extends this slice as a single edit and every consumer picks up the new entry by construction — the compiler-checked exhaustiveness on the sibling method match arms is the build-time guarantee that no arm forgets to grow. Same shape as the sibling closed-set typed enums’ RateLimitUnit::ALL (6bce03d) and crate::dep::DepList::ALL (45ee563) exhaustive-iteration surfaces — the third closed-set typed enum on the caixa surface to converge onto the same discipline.

Source

pub const fn as_str(self) -> &'static str

Canonical camelCase-schema discriminator scalar this variant serializes as under crate::M3_PLACEMENT_KEY_ESTRATEGIA. The three arms return the paired crate::M3_PLACEMENT_ESTRATEGIA_SINGLE_NODE / crate::M3_PLACEMENT_ESTRATEGIA_REPLICATED / crate::M3_PLACEMENT_ESTRATEGIA_SHARDED lifted constants so every substrate consumer that dispatches on the strategy (the lareira-fleet-programs aggregator, the future app-operator reconciler, the M3 Adaptive compression pass) reads the same byte-string the Serialize derive emits — the pin test in [tests::placement_strategy_variants_serialize_to_lifted_scalar_values] asserts the two paths agree.

Source

pub fn from_wire(s: &str) -> Option<Self>

Substrate-canonical reverse projection on the :placement :estrategia closed-set axis — parses the camelCase-schema discriminator scalar back to the typed variant, or None when s is outside the closed-set arm-string set Self::as_str emits. Dispatches on the same lifted crate::render::M3_PLACEMENT_ESTRATEGIA_SINGLE_NODE / crate::render::M3_PLACEMENT_ESTRATEGIA_REPLICATED / crate::render::M3_PLACEMENT_ESTRATEGIA_SHARDED constants the Self::as_str emitter walks, so the parse and emit halves of the round-trip migrate through one caixa-core edit on any future arm addition (an Anycast mesh-anycast arm the MESH-COMPOSITION §II.5 hint names as a trajectory item lands one variant + one arm per method and the compiler enforces exhaustiveness on every consumer’s match self arms).

Prior to this lift the substrate carried only the forward Self → &str projection (the Self::as_str emitter, the std::fmt::Display impl routed through it, the Serialize derive that emits the same byte-string under crate::M3_PLACEMENT_KEY_ESTRATEGIA) — every non-serde consumer that wanted to parse a wire-form strategy scalar had to re-inline a three-arm match s { "SingleNode" => …, "Replicated" => …, "Sharded" => …, _ => … } cascade that expressed no compile-time link back to the typed variant’s canonical lifted constant. A future variant rename or a per-arm serde-attribute drift would silently split the wire byte-string one non-serde consumer parsed from the one the emitter wrote, with the failure surfacing at parse time far from the rebrand commit.

Same closed-set-reverse-projection discipline the sibling crate::CaixaKind::from_wire (2aa6d23) and RateLimitUnit::from_suffix typed enums carry on the peer wire-side str → Self axes — extended onto the M3 mesh-primitive- defining :placement :estrategia closed-set axis, the third substrate-side closed-set typed enum to converge on the two-way str ↔ Self round-trip. Method-named from_wire (not from_str) to match the peer crate::CaixaKind::from_wire shape verbatim and side-step the std::str::FromStr-collision clippy (clippy::should_implement_trait) the plain from_str name carries; a future explicit std::str::FromStr impl can layer on top by delegating to this canonical arm-dispatch method.

Returns Option<Self> (rather than Result<Self, _>) to match the sibling crate::CaixaKind::from_wire shape: the caller picks the diagnostic form appropriate for its use site — a future feira app placement --set CLI-side arg-parse that wants an "unknown strategy: {s} (accepted: SingleNode, Replicated, Sharded)" diagnostic builds one on top by iterating Self::ALL, while the future M4 admission-webhook’s rejection path folds None onto its per-CR structured refusal body.

Trait Implementations§

Source§

impl Clone for PlacementStrategy

Source§

fn clone(&self) -> PlacementStrategy

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 Copy for PlacementStrategy

Source§

impl Debug for PlacementStrategy

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for PlacementStrategy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for PlacementStrategy

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for PlacementStrategy

std::fmt::Display routed through PlacementStrategy::as_str, so the pretty-printed byte-string every consumer that formats the strategy as user-facing text lands on (the M3 AplicacaoError::PlacementWithoutClusters / AplicacaoError::ShardKeyOnNonSharded #[error(":placement {estrategia} …")] diagnostic templates, the future feira app graph per-Aplicacao strategy line, the future M4 CR materializer’s per- admission-webhook rejection body) reaches for the same lifted crate::M3_PLACEMENT_ESTRATEGIA_SINGLE_NODE / crate::M3_PLACEMENT_ESTRATEGIA_REPLICATED / crate::M3_PLACEMENT_ESTRATEGIA_SHARDED const the wire-format Serialize derive already emits under crate::M3_PLACEMENT_KEY_ESTRATEGIA and the PlacementStrategy::as_str helper already returns.

Until this lift landed the sibling OTP-shape typed enums — crate::supervisor::RestartStrategy / crate::supervisor::RestartPolicy (both derive gen_platform::Discriminant with #[discriminant(also_display)] so std::fmt::Display routes through the same discriminant string the wire format emits) — carried a stable std::fmt::Display surface but PlacementStrategy did not; every consumer reaching for a strategy byte-string past the wire format had to pick between three paths (PlacementStrategy::as_str, the Serialize derive’s serialized string, format!("{variant:?}") on the std::fmt::Debug derive), any two of which a future variant rename or #[serde(rename_all = "kebab-case")] attribute would silently desynchronize — with the failure surfacing as a downstream renderer / operator’s per-strategy dispatch reading one spelling while the wire format emitted another, far from the source rebrand commit and with no field naming the drift. Routing Display through PlacementStrategy::as_str makes the three paths (Debug for structural inspection, Display for user-facing text, Serialize for the wire format) converge on the same lifted [crate::M3_PLACEMENT_ESTRATEGIA_*] const set: the wire byte-string, the diagnostic byte-string, and the pretty-printed byte-string move as a single unit through one canonical declaration each, by construction. Same trajectory as PlacementStrategy::as_str (cc8f749) on the sibling wire-vs-const single-source axis — this lift closes the third path.

Pin tests [tests::placement_strategy_display_routes_through_as_str_helper] and [tests::placement_strategy_display_matches_serialized_wire_byte_string] assert the three paths agree byte-for-byte on every variant, so a future variant rename or per-arm serde attribute drift is a build error visible at caixa-core test time, not a silent per-consumer dispatch miss at apply / reconcile time.

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for PlacementStrategy

Source§

impl Hash for PlacementStrategy

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for PlacementStrategy

Source§

fn eq(&self, other: &PlacementStrategy) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for PlacementStrategy

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PlacementStrategy

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<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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.