Skip to main content

MeshPort

Struct MeshPort 

Source
pub struct MeshPort {
    pub name: Option<String>,
    pub number: Option<u16>,
}
Expand description

One port a workload listens on, as its manifest declares it (R844-F17).

Before this, expose.mesh.ports was an array of bare numbers and a port name was unwritable anywhere in the workspace — names were real at every tier below the manifest (kamaji’s allocator resolves name -> port, a service record publishes {"http": 8080, "wss": 8443}, the sibling wire carries named_ports, PORT_<NAME> reaches the process) and synthesised from nothing at the top by crate::MeshExpose’s number list. This is the declaration surface that had to exist for any of that to be stated rather than guessed.

§Three spellings, one type

ports = [8080]                            # a number, unnamed
ports = ["http", "wss"]                   # names; the supervisor picks the numbers
ports = [{ name = "https", port = 443 }]  # both stated

They mix freely in one array (ports = [{ name = "http", port = 8080 }, "metrics"]), because the two facts are independent: a container’s ports are fixed by its image and still want names, while a native workload’s numbers are the allocator’s to choose and only the names are the author’s.

§What each spelling means downstream

  • A number is a request to listen there. On a container backend that is simply the container-side port. On the published (fleet) tier a number outside kamaji::ports::WORLD_FIXED_PORTS is refused at bring-up rather than honoured (R844-F14) — a stale pin is how one workload lands on the port a co-tenant already holds.
  • A name is what a consumer asks for: ServiceRecord::port("wss"), the ingress planner resolving which listener a hostname fronts, the PORT_<NAME> variable the process reads. A workload declaring several ports and naming none has nothing called http, and the front door refuses to resolve rather than publish a hostname at whichever listener sorted first (kamaji::name_anonymous_ports). Naming them is how you answer that question instead of being asked it.

§Wire shapes

Human-readable formats (TOML/JSON) accept all three spellings and round-trip back to the most compact faithful one. The binary wire (postcard, behind the kamaji UDS) carries the plain two-Option struct: untagged needs deserialize_any, which postcard refuses — the same split ImageRef makes, and for the same reason (R590-B3).

Deliberately NOT Default: the all-None value is the one shape no accepted spelling produces and validate::shape rejects, so a ..Default::default() would hand a caller exactly the invalid port.

Fields§

§name: Option<String>

The name this port is known by — http, wss, metrics. None when the manifest wrote a bare number; kamaji::name_anonymous_ports then decides what to call it, which is deliberately not http when there is more than one.

§number: Option<u16>

The port number, when the manifest states one. None means the supervisor allocates it and tells the workload via PORT_<NAME>.

Implementations§

Source§

impl MeshPort

Source

pub fn anonymous(number: u16) -> Self

A bare number, unnamed — the pre-R844-F17 spelling, still valid.

Source

pub fn named(name: impl Into<String>) -> Self

A named port whose number the supervisor allocates.

Source

pub fn pinned(name: impl Into<String>, number: u16) -> Self

A named port whose number the manifest states.

Trait Implementations§

Source§

impl Clone for MeshPort

Source§

fn clone(&self) -> MeshPort

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 MeshPort

Source§

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

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

impl<'de> Deserialize<'de> for MeshPort

Source§

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

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

impl Eq for MeshPort

Source§

impl From<&str> for MeshPort

Source§

fn from(name: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for MeshPort

Source§

fn from(name: String) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for MeshPort

Source§

fn from(number: u16) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for MeshPort

Source§

fn eq(&self, other: &MeshPort) -> 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 MeshPort

Source§

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

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

impl StructuralPartialEq for MeshPort

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.