Skip to content

Commit

Permalink
Create null balancer shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
Hilari Moragrega committed Dec 6, 2017
1 parent 37609e6 commit 7f2ab1f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions spec/BalancerBuilderSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,15 @@ function it_can_build_the_balancer(Monitor $monitor, LoggerInterface $logger)
"feature_2" => ["bar" => 20, "rab" => 40, "arb" => 40]
])->shouldImplement(BalancerInterface::class);
}

function it_can_build_a_null_balancer()
{
$balancer = $this->createNullBalancer([
"feature_1" => ["foo" => 50, "off" => 50],
"feature_2" => ["bar" => 20, "rab" => 40, "arb" => 40]
]);

$balancer->shouldImplement(BalancerInterface::class);
$balancer->get("feature_1")->shouldReturn("");
}
}
8 changes: 8 additions & 0 deletions src/BalancerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ public function create(array $config = [])
return $balancer;
}

/**
* @return BalancerInterface
*/
public function createNullBalancer()
{
return new ExceptionSilencerDecorator(new Balancer());
}

/**
* @param Monitor $monitor
* @param string $metric
Expand Down

0 comments on commit 7f2ab1f

Please sign in to comment.