Added beacon events
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Cachet.
|
||||||
|
*
|
||||||
|
* (c) Alt Three Services Limited
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace CachetHQ\Cachet\Bus\Events\Beacon;
|
||||||
|
|
||||||
|
use CachetHQ\Cachet\Bus\Events\EventInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the beacon event interface.
|
||||||
|
*
|
||||||
|
* @author James Brooks <james@alt-three.com>
|
||||||
|
*/
|
||||||
|
interface BeaconEventInterface extends EventInterface
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Cachet.
|
||||||
|
*
|
||||||
|
* (c) Alt Three Services Limited
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace CachetHQ\Cachet\Bus\Events\Beacon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the beacon failed to send event.
|
||||||
|
*
|
||||||
|
* @author James Brooks <james@alt-three.com>
|
||||||
|
*/
|
||||||
|
final class BeaconFailedToSendEvent implements BeaconEventInterface
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Cachet.
|
||||||
|
*
|
||||||
|
* (c) Alt Three Services Limited
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace CachetHQ\Cachet\Bus\Events\Beacon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the beacon was sent event.
|
||||||
|
*
|
||||||
|
* @author James Brooks <james@alt-three.com>
|
||||||
|
*/
|
||||||
|
final class BeaconWasSentEvent implements BeaconEventInterface
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
@@ -21,6 +21,12 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $listen = [
|
protected $listen = [
|
||||||
|
'CachetHQ\Cachet\Bus\Events\Beacon\BeaconFailedToSendEvent' => [
|
||||||
|
//
|
||||||
|
],
|
||||||
|
'CachetHQ\Cachet\Bus\Events\Beacon\BeaconWasSentEvent' => [
|
||||||
|
//
|
||||||
|
],
|
||||||
'CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupWasAddedEvent' => [
|
'CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupWasAddedEvent' => [
|
||||||
//
|
//
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ use CachetHQ\Cachet\Models\Incident;
|
|||||||
use CachetHQ\Cachet\Models\Metric;
|
use CachetHQ\Cachet\Models\Metric;
|
||||||
use CachetHQ\Cachet\Models\User;
|
use CachetHQ\Cachet\Models\User;
|
||||||
use CachetHQ\Cachet\Settings\Repository as Setting;
|
use CachetHQ\Cachet\Settings\Repository as Setting;
|
||||||
|
use CachetHQ\Cachet\Bus\Events\Beacon\BeaconWasSentEvent;
|
||||||
|
use CachetHQ\Cachet\Bus\Events\Beacon\BeaconFailedToSendEvent;
|
||||||
use Exception;
|
use Exception;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use Illuminate\Contracts\Config\Repository;
|
use Illuminate\Contracts\Config\Repository;
|
||||||
@@ -110,6 +112,11 @@ class Beacon implements BeaconContract
|
|||||||
]);
|
]);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
// TODO: Log a warning that the beacon could not be sent.
|
// TODO: Log a warning that the beacon could not be sent.
|
||||||
|
event(new BeaconFailedToSendEvent());
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event(new BeaconWasSentEvent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Cachet.
|
||||||
|
*
|
||||||
|
* (c) Alt Three Services Limited
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace CachetHQ\Tests\Cachet\Bus\Events\Beacon;
|
||||||
|
|
||||||
|
use AltThree\TestBench\EventTrait;
|
||||||
|
use CachetHQ\Cachet\Bus\Events\Beacon\BeaconEventInterface;
|
||||||
|
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the abstract beacon event test case.
|
||||||
|
*
|
||||||
|
* @author James Brooks <james@alt-three.com>
|
||||||
|
*/
|
||||||
|
abstract class AbstractBeaconEventTestCase extends AbstractTestCase
|
||||||
|
{
|
||||||
|
use EventTrait;
|
||||||
|
|
||||||
|
protected function getEventInterfaces()
|
||||||
|
{
|
||||||
|
return [BeaconEventInterface::class];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Cachet.
|
||||||
|
*
|
||||||
|
* (c) Alt Three Services Limited
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace CachetHQ\Tests\Cachet\Bus\Events\Beacon;
|
||||||
|
|
||||||
|
use CachetHQ\Cachet\Bus\Events\Beacon\BeaconFailedToSendEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the beacon was sent event test.
|
||||||
|
*
|
||||||
|
* @author James Brooks <james@alt-three.com>
|
||||||
|
*/
|
||||||
|
class BeaconFailedToSendEventTest extends AbstractBeaconEventTestCase
|
||||||
|
{
|
||||||
|
protected function objectHasHandlers()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getObjectAndParams()
|
||||||
|
{
|
||||||
|
$params = [];
|
||||||
|
$object = new BeaconFailedToSendEvent();
|
||||||
|
|
||||||
|
return compact('params', 'object');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Cachet.
|
||||||
|
*
|
||||||
|
* (c) Alt Three Services Limited
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace CachetHQ\Tests\Cachet\Bus\Events\Beacon;
|
||||||
|
|
||||||
|
use CachetHQ\Cachet\Bus\Events\Beacon\BeaconWasSentEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the beacon was sent event test.
|
||||||
|
*
|
||||||
|
* @author James Brooks <james@alt-three.com>
|
||||||
|
*/
|
||||||
|
class BeaconWasSentEventTest extends AbstractBeaconEventTestCase
|
||||||
|
{
|
||||||
|
protected function objectHasHandlers()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getObjectAndParams()
|
||||||
|
{
|
||||||
|
$params = [];
|
||||||
|
$object = new BeaconWasSentEvent();
|
||||||
|
|
||||||
|
return compact('params', 'object');
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user