innmind/installation-monitor

Simple socket to accumulate and dispatch system events

3.1.0 2021-02-15 17:05 UTC

This package is auto-updated.

Last update: 2024-11-16 01:41:13 UTC


README

Build Status codecov Type Coverage

Tool to listen and redispatch events from/to other applications.

This is useful to let applications configure themselves when installing them. Take for example an application B that depends on an application A, A can emit an event to this tool and when the installation of B starts it can ask this tool to send it all the events it has recorded.

Installation

composer require innmind/installation-monitor

Usage

First step is to start the server that will aggregate the events:

installation-monitor oversee --daemon

Then from your application you can send an event like so :

use function Innmind\InstallationMonitor\bootstrap;
use Innmind\InstallationMonitor\Event;
use Innmind\Immutable\{
    Map,
    Sequence,
};

$client = bootstrap()['client']['ipc']();
$client->send(
    new Event(
        new Event\Name('foo'),
        $payload = Map::of('string', 'scalar|array')
    ),
    new Event(
        new Event\Name('bar'),
        $payload = Map::of('string', 'scalar|array')
    )
    // etc...
);
// or
$client->events(); // Sequence<Event> all the events recorded by the server