Agent Module
Functions and values
| Function or value |
Description
|
Full Usage:
Agent.createReply processor
Parameters:
'Request -> 'Reply
-
A function to process each request and produce a reply.
Returns: Agent<'Request * AsyncReplyChannel<'Reply>>
An Agent instance.
Type parameters: 'Request, 'Reply |
Creates and starts an agent that supports request-reply messaging. The processor function computes a reply for each request.
|
Full Usage:
Agent.createReplyAsync processor
Parameters:
'Request -> Async<'Reply>
-
An async function to process each request and produce a reply.
Returns: Agent<'Request * AsyncReplyChannel<'Reply>>
An Agent instance.
Type parameters: 'Request, 'Reply |
Creates and starts an agent that supports request-reply messaging with an async processor function. Unlike createReply, the processor returns Async<'Reply>, so the agent can await async operations (e.g., inter-agent calls) without blocking a thread pool thread.
|
Full Usage:
Agent.createSimple processor
Parameters:
'T -> unit
-
A function to process each message.
Returns: Agent<'T>
An Agent instance.
Type parameters: 'T |
Creates and starts a simple agent that processes messages of type 'T in a loop. The processor function is called for each message received. This agent does not maintain state between messages and will not reply.
|
Full Usage:
Agent.createStateful (initialState, processor)
Parameters:
'State
-
The initial state value.
processor : 'State -> 'T -> 'State
-
A function to process each message and update the state.
Returns: Agent<'T>
An Agent instance.
Type parameters: 'T, 'State |
Creates and starts a stateful agent that maintains state of type 'State. The processor function updates the state for each message received. This agent does not reply to messages.
|
Full Usage:
Agent.createStatefulReply (initialState, processor)
Parameters:
'State
-
The initial state value.
processor : 'State -> 'Request -> 'Reply * 'State
-
A function to process each request and update the state.
Returns: Agent<'Request * AsyncReplyChannel<'Reply>>
An Agent instance.
Type parameters: 'Request, 'Reply, 'State |
Creates and starts a stateful agent that supports request-reply messaging. The processor function computes a reply and updates the state for each request.
|
Full Usage:
Agent.dispose agent
Parameters:
Agent<'a>
-
The agent instance.
Type parameters: 'a |
Disposes the agent and cancels its processing.
|
Full Usage:
Agent.getCurrentQueueLength agent
Parameters:
Agent<'a>
-
The agent instance.
Returns: int
The number of queued messages.
Type parameters: 'a |
Gets the current number of messages in the agent's queue.
|
Full Usage:
Agent.getDefaultTimeout agent
Parameters:
Agent<'a>
-
The agent instance.
Returns: int
The default timeout in milliseconds.
Type parameters: 'a |
Gets the default timeout for reply operations on the agent.
|
Full Usage:
Agent.post msg agent
Parameters:
'a
agent : Agent<'a>
Returns: bool
Type parameters: 'a |
|
Full Usage:
Agent.postAndAsyncReply msg agent
Parameters:
'a
-
The request message.
agent : Agent<'a * AsyncReplyChannel<'b>>
-
The agent instance.
Returns: Async<'b>
An Async computation returning the reply.
Type parameters: 'a, 'b |
Posts a request to the agent and asynchronously waits for a reply.
|
Full Usage:
Agent.postAndAsyncReplyTask msg agent
Parameters:
'a
-
The request message.
agent : Agent<'a * AsyncReplyChannel<'b>>
-
The agent instance.
Returns: Task<'b>
A Task returning the reply.
Type parameters: 'a, 'b |
Posts a request to the agent and returns a Task that completes with the reply.
|
Full Usage:
Agent.postAndReply msg agent
Parameters:
'a
-
The request message.
agent : Agent<'a * AsyncReplyChannel<'b>>
-
The agent instance.
Returns: 'b
The reply value.
Type parameters: 'a, 'b |
Posts a request to the agent and synchronously waits for a reply. When DefaultTimeout is Timeout.Infinite, a configurable fallback timeout is used (AGENT_REPLY_TIMEOUT_MS environment variable, default 30 000 ms). Throws if the reply times out.
|
Full Usage:
Agent.postAndTryAsyncReply timeout msg agent
Parameters:
int
-
Timeout in milliseconds.
msg : 'a
-
The request message.
agent : Agent<'a * AsyncReplyChannel<'b>>
-
The agent instance.
Returns: Async<'b option>
An Async computation returning Some(reply) or None if timed out.
Type parameters: 'a, 'b |
Posts a request to the agent and asynchronously tries to receive a reply within the specified timeout.
|
Full Usage:
Agent.setDefaultTimeout timeout agent
Parameters:
int
-
Timeout in milliseconds.
agent : Agent<'a>
-
The agent instance.
Type parameters: 'a |
Sets the default timeout for reply operations on the agent.
|
Full Usage:
Agent.stopAndDispose stopMsg agent
Parameters:
AsyncReplyChannel<unit> -> 'T
agent : Agent<'T>
Returns: Async<unit>
Type parameters: 'T |
|
Full Usage:
Agent.tryPostAndReply timeout msg agent
Parameters:
int
-
Timeout in milliseconds.
msg : 'a
-
The request message.
agent : Agent<'a * AsyncReplyChannel<'b>>
-
The agent instance.
Returns: 'b option
Some(reply) if successful, None if timed out.
Type parameters: 'a, 'b |
Posts a request to the agent and tries to synchronously receive a reply within the specified timeout.
|
GenPRES