pub struct AgentBuilder { /* private fields */ }Expand description
Builder for configuring and creating an Agent
§Example
use elo::Agent;
let agent = Agent::builder()
.storage_path("/var/lib/loa")
.identity_path("/etc/loa/agent_id.key")
.dashboard_port(3000)
.build()
.await?;Implementations§
Source§impl AgentBuilder
impl AgentBuilder
Sourcepub fn storage_path<P: AsRef<Path>>(self, path: P) -> Self
pub fn storage_path<P: AsRef<Path>>(self, path: P) -> Self
Set the storage path for databases and persistent data
This is required. If not set, build() will return an error.
§Example
use elo::Agent;
let agent = Agent::builder()
.storage_path("/var/lib/loa")
.build()
.await?;Sourcepub fn identity_path<P: AsRef<Path>>(self, path: P) -> Self
pub fn identity_path<P: AsRef<Path>>(self, path: P) -> Self
Set the identity path for agent identity key
If not specified, defaults to {storage_path}/agent_id.key
§Example
use elo::Agent;
let agent = Agent::builder()
.storage_path("/var/lib/loa")
.identity_path("/etc/loa/agent_id.key")
.build()
.await?;Sourcepub fn dashboard_port(self, port: u16) -> Self
pub fn dashboard_port(self, port: u16) -> Self
Set the dashboard port
Optional. If set, a dashboard will be served on this port (future feature).
§Example
use elo::Agent;
let agent = Agent::builder()
.storage_path("/var/lib/loa")
.dashboard_port(3000)
.build()
.await?;Sourcepub fn claim<S: Into<String>>(self, claim_token_id: S) -> Self
pub fn claim<S: Into<String>>(self, claim_token_id: S) -> Self
Claim this agent for a workspace using a claim token
This allows immediate agent claiming during startup. The claim_token_id is sent with the heartbeat for self-registration, linking the agent to a workspace.
§Example
use elo::Agent;
let agent = Agent::builder()
.storage_path("/var/lib/loa")
.claim("550e8400-e29b-41d4-a716-446655440000")
.build()
.await?;Sourcepub async fn build(self) -> Result<Agent>
pub async fn build(self) -> Result<Agent>
Build the agent and spawn all internal actors
This will:
- Validate configuration
- Create storage directories if needed
- Spawn the root supervisor
- Spawn all core actors (currently empty)
- Return an Agent handle
§Errors
Returns an error if:
- storage_path is not set
- storage directories cannot be created
- supervisor fails to spawn
§Example
use elo::Agent;
let agent = Agent::builder()
.storage_path("/var/lib/loa")
.build()
.await?;
agent.run().await?;Auto Trait Implementations§
impl Freeze for AgentBuilder
impl RefUnwindSafe for AgentBuilder
impl Send for AgentBuilder
impl Sync for AgentBuilder
impl Unpin for AgentBuilder
impl UnwindSafe for AgentBuilder
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
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> Message for T
impl<T> Message for T
Source§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
Convert a BoxedMessage to this concrete type
Source§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
Convert this message to a BoxedMessage