pub trait Agent {
// Required method
fn run(
&self,
route: RouteUri,
route_params: HashMap<String, String>,
config: AgentConfig,
context: Box<dyn AgentContext + Send>,
) -> BoxFuture<'static, AgentInitResult>;
}Expand description
Trait to define a type of agent. Instances of this will be passed to the runtime to be executed. User code should not generally need to implement this directly. It is necessary for this trait to be object safe and any changes to it should take that into account.
Required Methods§
Sourcefn run(
&self,
route: RouteUri,
route_params: HashMap<String, String>,
config: AgentConfig,
context: Box<dyn AgentContext + Send>,
) -> BoxFuture<'static, AgentInitResult>
fn run( &self, route: RouteUri, route_params: HashMap<String, String>, config: AgentConfig, context: Box<dyn AgentContext + Send>, ) -> BoxFuture<'static, AgentInitResult>
Running an agent results in future that will perform the initialization of the agent and then yield another future that will actually run the agent.
§Arguments
route- The node URI of this agent instance.route_params- Parameters extracted from the route URI.config- Configuration parameters for the agent.context- Context through which the agent can interact with the runtime. If this is dropped, then the agent will be terminated.