Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
77 lines (53 sloc) 2.94 KB

Operation runner

Factory

When using simple operation runners, you can create them using the YML configuration of the bundle. Each operation runner have a name (default in the following example). The created operation runner will be available via the service named tolerance.operation_runner.default.

tolerance:
    operation_runners:
        default:
            retry:
                runner:
                    callback: ~

                waiter:
                    count_limited:
                        count: 10
                        waiter:
                            exponential_back_off:
                                exponent: 1
                                waiter:
                                    sleep: ~

In that example, that will create a operation runner that is the retry operation runner decorating a callable operation runner. The following image represents the imbrication of the different runners.

../../_static/runner-factory.png

Note

This YML factory do not support recursive operation runner. That means that you can't use a chain runner inside another chain runner. If you need to create more complex operation runners, you should create your own service with a simple factory like the one that was in the tests before this YML factory.

Tip

If you just need to add a decorator on a created operation runner, simply uses Symfony DIC decorates features.

Buffered termination

If you are using a buffered operation runner, it will automatically run all the buffered operations after the response it sent to the client (kernel.terminate event).

You can disable this feature with the following configuration:

tolerance:
    operation_runner_listener: false

This will automatically work with operation runners created using the factory. If you've created your own service, you will need to tag it with tolerance.operation_runner in order to declare it.

<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <services>
        <service id="app.my_buffered_operation_runner" class="Tolerance\Operation\Runner\BufferedOperationRunner">
            <!-- Arguments... -->

            <tag name="tolerance.operation_runner" />
        </service>
    </services>
</container>