Skip to content

Commit 84cc03b

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 443f8f9 + 6c3b0c9 commit 84cc03b

File tree

2 files changed

+138
-0
lines changed

2 files changed

+138
-0
lines changed

config.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ hasChildren = true
8080
url = "core-concept/satellite/http-api"
8181
weight = 5
8282

83+
[[menu.main]]
84+
parent = "Core concepts"
85+
name = "Action"
86+
url = "core-concept/satellite/action"
87+
weight = 6
88+
8389
[[menu.main]]
8490
weight = 3
8591
name = "Features"
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
title: "Action"
3+
date: 2023-07-06T15:06:20+02:00
4+
draft: false
5+
weight: 4
6+
---
7+
8+
{{< feature-state for_mw_version="0.1" state="alpha" >}}
9+
10+
- [What is it for?](#what-is-it-for)
11+
- [Installation](#installation)
12+
- [Basic Usage](#basic-usage)
13+
- [Advanced Usage](#advanced-usage)
14+
- [Using expressions](#using-expressions)
15+
- [Adding logger](#adding-logger)
16+
- [Adding state](#adding-state)
17+
18+
---
19+
20+
> An action is a process that enables a task to be carried out before, during or at the end of the execution of a workflow.
21+
> For example, an action can be used to retrieve or upload files to an SFTP server.
22+
23+
## What is it for?
24+
25+
This package provides a process capable of executing actions.
26+
27+
## Installation
28+
29+
```shell
30+
composer require php-etl/action
31+
```
32+
33+
## Basic usage
34+
35+
At present, actions can only be used within a workflow. It is therefore not currently possible to launch an action on its own.
36+
37+
```yaml
38+
workflow:
39+
jobs:
40+
- action: # ...
41+
```
42+
43+
We've made sure that you can use your own actions.
44+
45+
You need to implement the `Kiboko\Contract\Action\Interface` and in the `execute` method, you simply write your script.
46+
47+
```php
48+
<?php
49+
50+
namespace App;
51+
52+
final readonly class MyCustomAction implements ActionInterface
53+
{
54+
public function execute(): void
55+
{
56+
// write your script here
57+
}
58+
}
59+
```
60+
61+
Once you've written your action, you need to use it in your Satellite using the custom action plugin like this :
62+
63+
```yaml
64+
workflow:
65+
jobs:
66+
- action:
67+
custom:
68+
use: 'App\MyCustomAction'
69+
services:
70+
App\MyCustomAction:
71+
public: true
72+
```
73+
74+
## Advanced usage
75+
76+
### Using expressions
77+
78+
It's possible to use expressions in your pipeline using the `expression_language` option. To use these expressions,
79+
you need to use our customised Providers which provide the different expressions. For more information, please visit
80+
the [detailed documentation](../../../feature/expression-language) of the language expressions.
81+
82+
```yaml
83+
action:
84+
expression_language:
85+
- 'Kiboko\Component\Satellite\ExpressionLanguage\Provider'
86+
```
87+
88+
### Adding logger
89+
90+
It's possible to add a `logger` at each action of a workflow.
91+
92+
For more details, go to the [detailed logger documentation](../../../feature/logger).
93+
94+
```yaml
95+
satellite:
96+
# ...
97+
workflow:
98+
jobs:
99+
- action:
100+
# ...
101+
logger:
102+
channel: pipeline
103+
destinations:
104+
- elasticsearch:
105+
level: warning
106+
hosts:
107+
- http://user:password@elasticsearch.example.com:9200
108+
```
109+
110+
### Adding state
111+
112+
It's possible to add a `state` at each action of a workflow.
113+
114+
For more details, go to the [detailed state documentation](../../../feature/state)
115+
116+
```yaml
117+
satellite:
118+
# ...
119+
workflow:
120+
jobs:
121+
- action:
122+
# ...
123+
state:
124+
destinations:
125+
- rabbitmq:
126+
host: rabbitmq.example.com
127+
vhost: /
128+
topic: foo.rejects
129+
```
130+
131+
> As you can see, actions are only able to manage the logs and states of their processes,
132+
> but cannot deal with rejects that are contrary to pipelines.

0 commit comments

Comments
 (0)