承接 convertim/variantretriever 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

convertim/variantretriever

最新稳定版本:v1.0.0

Composer 安装命令:

composer require convertim/variantretriever

包简介

README 文档

README

VariantRetriever is a minimalist package for feature flagging. It's fast, database free and idempotent library to choose over a set of variants.

Getting Started

First of all, you need to define an Experiment with a name and it variants. Variant requires 2 arguments, a name and a rollout percentage (50% by default). Then create a variant retriever with this experiment and variants, and ask it to retrieve a variant for a resource (in the following code, it's for a user uuid).

$variantRetriever = new VariantRetriever();
$experiment = new Experiment('my-ab-test', ...[new Variant('control1'), new Variant('variant2')]);
$variantRetriever->addExperiment($experiment);

$affectedVariant = $variantRetriever->getVariantForExperiment(new Experiment('my-ab-test'), '77d8a1d5-97ba-42db-a4a7-3b9562f0ff22');

var_dump((string) $affectedVariant); // string(7) "variant2"

Running the Test Suite

VariantRetriever uses Pest PHP as testing framework. Once you have all dependencies installed via composer install, you can run the test suite with:

.php phing tests

To obtain the code coverage report, you'll need to have xdebug installed. Then, you can run:

.php phing tests-coverage

And this will give you detailed information about code coverage.

What about speed

VariantRetriever is fast. In our test, we ensure that the retriever is able to get 50 000 variants to randomly generate different identifiables in less than 1 second. Local dev machine can run 500 000 runs in less than a second.

What about randomness

Rows Rollout Rollout Max Rollout difference
1k 50/50 46.5/46.5 3.5%
500k 50/50 49.87/49.87 0.13%
500k 10*10 9.88 0.12%
500k 10/10/80 9.88/9.88/79.92 0.12%

统计信息

  • 总下载量: 2.17k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-14