ServerObserver interface in Aerys

The ServerObserver interface is necessary to be able to watch for state changes of the Server.

update(Server): Promise

The only method of this interface; it is called each time when the Server changes its state. It is guaranteed that nothing further happens until all the Promises returned by each attached ServerObserver have been resolved (or eventually timed out).


class MyObserver implements Aerys\Bootable, Aerys\ServerObserver {
	function boot(Aerys\Server $server, Aerys\Logger $logger) {

	function update(Aerys\Server $server): Amp\Promise {
		switch ($server->state()) {
			case Aerys\Server::STARTING: /* ... */ break;
			case Aerys\Server::STARTED: /* ... */ break;
			case Aerys\Server::STOPPING: /* ... */ break;
			case Aerys\Server::STOPPED: /* ... */ break;
		return new Amp\Success;