Class RuleCompileExtensions
- Namespace
- IntentSharp.Guardrails
- Assembly
- IntentSharp.Guardrails.dll
Turns on the compilation of the rules a client's rule files write as intent, which is off until one of these is called. On the builder:
var store = new FolderDocumentStore("policy");
using var client = new IntentClientBuilder()
.UseProviderOptions(store)
.WithDocumentStore(store)
.WithGuardrailFiles(store, "orders-data")
.WithRuleCompilation(store)
.Build();
For the client AddIntentSharp builds:
services.AddDocumentStore(store);
services.AddGuardrails(store, "orders-data");
services.AddRuleCompilation();
services.AddIntentSharp(configuration);
[Experimental("INTENTSHARP001")]
public static class RuleCompileExtensions
- Inheritance
-
objectRuleCompileExtensions
- Inherited Members
-
object.Equals(object)object.Equals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()object.ReferenceEquals(object, object)object.ToString()
Remarks
Experimental (INTENTSHARP001): the compile output and its companion format, rules-compiled/1, may change
in a later version, so a call to either member is a compiler error until the diagnostic is suppressed. A rule set
compiles only when its rule file has intent:, target: and compile:; a rule file with
intent: and no target: does not load.
Methods
- AddRuleCompilation(IServiceCollection, Action<RuleCompileOptions>?)
Registers a RuleCompileHandler as an IEnvironmentChangeHandler for the client
AddIntentSharpbuilds, over the store and the manifest that AddGuardrails(IServiceCollection, IDocumentStore, params string[]) registered, so a target's schema change, or a change of a rule file'sintent:text, compiles the rule sets written for that target into their companions through the client's edit seam. Compilation is opt-in:AddGuardrailsdoes not register it. The handler knows the kinds, subjects and settingsAddGuardrailsdeclared and those registered in the container.
- WithRuleCompilation(IntentClientBuilder, IDocumentStore, Action<RuleCompileOptions>?)
Adds a RuleCompileHandler over
storeto the client's environment change handlers, so a target's schema change, or a change of a rule file'sintent:text, compiles the rule sets written for that target into their companions through the client's edit seam. Compilation is opt-in: WithGuardrailFiles(IntentClientBuilder, IDocumentStore, params string[]) does not add it. The client must use the same store (WithDocumentStore(IDocumentStore)), since the companion is submitted as an edit of the client's store, and must validate rule documents with a RuleDocumentValidator, whichWithGuardrailFilesadds: a companion no validator handles is refused by the edit seam, and the version that ran before keeps running.