How to create an executor

This documentation is not for the latest version Pacemaker version. Click here to switch to version 1.2

Pipeline Step Executor

Each pipeline step has one executor, which implements the interface \TechDivision\ProcessPipelines\Api\ExecutorInterface.

Abstract Executors

There are some abstract executors, which should be extended by your own executor.

TechDivision\ProcessPipelines\Model\Executor\AbstractExecutor

Base executor, which already implements methods for logging and warnings

TechDivision\ProcessPipelines\Model\Executor\AbstractShellExecutor

Shell executor for run CLI and bash scripts.

Concrete Executors

There are some ready-to-use executors.

TechDivision\ProcessPipelines\Model\Executor\DropCache

Cache invalidation executor

TechDivision\ProcessPipelines\Model\Executor\Reindex

Reindex executor

Usage

In order to use these executors, you need to define them as following in your pipeline.xml.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:TechDivision/ProcessPipelines/etc/pipeline.xsd">
    <pipeline name="example_pipeline" description="Example pipeline for reindex and drop cache">
        <conditions>
            <pipeline_condition type="TechDivision\ProcessPipelines\Helper\Condition\Pipeline\NoAutoSpawn" description="Disable auto spawning"/>
        </conditions>
        <step name="example_reindex" executorType="TechDivision\ProcessPipelines\Model\Executor\Reindex" sortOrder="10" description="" >
            <arguments>
                <argument key="indexes" value="catalog_category_product,catalog_product_category,catalogsearch_fulltext" />
            </arguments>
        </step>
        <step name="example_cache_drop" executorType="TechDivision\ProcessPipelines\Model\Executor\DropCache" sortOrder="20" description="" >
            <arguments>
                <argument key="caches" value="collections,full_page,block_html" />
            </arguments>
            <conditions>
                <step_condition type="TechDivision\ProcessPipelines\Helper\Condition\Step\PreviousStepsCompleted" description="Run after the first step"/>
            </conditions>
        </step>
    </pipeline>
</config>

Testing executors on a local environment (DEV)

While developing a new executor it is necessary to execute them without waiting for heartbeat and without having some runner up and running (see [Cron and Consumer/Runner](./system-cron-consumer.md)). Therefore we introduce the CLI command pipeline:dev:run:executor.

Usage

Run a customer executor in the same way as the runner would do.

bin/magento pipeline:dev:run:executor --arguments='{\"arg1\": \"value-1\", \"arg2\": 2}' --pipeline-id=102 --step-id=1562 '\MyCompany\MyModule\Model\Executor\DoSomeThing'

The options --arguments, --pipeline-id and --step-id are optional. Sometimes there are dependencies inside your executor for these values.