Feedback from 1 year of life
with 400 microservices
and growing...
/**
* @param float $amount
* @param string $user_id
* @param string $auction_id
*/
class AuctionRaiseCommand extends Command
{
public static $handlers = [
AddUserToAuction::class,
CheckBidAmount::class,
NotifyParticipants::class
];
public function __construct(array $attributes = [])
{
// Validate given data
parent::__construct($attributes);
}
}
class AddUserToAuction
{
protected $auction;
public function __construct(AuctionRepository $auction)
{
$this->auction = $auction;
}
public function handle(AuctionRaiseCommand $command)
{
}
}
$bus = new SimpleBus();
$bus->handle(new AuctionRaiseCommand([
'user_id'=> '',
'auction_id'=>'',
'amount' => ''
]));
class AuctionCommand implements RetryOnFail, IsHandledAsynchronously
{
public function getMaxRetry();
public function getWorker();
public function getRetryDelay($tried);
}
$bus = new SimpleBus();
$bus->appendMiddleware(new AsynchronousMiddleware());
$bus->appendMiddleware(new RetryOnFailMiddleware());
class Worker extends Console
{
protected $signature = 'worker {--bind=tcp://0.0.0.0:25001}';
public function handle(Httpd $httpd)
{
$httpd->route('PUT', '/', function($request, $response) {
$response->send("OK")
->subscribeCallback(null, null, function() use($request) {
SyncBus::handle($request->getCommand());
});
});
$httpd->listen($this->option('bind'));
}
}
$push = $zmq->push("tcp://publisher.svc.domraider.com:23499");
$push->send(new AuctionRaisedEvent());
$pull = $zmq->pull("tcp://0.0.0.0:23499");
$pull->subscribeCallback(function(AuctionRaisedEvent $event) {
foreach($this->webSocket->sessions as $session) {
$session->send($event);
}
});
kubectl scale --replicas=5 rc AuctionWorker
kubectl rolling-update --image=domraider/worker:1.3.7 AuctionWorker
Le mariage sert à régler à deux
des problèmes que l'on aurait jamais eu
si on était resté tout seul.
composer install
cp docker/worker/Dockerfile .
cp docker/worker/.dockerignore .
docker build -t worker:$version .
docker tag latest worker:$version
docker push worker:$version
docker push worker:latest