Interface ISpecialistStore
- Namespace
- IntentSharp.Specialist
- Assembly
- IntentSharp.Specialist.dll
Where a SpecialistRuntime keeps what it knows about its requests: the ticket of each request by intent and request hash, the offer and the fit report for it, the times of the requests for the hourly limit, and the held record of the specialist in use for each intent (HeldSpecialist). InMemorySpecialistStore is the default; implement it over a database to keep requests across restarts, so a restarted application waits on its open requests instead of sending new ones. Implementations must be thread-safe.
public interface ISpecialistStore
- Extension Methods
Methods
- AbandonRequestAsync(string, string, CancellationToken)
Called by the runtime when a request it began with BeginRequestAsync(string, string, int, DateTimeOffset, CancellationToken) could not be sent, so another caller may send it. The request's time stays recorded. The default does nothing.
- BeginRequestAsync(string, string, int, DateTimeOffset, CancellationToken)
Called by the runtime before it sends a request, to decide who sends it: returns the ticket when one is already recorded for the intent and request hash; the hourly limit when the intent had
maxRequestsPerHourrequests in the hour beforenow; that another caller is sending it; or that this caller sends it, in which case the request is recorded atnowand counts toward the limit. The default reads the ticket and the count and then records the request, which is not atomic: a store that several processes share overrides it so that one of them sends each request and the limit holds across them, as DocumentSpecialistStore does.
- CountRequestsAsync(string, DateTimeOffset, CancellationToken)
The number of requests recorded for the intent at or after
since.
- GetFitReportAsync(string, string, CancellationToken)
The fit report recorded for the intent and request hash, or null.
- GetHeldAsync(string, CancellationToken)
The held record of the intent, or null. The default answers null.
- GetOfferAsync(string, string, CancellationToken)
The offer recorded for the intent and request hash, or null.
- GetTicketAsync(string, string, CancellationToken)
The ticket recorded for the intent and request hash, or null.
- ListHeldAsync(CancellationToken)
Every held record, one per intent, in no set order. The default answers none.
- RecordRequestAsync(string, DateTimeOffset, CancellationToken)
Records that a request was sent for the intent at
at.
- RemoveAsync(string, string, CancellationToken)
Forgets the ticket, the offer and the fit report recorded for the intent and request hash. The request times stay.
- RemoveHeldAsync(string, CancellationToken)
Forgets the held record of the intent. The default does nothing.
- SaveFitReportAsync(string, FitReport, CancellationToken)
Records the verdict on the offer of a request, under its RequestHash.
- SaveHeldAsync(HeldSpecialist, CancellationToken)
Keeps the held record of the specialist put in use for an intent, replacing the one held for that intent before. The default keeps nothing, so a store that does not implement the held members never recalls a specialist.
- SaveOfferAsync(string, string, SpecialistOffer, CancellationToken)
Records the offer received for a request.
- SaveTicketAsync(string, SpecialistTicket, CancellationToken)
Records the ticket of a request, under its request hash.