Download the PHP package pluggit/feature-balancer without Composer
On this page you can find all versions of the php package pluggit/feature-balancer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pluggit/feature-balancer
More information about pluggit/feature-balancer
Files in pluggit/feature-balancer
Package feature-balancer
Short Description This PHP library will allow to switch on/off or balance with a percentage between features
License proprietary
Informations about the package feature-balancer
Feature Balancer
This PHP library will allow to switch on/off or balance with a percentage between features
TLDR;
Building the balancer
The library comes with a builder to ease the creation of the balancer.
Adding logging
If you install the Psr\Log
library you can add logging to every decision made by the balancer. You can choose the log level that will be use to record log entries
Adding monitoring
If you install the pluggit\monitoring
library you can add monitoring to every decision made by the balancer.
You have to choose the metric name to increment
Hiding exceptions
If you don't wan't the feature balancer to throw exceptions, you can silence it with the ExceptionSilencerDecorator
. It will log the errors and return "" as path for the requested feature
Adding features to the balancer
You can always add features to the balancer trough the method add
. The rules are:
- Every feature must have a non-empty unique string identifier, adding the same feature will overwrite the previous configuration
- Every feature must have at least one possible path
- Every feature path must have a non-empty unique string identifier for the given feature
- Every path has assigned a percentage
- The percentage for every path has to be an unsigned integer between 0 and 100
- All the path percentages must sum exactly 100
Any violation of the following rules will make the balancer throw a Cmp\FeatureBalancer\Exception\InvalidArgumentException
exception
Valid examples
Invalid examples
Getting a path
Once you have configured a feature, you can request a path to the balancer
Random Non-deterministic retrieval
If you don't pass a seed, the path will be choosen randomly taking into account the defined percentages
Seed based deterministic retrieval
If you pass a seed, the path will be decided using a simple yet infallible algorithm so that for every given configuration and seed, it will always choose the same path
NOTE This means that the path can change if either the configuration or the seed changes
You can pass both signed numbers (integers and doubles) or non-empty strings as seed