Class ScriptedSpecialistService
- Namespace
- IntentSharp.Specialist.Testing
- Assembly
- IntentSharp.Specialist.dll
An in-process specialist service for tests. Answers each request from a queue of offers, in order, or from a function
of the request; can answer "not yet" a set number of times per request first; recalls a held specialist whose offer
brought a provider when it answered that offer itself; and records every request, wait, fit report, retire and
recall, as ScriptedProvider records requests. Nothing leaves the process. Thread-safe.
public sealed class ScriptedSpecialistService : ISpecialistService
- Inheritance
-
objectScriptedSpecialistService
- Implements
- Inherited Members
-
object.Equals(object)object.Equals(object, object)object.GetHashCode()object.GetType()object.ReferenceEquals(object, object)object.ToString()
- Extension Methods
Constructors
- ScriptedSpecialistService(params SpecialistOffer[])
Creates a service that answers requests with
offers, one per request, in order. Once the queue is empty, every wait answers "not yet".
- ScriptedSpecialistService(Func<SpecialistRequest, SpecialistOffer?>)
Creates a service that computes the offer for each request. A null offer answers "not yet" to every wait on that request.
Properties
- CanRecall
True, the default, makes RecallAsync(HeldSpecialist, CancellationToken) hand back the offer this instance gave for the held record's ticket; false makes it answer that it cannot recall, as a service without the ability does.
- FitReports
Every fit report received, in order.
- HoldNotYet
True makes each "not yet" answer take the whole timeout of the wait, as a real service that holds the call open would. Default false: "not yet" is answered at once.
- Name
The service's name, recorded on its tickets. Default "Scripted".
- NotYetCount
How many waits on each request answer "not yet" before the offer is given. Default 0.
- Recalls
Every held record it was asked to recall, in order, whether or not it could.
- Requests
Every request received, in order.
- Retired
Every ticket retired, in order.
- TimeProvider
The clock for RequestedAt and held waits. Default the system clock.
- Waits
Every wait answered, in order.
Methods
- Enqueue(SpecialistOffer)
Adds an offer to the queue.
- RecallAsync(HeldSpecialist, CancellationToken)
Hands back the offer this instance gave for the held record's ticket, when CanRecall is on and that offer brought a provider; otherwise null. Records the record in Recalls either way.
- ReportFitAsync(SpecialistTicket, FitReport, CancellationToken)
Tells the service whether its offer met the requirement, and why not when it did not.
- RequestAsync(SpecialistRequest, CancellationToken)
Sends a request and returns the ticket for it. It does not wait for the specialist.
- RetireAsync(SpecialistTicket, CancellationToken)
Tells the service the application no longer uses the specialist of
ticket.
- ReturnRequested(IAIProvider, string?, string?)
A responder that hands back the requested definition unchanged, to run on
provider, which the runtime reaches through its SpecialistRouter.
- ReturnRequested(string, string?, string?)
A responder that hands back the requested definition unchanged, to run on the provider configured on the client under
providerName, with the request hash recorded in the offer's facts.
- WaitAsync(SpecialistTicket, TimeSpan, CancellationToken)
Waits up to
timeoutfor the specialist ofticket. Returns the offer once it is ready, or null when it is not ready yet. Either hold the call until the offer is ready or the timeout ends, or answer null at once: within its wait, the runtime asks again after WaitPollInterval with the time left. Never wait past the timeout: the runtime ends the call there and counts it as not ready.