Class SpecialistChangeHandler
- Namespace
- IntentSharp.Specialist
- Assembly
- IntentSharp.Specialist.dll
An opt-in environment change handler that refreshes specialists when a document they depend on changes. On a Document change it finds, in each runtime it watches, the intents that runtime has requested a specialist for and not retired whose definition was loaded from the changed document, or whose DocumentContextSource reads it, and starts RefreshAsync(string, CancellationToken) for each. The handler returns once the refreshes have started: it does not wait for any specialist, so the client's handler timeout never runs while a specialist is awaited.
public sealed class SpecialistChangeHandler : IEnvironmentChangeHandler
- Inheritance
-
objectSpecialistChangeHandler
- Implements
- Inherited Members
-
object.Equals(object)object.Equals(object, object)object.GetHashCode()object.GetType()object.ReferenceEquals(object, object)object.ToString()
- Extension Methods
Remarks
The client must exist before a runtime can be created over it, so create the handler first, register it on the
builder with AddEnvironmentChangeHandler (or as an IEnvironmentChangeHandler service), and call
Watch(SpecialistRuntime) with each runtime once it exists. A change to an intent's definition reloads the runtime's
catalog before the refresh. An intent the runtime has not handled yet is left alone: its first run requests a
specialist as usual. A refresh that fails is logged as a Warning on the runtime's logger and changes nothing else.
Constructors
- SpecialistChangeHandler()
Creates a handler that watches no runtime yet.
Properties
- Runtimes
The runtimes watched.
Methods
- Watch(SpecialistRuntime)
Watches
runtimefrom now on. Watching one runtime twice changes nothing.
- WhenRefreshedAsync(CancellationToken)
Waits for the refreshes this handler started so far to end, whether each succeeded or failed. For tests and for an orderly shutdown; the handler itself never waits for them.