async-bot/github-status-plugin

GitHub status plugin

dev-master 2019-11-29 20:42 UTC

This package is auto-updated.

Last update: 2024-11-29 06:47:05 UTC


README

Latest Stable Version Build Status Coverage Status License

This plugin emit an event when the uptime status of GitHub services change.

Requirements

  • PHP 7.4

Installation

composer require async-bot/github-status-plugin

Usage

Initialization

$plugin = new Plugin(
    \AsyncBot\Logger\Factory::buildConsoleLogger(),
    new \AsyncBot\Plugin\Retreiever\Http(new \Amp\Http\Client\Client(), new \AsyncBot\Plugin\GitHubStatus\Parser\Html()),
    new \AsyncBot\Plugin\GitHubStatus\Storage\InMemoryStorage(),
);

Attaching an event listener

If the GitHub status changes an event will be emitted which can be subscribed to. The registered event listener will get an \AsyncBot\Plugin\GitHubStatus\Event\Data\Status object passed which contains information about the status change.

$plugin->onStatusChange(new class implement \AsyncBot\Plugin\GitHubStatus\Event\Listener\StatusChange {
    /**
     * @return Promise<null>
     */
    public function __invoke(Status $status): Promise
    {
        var_dump($status);

        return new Success();
    }
});