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: DurationPer-workspace deadline for all fan-out (R33). Defaults to
DEFAULT_SEARCH_DEADLINE_MS; overridden by with_search_deadline.
Implementations§
Source§impl WorkspaceRouter
impl WorkspaceRouter
Sourcepub fn single(config: Arc<Config>) -> Self
pub fn single(config: Arc<Config>) -> Self
Build the one-workspace router that backs compatibility mode.
Sourcepub fn multi(
runtimes: Vec<WorkspaceRuntime>,
default_workspace: Option<String>,
) -> Self
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.
Sourcepub fn mode(&self) -> ServerMode
pub fn mode(&self) -> ServerMode
The server mode this router represents.
Sourcepub fn default_id(&self) -> Option<&str>
pub fn default_id(&self) -> Option<&str>
The configured default workspace id, if set.
Sourcepub fn is_registered(&self, id: &str) -> bool
pub fn is_registered(&self, id: &str) -> bool
Whether id is a registered workspace (used for qualified-id parsing, R40).
Sourcepub fn list(&self) -> Vec<Arc<WorkspaceRuntime>>
pub fn list(&self) -> Vec<Arc<WorkspaceRuntime>>
All runtimes in stable listing order (for the workspaces tool).
Sourcepub fn default_config(&self) -> Arc<Config>
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.
Sourcefn enabled_ids(&self) -> Vec<String>
fn enabled_ids(&self) -> Vec<String>
Ids of all enabled workspaces (used in workspace_required messages).
Sourcepub fn resolve(
&self,
selector: Option<&str>,
) -> Result<Arc<WorkspaceRuntime>, RouterError>
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.
Sourcefn resolve_id(&self, id: &str) -> Result<Arc<WorkspaceRuntime>, RouterError>
fn resolve_id(&self, id: &str) -> Result<Arc<WorkspaceRuntime>, RouterError>
Resolve a concrete workspace id, applying enabled/health checks.
Sourcepub fn search_deadline(&self) -> Duration
pub fn search_deadline(&self) -> Duration
The configured per-workspace all-search deadline (R33).
Sourcepub fn with_search_deadline(self, ms: Option<u64>) -> Self
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.
Sourcepub fn resolve_all(
&self,
) -> (Vec<Arc<WorkspaceRuntime>>, Vec<(String, RouterError)>)
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.
Sourcepub fn split_qualified_id<'a>(&self, id: &'a str) -> (Option<&'a str>, &'a str)
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§
impl Freeze for WorkspaceRouter
impl RefUnwindSafe for WorkspaceRouter
impl Send for WorkspaceRouter
impl Sync for WorkspaceRouter
impl Unpin for WorkspaceRouter
impl UnsafeUnpin for WorkspaceRouter
impl UnwindSafe for WorkspaceRouter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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