Skip to main content

Daemon

Struct Daemon 

Source
pub struct Daemon {
    pub runtime: Arc<RwLock<Arc<Runtime<ProviderRegistry, DaemonHook>>>>,
    /* private fields */
}
Expand description

Shared daemon state — holds the runtime. Cheap to clone (Arc-backed).

The runtime is stored behind Arc<RwLock<Arc<Runtime>>> so that Daemon::reload can swap it atomically while in-flight requests that already cloned the inner Arc complete normally.

Fields§

§runtime: Arc<RwLock<Arc<Runtime<ProviderRegistry, DaemonHook>>>>

The walrus runtime, swappable via Daemon::reload.

Implementations§

Source§

impl Daemon

Source

pub async fn reload(&self) -> Result<()>

Rebuild the runtime from disk and swap it in atomically.

In-flight requests that already hold a reference to the old runtime complete normally. New requests after the swap see the new runtime. Note: reload does not restart managed services — that requires a full daemon restart. Services field is cleared to avoid re-spawning.

Source§

impl Daemon

Source

pub async fn start(config_dir: &Path) -> Result<DaemonHandle>

Load config, build runtime, and start the event loop.

Returns a DaemonHandle with the event sender exposed. The caller spawns transports (socket, channels) using the handle’s event_tx and shutdown_tx, then integrates its own channels by cloning event_tx and sending DaemonEvent::Message variants.

Trait Implementations§

Source§

impl Clone for Daemon

Source§

fn clone(&self) -> Daemon

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Server for Daemon

Source§

async fn send(&self, req: SendMsg) -> Result<SendResponse>

Handle Send — run agent and return complete response.
Source§

fn stream( &self, req: StreamMsg, ) -> impl Stream<Item = Result<StreamEvent>> + Send

Handle Stream — run agent and stream response events.
Source§

async fn ping(&self) -> Result<()>

Handle Ping — keepalive.
Source§

async fn list_sessions(&self) -> Result<Vec<SessionInfo>>

Handle Sessions — list active sessions.
Source§

async fn kill_session(&self, session: u64) -> Result<bool>

Handle Kill — close a session by ID.
Source§

async fn list_tasks(&self) -> Result<Vec<TaskInfo>>

Handle Tasks — list tasks in the task registry.
Source§

async fn kill_task(&self, task_id: u64) -> Result<bool>

Handle KillTask — cancel a task by ID.
Source§

async fn approve_task(&self, _task_id: u64, _response: String) -> Result<bool>

Handle Approve — approve a blocked task’s inbox item.
Source§

fn hub( &self, package: String, action: HubAction, filters: Vec<String>, ) -> impl Stream<Item = Result<DownloadEvent>> + Send

Handle Hub — install or uninstall a hub package. Read more
Source§

fn subscribe_tasks(&self) -> impl Stream<Item = Result<TaskEvent>> + Send

Handle SubscribeTasks — stream task lifecycle events.
Source§

async fn list_downloads(&self) -> Result<Vec<DownloadInfo>>

Handle Downloads — list downloads in the registry.
Source§

fn subscribe_downloads( &self, ) -> impl Stream<Item = Result<DownloadEvent>> + Send

Handle SubscribeDownloads — stream download lifecycle events.
Source§

async fn get_config(&self) -> Result<String>

Handle GetConfig — return the full daemon config as JSON.
Source§

async fn set_config(&self, config: String) -> Result<()>

Handle SetConfig — replace the daemon config from JSON.
Source§

async fn service_query(&self, service: String, query: String) -> Result<String>

Handle ServiceQuery — route to a named service.
Source§

async fn get_service_schema(&self, service: String) -> Result<String>

Handle GetServiceSchema — return JSON Schema for one service’s config.
Source§

async fn get_all_schemas(&self) -> Result<HashMap<String, String>>

Handle GetAllSchemas — return JSON Schemas for all services.
Source§

async fn list_services(&self) -> Result<Vec<ServiceInfoMsg>>

Handle GetServices — list registered services with status.
Source§

async fn set_service_config( &self, service: String, config: String, ) -> Result<()>

Handle SetServiceConfig — update a single service’s config.
Source§

async fn reload(&self) -> Result<()>

Handle Reload — hot-reload runtime from disk.
Source§

fn dispatch( &self, msg: ClientMessage, ) -> impl Stream<Item = ServerMessage> + Send

Dispatch a ClientMessage to the appropriate handler method. Read more

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> PolicyExt for T
where T: ?Sized,

Source§

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
Source§

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> 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 = 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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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