Skip to main content

Agent

Struct Agent 

Source
pub struct Agent<H> {
Show 28 fields pub id: AgentId, pub consumer_group: Option<ConsumerGroupName>, pub listen_on: AgentTopic<'static>, pub handler: H, pub respond_on: Option<AgentTopic<'static>>, pub inbox_route: InboxRoute, pub poll_interval: Option<Duration>, pub shutdown_grace: Option<Duration>, pub concurrency: Option<ConcurrencyPolicy>, pub max_queued_records: Option<usize>, pub max_queued_bytes: Option<usize>, pub warm_dedup: bool, pub middleware: Vec<Arc<dyn AgentMiddleware>>, pub on_dead_letter: Option<Arc<dyn DeadLetterSink>>, pub operations: Option<Vec<String>>, pub sessions: Option<SessionConfig>, pub dedup_window: Option<usize>, pub retry: Option<RetryPolicy>, pub understood_features: u64, pub deduplicator: Option<Box<dyn Deduplicator>>, pub verifier: Option<Arc<KeyRegistry>>, pub signing_key: Option<Arc<SigningKey>>, pub capabilities: Vec<CapabilityDescriptor>, pub ack_on_pickup: bool, pub consolidate_every: Option<Duration>, pub consolidator: Option<SharedConsolidator>, pub governor: Option<(Arc<dyn ActionGovernor>, GovernorMode)>, pub governor_retention: Option<GovernorRetention>,
}
Expand description

One logical agent defaults to one Iggy consumer group.

spawn derives the group name from id unless consumer_group is set. Horizontal scaling (multiple replicas of the same agent) means multiple processes joining that group, and Iggy load-balances messages across them.

Do NOT put two different agent ids in the same group. The ReliableConsumer skips messages whose agdx.to does not match its own id, which is the right behavior when a publisher addresses a specific agent on a shared topic. If two agents shared a group, Iggy would still deliver each message to exactly one member, and if it landed on the wrong one the filter would drop it and the intended agent would never see it. Each Agent::builder().id(...).spawn(..) call is its own consumer group. Do not bypass that by reusing the consumer group name across distinct agent ids.

Fields§

§id: AgentId

The agent’s stable logical identity.

§consumer_group: Option<ConsumerGroupName>

Deployment group for load balancing replicas. Defaults to the agent id’s spelling but remains a distinct type and may be overridden explicitly.

§listen_on: AgentTopic<'static>

The topic this agent consumes.

§handler: H

The handler invoked for each message.

§respond_on: Option<AgentTopic<'static>>

Default reply topic for AgentCtx::respond (none = respond errors).

§inbox_route: InboxRoute

Default route from a resolved target agent to the topic its work is sent on, used by AgentCtx::fan_out and the directed-send helpers. Sticks as this agent’s routing convention. Defaults to InboxRoute::Advertised (resolve each target to its live-presence inbox). Set InboxRoute::Fixed for a workflow topic the caller owns.

§poll_interval: Option<Duration>

Override the consumer poll interval (default: the runtime’s reactive 10ms).

§shutdown_grace: Option<Duration>

How long AgentHandle::shutdown waits for the in-flight message to finish draining before the consumer is dropped. AgentHandle::abort is the unconditional hard stop. Defaults to the consumer’s 30s grace.

§concurrency: Option<ConcurrencyPolicy>

How message handling is scheduled across the partitions this agent is assigned. Defaults to ConcurrencyPolicy::Serial. Set ConcurrencyPolicy::SerialPerPartition so a slow or retrying message on one partition does not stall the others.

§max_queued_records: Option<usize>

Override the total records buffered across partition lanes.

§max_queued_bytes: Option<usize>

Override the total payload and header bytes buffered across partition lanes.

§warm_dedup: bool§middleware: Vec<Arc<dyn AgentMiddleware>>

Cross-cutting hooks wrapped around each handler dispatch, in order, for auth, metrics, and tracing without touching the handler.

§on_dead_letter: Option<Arc<dyn DeadLetterSink>>

Notified on every dead-letter with the result of publishing it, so a lost poison message is an observable event rather than only a log line.

§operations: Option<Vec<String>>

The command operations the handler serves. Unset serves every operation. A command for another operation is skipped.

§sessions: Option<SessionConfig>

The session configuration the agent’s runtime applies: the lens AgentCtx::session opens and SessionConfig::fail_on_dead_letter. Defaults to SessionConfig::default.

§dedup_window: Option<usize>

Override the dedup window size (recent idempotency keys kept in memory). Defaults to the ReliableConsumer default when unset.

§retry: Option<RetryPolicy>

Override the handler retry policy (attempts + backoff for a retryable handler error). Defaults to the RetryPolicy default when unset.

§understood_features: u64

Must-understand AGDX feature bits implemented by this agent. A message requiring any other bit is dead-lettered before the handler runs.

§deduplicator: Option<Box<dyn Deduplicator>>

Override the dedup backend (e.g. a durable StateStore-backed one). Defaults to the in-memory sliding window.

§verifier: Option<Arc<KeyRegistry>>

The signature verifier for control and effect topics: when set, every message’s envelope signature is verified against this registry before dispatch, and an unsigned or unverified record is dead-lettered. This is the enforcement gate for authorship and authorization, so it is reachable from the primary builder rather than only the lower-level consumer.

§signing_key: Option<Arc<SigningKey>>

This agent’s signing identity: when set, AgentCtx::respond answers a correlated command with a signed AGDX response instead of a plain reply, so a caller holding a verifier (and the contract path’s signer binding) can accept this agent’s terminals and no one else’s.

§capabilities: Vec<CapabilityDescriptor>

What this agent serves. When non-empty, on spawn the agent publishes a capability card to the registry (so capability routing can discover it) and advertises its inbox (its listen_on topic) as live presence (so a fan-out resolves where to send it work). Empty means a private agent that does not advertise, the prior behavior.

§ack_on_pickup: bool

Emit a Working status the moment an AGDX command is picked up, before the handler runs, so a Laser::contract caller can tell the command was consumed. Off by default. Enable it on agents that take contracted work, with a respond_on set.

§consolidate_every: Option<Duration>

Run consolidator every consolidate_every off the handler loop (its own task, stopped with the agent). Both must be set for the tick to exist. Absent means no background consolidation, ever. Each pass runs over this agent’s own memory: the scope carries the agent id and nothing else. A zero period fails the agent with LaserError::Config instead of starting.

§consolidator: Option<SharedConsolidator>

The consolidation pass the periodic tick runs (see consolidate_every).

§governor: Option<(Arc<dyn ActionGovernor>, GovernorMode)>

The pre-effect policy hook applied to everything this agent’s handler publishes (ctx.send/respond/request/fan_out, AGDX verbs, memory writes), with the GovernorMode it runs under. Spawn re-scopes the agent’s Laser with it, so a governor set on the connection is replaced for this agent. See Laser::with_governor.

§governor_retention: Option<GovernorRetention>

Process-local evidence-chain retention for this agent’s governor. A restart or eviction begins a new local chain for the conversation.

Implementations§

Source§

impl<H> Agent<H>

Source

pub fn builder() -> AgentBuilder<H>

Create an instance of Agent using the builder syntax

Source§

impl<H> Agent<H>
where H: AgentHandler + Sync + Send + 'static,

Source

pub fn spawn(self, laser: Laser) -> AgentHandle

Spawn the agent on laser as its own consumer group, returning a handle to stop it.

Auto Trait Implementations§

§

impl<H> !RefUnwindSafe for Agent<H>

§

impl<H> !UnwindSafe for Agent<H>

§

impl<H> Freeze for Agent<H>
where H: Freeze,

§

impl<H> Send for Agent<H>
where H: Send,

§

impl<H> Sync for Agent<H>
where H: Sync,

§

impl<H> Unpin for Agent<H>
where H: Unpin,

§

impl<H> UnsafeUnpin for Agent<H>
where H: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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