Class RDWebKeptMachines
- Namespace
- RDCore.Web.Machines
- Assembly
- RDCore.Web.dll
The machines of an RD-VBA program that are kept between requests, each for a key: a request with that key runs on that machine, which is never reset, so its module-level variables, its objects and the rest of its state are what the requests before it left.
public sealed class RDWebKeptMachines : IAsyncDisposable
- Inheritance
-
RDWebKeptMachines
- Implements
- Inherited Members
Remarks
- A request that makes a machine makes it for its key, then runs on it; one whose key has a machine already is not run. Any other request runs on the machine of its key, once its machine is free: one invocation at a time per machine, in the order they arrive. A request waits without holding a thread.
- A request that ends with Completed, RuntimeError or NotFound leaves its machine kept. Any other outcome, an invocation that throws, and a machine that is abandoned end it: the machine is disposed, and its key has no machine afterwards.
- A machine that has had no request for IdleTimeout is disposed.
- A request that waits for its machine past RequestTimeout answers Refused. One that runs past it is cancelled, and a machine that has not stopped StopTimeout later is abandoned: its request answers Interrupted, and the machine is disposed if it ever ends.
Constructors
RDWebKeptMachines(IComposedProgram, RDWebKeptMachinesOptions, TimeProvider?)
Makes the registry of the kept machines of a program, with no machine kept.
public RDWebKeptMachines(IComposedProgram program, RDWebKeptMachinesOptions options, TimeProvider? timeProvider = null)
Parameters
programIComposedProgramThe program whose machines are kept, each a session of its own. The registry does not dispose it.
optionsRDWebKeptMachinesOptionsThe registry's limits.
timeProviderTimeProviderThe clock of the deadlines; System by default.
Exceptions
- ArgumentOutOfRangeException
MaxMachines is less than 1, or a timeout is not positive.
Properties
Count
How many machines are kept: made, or being made.
public int Count { get; }
Property Value
Methods
DisposeAsync()
Disposes the registry: it takes no more requests, and disposes each machine, now when it is free, or when its request ends. The registry does not dispose the program: its owner does, once the registry is disposed.
public ValueTask DisposeAsync()
Returns
- ValueTask
A task that completes when the free machines and the registry's own work have ended.
InvokeAsync(string, ProgramInvocation, bool, CancellationToken)
Runs the invocation on the machine kept for the key, once it is free; a request that makes a machine makes it first.
public Task<RDWebKeptMachineAnswer> InvokeAsync(string key, ProgramInvocation invocation, bool makesMachine, CancellationToken cancellationToken)
Parameters
keystringThe key of the machine, as the request names it.
invocationProgramInvocationThe procedure, and its arguments.
makesMachineboolWhether the request makes the machine of its key.
cancellationTokenCancellationTokenCancels the wait for the machine, and the invocation: the request was aborted.
Returns
- Task<RDWebKeptMachineAnswer>
Served with what the machine answered: Refused when the machine was not free before the request's deadline, and Interrupted when it did not stop after it. Otherwise why the request reached no machine.
Exceptions
- OperationCanceledException
cancellationTokenwas cancelled before the machine was free.- ObjectDisposedException
The registry is disposed.