QaaS.Framework.Policies¶
QaaS.Framework.Policies contains the Framework solution's policy-chain implementation for repeated communication actions. The package is responsible for turning policy configuration objects into runtime policy instances and then executing those policies in a stable order.
What this project contains¶
Core policy chain¶
The chain model is implemented in:
Policy.csPolicyBuilder.csPolicies.cs
Policy is the runtime base for the chain. It exposes the mechanics for adding the next policy, preparing the chain, and executing it. PolicyBuilder is the configuration-to-runtime bridge. It accepts one concrete IPolicyConfig implementation at a time and builds the corresponding runtime policy instance.
Simple policy implementations¶
The package contains three direct policy types for common control behavior:
CountPolicy.csTimeoutPolicy.csLoadBalancePolicy.cs
These policies cover limiting execution by count, limiting it by time, and pacing it at a fixed rate.
Advanced load-balance policies¶
The AdvancedLoadBalance folder contains:
AdvancedLoadBalancePolicy.csIncreasingLoadBalancePolicy.csLoadBalanceStage.cs
This part of the project handles multi-stage and ramping load behavior. It is where the package models stage-by-stage execution rates and timed or count-based stage transitions.
Configuration objects¶
The ConfigurationObjects folder contains the public configuration model used by the builder:
CountPolicyConfig.csTimeoutPolicyConfig.csLoadBalancePolicyConfig.csIncreasingLoadBalancePolicyConfig.csAdvancedLoadBalancePolicyConfig.csIPolicyConfig.cs
AdvancedLoadBalancePolicyConfig also defines StageConfig, which is the package's stage model. Each stage can define a Rate, Amount, TimeoutMs, and TimeIntervalMs.
Exceptions and timing abstraction¶
The project also contains:
Exceptions/CountStop.csExceptions/TimeoutStop.csExceptions/StopAction.csExtentions/Stopwatch/ITimer.csExtentions/Stopwatch/Timer.cs
These types support stop conditions and time-based execution without hard-coding the timing implementation everywhere.
Current behavior¶
The current implementation behaves as follows:
PolicyBuilder.Configure(IPolicyConfig)accepts a single concrete policy-config type and stores the matching configuration.PolicyBuilder.Build()fails if no supported config was supplied or if more than one config type was supplied at once.PolicyBuilder.BuildPolicies()chains multiple built policies together by repeatedly callingPolicy.Add(...).Policy.Add(...)preserves index-based ordering inside the chain.Policy.RunChain()executes the chain and convertsStopActionException-based stop conditions into afalseresult instead of letting the exception escape as normal flow.CountPolicystops after the configured number of actions.TimeoutPolicystops after the configured timeout window.LoadBalancePolicymaintains a steady rate over the configured interval.IncreasingLoadBalancePolicyincreases the rate only after the configured interval has elapsed.AdvancedLoadBalancePolicyexecutes staged load behavior and advances stages according toAmountorTimeoutMs, while protecting the final stage from overflowing into an invalid next stage.
Main source areas¶
The most important files and folders in this package are:
Policy.csPolicyBuilder.csCountPolicy.csTimeoutPolicy.csLoadBalancePolicy.csAdvancedLoadBalance/ConfigurationObjects/Exceptions/Extentions/Stopwatch/
Companion tests¶
QaaS.Framework.Policies.Tests is the sibling test project for this package.
The current tests cover:
- policy-chain ordering
- chain setup and execution flow
- count-based stopping
- timeout-based stopping
- stop-exception behavior
- builder mapping from config objects to runtime policy classes
- advanced stage progression and final-stage protection
- increasing-load timing behavior
Representative test files include:
PolicyBehaviorTests.csLoadBalancePolicyTests.csPolicyValidationCoverageTests.cs