Skip to main content

WorkspaceRouter

Struct WorkspaceRouter 

Source
pub struct WorkspaceRouter {
    default_workspace: Option<String>,
    workspaces: HashMap<String, Arc<WorkspaceRuntime>>,
    order: Vec<String>,
    mode: ServerMode,
    search_deadline: Duration,
}
Expand description

Routes built-in operations to the selected WorkspaceRuntime.

Fields§

§default_workspace: Option<String>§workspaces: HashMap<String, Arc<WorkspaceRuntime>>§order: Vec<String>

Stable iteration order for discovery/listing.

§mode: ServerMode§search_deadline: Duration

Per-workspace deadline for all fan-out (R33). Defaults to DEFAULT_SEARCH_DEADLINE_MS; overridden by with_search_deadline.

Implementations§

Source§

impl WorkspaceRouter

Source

pub fn single(config: Arc<Config>) -> Self

Build the one-workspace router that backs compatibility mode.

Source

pub fn multi( runtimes: Vec<WorkspaceRuntime>, default_workspace: Option<String>, ) -> Self

Build a multi-workspace router from pre-resolved runtimes.

runtimes is consumed in the order it should be listed by discovery. default_workspace is the [defaults].workspace id, if any.

Source

pub fn mode(&self) -> ServerMode

The server mode this router represents.

Source

pub fn default_id(&self) -> Option<&str>

The configured default workspace id, if set.

Source

pub fn is_registered(&self, id: &str) -> bool

Whether id is a registered workspace (used for qualified-id parsing, R40).

Source

pub fn list(&self) -> Vec<Arc<WorkspaceRuntime>>

All runtimes in stable listing order (for the workspaces tool).

Source

pub fn default_config(&self) -> Arc<Config>

A config to back convenience-method access in a [ToolContext]. Returns the default workspace’s config, else the first enabled, else the first. In multi mode built-in tools resolve per-call and do not rely on this.

Source

fn enabled_ids(&self) -> Vec<String>

Ids of all enabled workspaces (used in workspace_required messages).

Source

pub fn resolve( &self, selector: Option<&str>, ) -> Result<Arc<WorkspaceRuntime>, RouterError>

Resolve a selector to a single runtime (SPEC-0014 R19–R26).

Precedence: explicit id → [defaults].workspace → single enabled → otherwise workspace_required. The all selector is rejected here in Phase 1 (unsupported_workspace_selector); fan-out is Phase 2.

Source

fn resolve_id(&self, id: &str) -> Result<Arc<WorkspaceRuntime>, RouterError>

Resolve a concrete workspace id, applying enabled/health checks.

Source

pub fn search_deadline(&self) -> Duration

The configured per-workspace all-search deadline (R33).

Source

pub fn with_search_deadline(self, ms: Option<u64>) -> Self

Override the per-workspace all-search deadline. None leaves the current value (the default) unchanged. Builder-style so existing multi(...) call sites need no change.

Source

pub fn resolve_all( &self, ) -> (Vec<Arc<WorkspaceRuntime>>, Vec<(String, RouterError)>)

Resolve the all selector (SPEC-0014 R21) into the enabled workspaces, partitioned into healthy runtimes (to search) and enabled-but-unavailable workspaces as pre-built error entries (R26/R37). Disabled workspaces are excluded entirely — they are not part of all and are not errors (R7). Output follows the stable registry order.

Source

pub fn split_qualified_id<'a>(&self, id: &'a str) -> (Option<&'a str>, &'a str)

Split a get id into (workspace, raw_id) using qualified-id rules (R40).

An id is qualified only when it contains : and the prefix matches a registered workspace id; otherwise the whole value is a raw id. Returns the workspace prefix (if qualified) and the bare document id.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

§

impl<T> MaybeSend for T
where T: Send,