pub struct ServiceRegistry { /* private fields */ }Expand description
Registry of system services with lifecycle management.
Uses DashMap for concurrent access from multiple kernel
subsystems. Maintains two maps:
services:SystemServicetrait object implementations (existing)entries:ServiceEntrymetadata for service identity (D1, K2.1)
A service can have metadata before it has a running implementation (useful for external services), and vice versa.
Implementations§
Source§impl ServiceRegistry
impl ServiceRegistry
Sourcepub fn register(
&self,
service: Arc<dyn SystemService>,
) -> Result<(), Box<dyn Error + Send + Sync>>
pub fn register( &self, service: Arc<dyn SystemService>, ) -> Result<(), Box<dyn Error + Send + Sync>>
Register a service.
Returns an error if a service with the same name is already registered.
Sourcepub fn unregister(&self, name: &str) -> Option<Arc<dyn SystemService>>
pub fn unregister(&self, name: &str) -> Option<Arc<dyn SystemService>>
Unregister a service by name.
Sourcepub fn list(&self) -> Vec<(String, ServiceType)>
pub fn list(&self) -> Vec<(String, ServiceType)>
List all registered services with their types.
Sourcepub async fn start_all(&self) -> Result<(), Box<dyn Error + Send + Sync>>
pub async fn start_all(&self) -> Result<(), Box<dyn Error + Send + Sync>>
Start all registered services.
Individual service failures are logged as warnings but do not prevent other services from starting.
Sourcepub async fn stop_all(&self) -> Result<(), Box<dyn Error + Send + Sync>>
pub async fn stop_all(&self) -> Result<(), Box<dyn Error + Send + Sync>>
Stop all registered services.
Individual service failures are logged as warnings.
Sourcepub fn snapshot(&self) -> Vec<(String, Arc<dyn SystemService>)>
pub fn snapshot(&self) -> Vec<(String, Arc<dyn SystemService>)>
Return a snapshot of all services as a Vec.
This copies all (name, Arc<dyn SystemService>) pairs out of
the DashMap, so the returned collection owns no DashMap refs
and is safe to hold across await points and send across threads.
Sourcepub async fn health_all(&self) -> Vec<(String, HealthStatus)>
pub async fn health_all(&self) -> Vec<(String, HealthStatus)>
Run health checks on all registered services.
Sourcepub fn register_entry(
&self,
entry: ServiceEntry,
) -> Result<(), Box<dyn Error + Send + Sync>>
pub fn register_entry( &self, entry: ServiceEntry, ) -> Result<(), Box<dyn Error + Send + Sync>>
Register a service entry (metadata, not a running implementation).
Returns an error if an entry with the same name already exists.
Sourcepub fn get_entry(&self, name: &str) -> Option<ServiceEntry>
pub fn get_entry(&self, name: &str) -> Option<ServiceEntry>
Get a service entry by name.
Sourcepub fn resolve_target(&self, name: &str) -> Option<Pid>
pub fn resolve_target(&self, name: &str) -> Option<Pid>
Resolve a service name to its owning agent PID.
Returns None if the service is not registered or has no
owner_pid (e.g. external services).
Sourcepub fn list_entries(&self) -> Vec<ServiceEntry>
pub fn list_entries(&self) -> Vec<ServiceEntry>
List all registered service entries.
Sourcepub fn unregister_entry(&self, name: &str) -> Option<ServiceEntry>
pub fn unregister_entry(&self, name: &str) -> Option<ServiceEntry>
Remove a service entry by name.
Sourcepub fn register_with_tree(
&self,
service: Arc<dyn SystemService>,
tree_manager: &TreeManager,
) -> Result<(), Box<dyn Error + Send + Sync>>
pub fn register_with_tree( &self, service: Arc<dyn SystemService>, tree_manager: &TreeManager, ) -> Result<(), Box<dyn Error + Send + Sync>>
Register a service and create a resource tree node + chain event.
When the exochain feature is enabled and a tree manager is provided,
creates a node at /kernel/services/{name} in the resource tree
and appends a corresponding chain event via TreeManager.
Sourcepub fn register_with_contract(
&self,
service: Arc<dyn SystemService>,
methods: Vec<String>,
chain: &ChainManager,
) -> Result<(), Box<dyn Error + Send + Sync>>
pub fn register_with_contract( &self, service: Arc<dyn SystemService>, methods: Vec<String>, chain: &ChainManager, ) -> Result<(), Box<dyn Error + Send + Sync>>
Register a service and automatically create a chain-anchored contract (C3).
This is the recommended registration path for K4+ services that want immutable API contracts stored on the ExoChain. It combines service registration, contract creation, and chain logging in one call.
Sourcepub fn register_contract(
&self,
contract: &ServiceContract,
chain: &ChainManager,
) -> Result<(), Box<dyn Error + Send + Sync>>
pub fn register_contract( &self, contract: &ServiceContract, chain: &ChainManager, ) -> Result<(), Box<dyn Error + Send + Sync>>
Register a service contract and log it to the chain (K2 C3, K4 G2).
A service contract is a versioned interface declaration that is anchored in the ExoChain for immutability. Once a contract version is registered, it cannot be changed — only superseded by a new version.
Trait Implementations§
Source§impl Default for ServiceRegistry
impl Default for ServiceRegistry
Source§impl Registry for ServiceRegistry
impl Registry for ServiceRegistry
Auto Trait Implementations§
impl Freeze for ServiceRegistry
impl !RefUnwindSafe for ServiceRegistry
impl Send for ServiceRegistry
impl Sync for ServiceRegistry
impl Unpin for ServiceRegistry
impl UnsafeUnpin for ServiceRegistry
impl !UnwindSafe for ServiceRegistry
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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