Skip to content

Decorate the operating system

The framework exposes an instance of OperatingSystem in all configuration methods of Application offering you a wide range of abstractions. You can enhance its capabilities by adding a decorator on top of it.

For example innmind/operating-system comes with a decorator that use an exponential backoff strategy for the http client.

use Innmind\Framework\{
    Main\Cli,
    Main\Http,
    Application,
};
use Innmind\OperatingSystem\{
    OperatingSystem,
    OperatingSystem\Resilient,
};

new class extends Http|Cli {
    protected function configure(Application $app): Application
    {
        return $app->mapOperatingSystem(
            static fn(OperatingSystem $os) => Resilient::of($os),
        );
    }
};

Now everything that relies on $os->remote()->http() will use this exponential backoff strategy.