pub struct AgentKernel<H>where
H: AgentMessageHandler + 'static,{ /* private fields */ }Expand description
Core runtime that wires lifecycle, scheduler, and MXP handlers.
Implementations§
Source§impl<H> AgentKernel<H>where
H: AgentMessageHandler + 'static,
impl<H> AgentKernel<H>where
H: AgentMessageHandler + 'static,
Sourcepub fn new(agent_id: AgentId, handler: Arc<H>, scheduler: TaskScheduler) -> Self
pub fn new(agent_id: AgentId, handler: Arc<H>, scheduler: TaskScheduler) -> Self
Creates a new agent kernel with the provided handler and scheduler.
Sourcepub fn set_registry<R>(
&mut self,
registry: Arc<R>,
manifest: AgentManifest,
config: RegistrationConfig,
)where
R: AgentRegistry + 'static,
pub fn set_registry<R>(
&mut self,
registry: Arc<R>,
manifest: AgentManifest,
config: RegistrationConfig,
)where
R: AgentRegistry + 'static,
Provides registry integration for mesh discovery and heartbeat management.
Sourcepub fn set_recovery(&mut self, recovery: Arc<StateRecovery>)
pub fn set_recovery(&mut self, recovery: Arc<StateRecovery>)
Enables state recovery with the provided recovery manager.
Sourcepub fn state(&self) -> AgentState
pub fn state(&self) -> AgentState
Returns the current lifecycle state.
Sourcepub fn transition(&mut self, event: LifecycleEvent) -> KernelResult<AgentState>
pub fn transition(&mut self, event: LifecycleEvent) -> KernelResult<AgentState>
Applies a lifecycle event, returning the new state on success.
§Errors
Returns LifecycleError when the transition is
not permitted from the current state.
Sourcepub async fn handle_message(&self, message: Message) -> HandlerResult
pub async fn handle_message(&self, message: Message) -> HandlerResult
Handles an MXP message immediately on the current task.
§Errors
Propagates any error returned by the message handler implementation.
Sourcepub fn schedule_message(
&self,
message: Message,
) -> SchedulerResult<JoinHandle<HandlerResult>>
pub fn schedule_message( &self, message: Message, ) -> SchedulerResult<JoinHandle<HandlerResult>>
Enqueues an MXP message for asynchronous processing via the scheduler.
§Errors
Returns SchedulerError when the scheduler has been closed.
Sourcepub fn scheduler(&self) -> &TaskScheduler
pub fn scheduler(&self) -> &TaskScheduler
Returns a reference to the underlying scheduler.
Sourcepub fn shutdown(&self) -> &ShutdownCoordinator
pub fn shutdown(&self) -> &ShutdownCoordinator
Returns a reference to the shutdown coordinator.
Sourcepub async fn graceful_shutdown(&mut self) -> ShutdownResult<()>
pub async fn graceful_shutdown(&mut self) -> ShutdownResult<()>
Initiates graceful shutdown of the agent.
Stops accepting new requests and drains in-flight work up to the configured timeout. If recovery is enabled, persists critical state before termination.
§Errors
Returns ShutdownError if shutdown fails or times out.