Skip to content

Commit f2586cb

Browse files
author
Xavier Marchegay
committed
#145 Add documentation/examples for Basic and debug tasks
1 parent 7c2329e commit f2586cb

15 files changed

+245
-37
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Services must be prefixed with the bundle alias instead of using fully qualified
2323
* [#147](https://github.com/cleverage/process-bundle/issues/147) Add missing dependencies on `symfony/dotenv` and `symfony/runtime`
2424
* [#147](https://github.com/cleverage/process-bundle/issues/147) Remove dependencies on `symfony/form`, `symfony/messenger` & `symfony/scheduler`
2525
* [#146](https://github.com/cleverage/process-bundle/issues/146) eav-process-bundle, enqueue-process-bundle, cache-process-bundle and process-soap-bundle were deprecated / archived.
26+
* [#141](https://github.com/cleverage/process-bundle/issues/141) Add a default value to the node "default_error_strategy"
2627

2728
### Fixes
2829

docs/index.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
- Basic and debug
2323
- [ConstantOutputTask](reference/tasks/constant_output_task.md)
2424
- [ConstantIterableOutputTask](reference/tasks/constant_iterable_output_task.md)
25-
- [CounterTask]
25+
- [CounterTask](reference/tasks/counter_task.md)
2626
- [DebugTask](reference/tasks/debug_task.md)
2727
- [DieTask](reference/tasks/die_task.md)
2828
- [DummyTask](reference/tasks/dummy_task.md)
29-
- [ErrorForwarderTask]
29+
- [ErrorForwarderTask](reference/tasks/error_forwarder_task.md)
3030
- [EventDispatcherTask](reference/tasks/event_dispatcher_task.md)
31-
- [StopwatchTask]
31+
- [StopwatchTask](reference/tasks/stopwatch_task.md)
3232
- Data manipulation and transformations
3333
- [DenormalizerTask](reference/tasks/denormalizer_task.md)
3434
- [NormalizerTask](reference/tasks/normalizer_task.md)

docs/reference/tasks/_template.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ _Description of possible types_
2020

2121
Options
2222
-------
23-
24-
| Code | Type | Required | Default | Description |
25-
| ---- | ---- | :------: | ------- | ----------- |
23+
| Code | Type | Required | Default | Description |
24+
|--------|--------|--------------------|--------------------------------|---------------|
2625
| `code` | `type` | **X** _or nothing_ | `default value` _if available_ | _description_ |
2726

2827
Examples

docs/reference/tasks/constant_iterable_output_task.md

+22-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,26 @@ Possible outputs
2121
Options
2222
-------
2323

24-
| Code | Type | Required | Default | Description |
25-
| ---- | ---- | :------: | ------- | ----------- |
26-
| `output` | `array` | **X** | | Array of values to iterate onto |
24+
| Code | Type | Required | Default | Description |
25+
|----------|---------|:--------:|---------|---------------------------------|
26+
| `output` | `array` | **X** | | Array of values to iterate onto |
2727

28+
Example
29+
-------
30+
31+
```yaml
32+
clever_age_process:
33+
configurations:
34+
project_prefix.constant_iterable_output_example:
35+
tasks:
36+
constant_iterable_output_example:
37+
service: '@CleverAge\ProcessBundle\Task\ConstantIterableOutputTask'
38+
options:
39+
output:
40+
id: 123
41+
firstname: Test1
42+
lastname: Test2
43+
outputs: [debug]
44+
debug:
45+
service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask'
46+
```

docs/reference/tasks/constant_output_task.md

+17-15
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,26 @@ Possible outputs
2121
Options
2222
-------
2323

24-
| Code | Type | Required | Default | Description |
25-
| ---- | ---- | :------: | ------- | ----------- |
26-
| `output` | `any` | **X** | | Value to output |
24+
| Code | Type | Required | Default | Description |
25+
|----------|-------|:---------|---------|-----------------|
26+
| `output` | `any` | **X** | | Value to output |
2727

2828
Example
2929
-------
3030

3131
```yaml
3232
clever_age_process:
33-
configurations:
34-
project_prefix.process_name:
35-
tasks:
36-
constant_output_example:
37-
service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
38-
options:
39-
output:
40-
id: 123
41-
firstname: Test1
42-
lastname: Test2
43-
outputs: [XXXX]
44-
```
33+
configurations:
34+
project_prefix.constant_output_example:
35+
tasks:
36+
constant_output_example:
37+
service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
38+
options:
39+
output:
40+
id: 123
41+
firstname: Test1
42+
lastname: Test2
43+
outputs: [debug]
44+
debug:
45+
service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask'
46+
```

docs/reference/tasks/counter_task.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
CounterTask
2+
==================
3+
4+
Count the number of times the task is processed and continue every N iteration (skip the rest of the time)
5+
6+
Flush at the end with the actual count.
7+
8+
Task reference
9+
--------------
10+
11+
* **Service**: `CleverAge\ProcessBundle\Task\CounterTask`
12+
13+
Accepted inputs
14+
---------------
15+
16+
`any`
17+
18+
Possible outputs
19+
----------------
20+
21+
`int`: outputs the number of times the counter is called
22+
23+
Options
24+
-------
25+
26+
| Code | Type | Required | Default | Description |
27+
|---------------|-------|----------|----------|---------------------------------------------------|
28+
| `flush_every` | `int` | **X** | | The period at which the task will produce outputs |
29+
30+
Example
31+
-------
32+
33+
```yaml
34+
clever_age_process:
35+
configurations:
36+
project_prefix.counter_example:
37+
tasks:
38+
counter_example:
39+
service: '@CleverAge\ProcessBundle\Task\ConstantIterableOutputTask'
40+
options:
41+
output:
42+
test1: test1
43+
test2: test2
44+
test3: test3
45+
test4: test4
46+
test5: test5
47+
test6: test6
48+
outputs: [counter]
49+
counter:
50+
service: '@CleverAge\ProcessBundle\Task\CounterTask'
51+
options:
52+
flush_every: 2
53+
outputs: [ debug ]
54+
debug:
55+
service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask'
56+
```

docs/reference/tasks/debug_task.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,19 @@ Possible outputs
2323
Example
2424
----------------
2525

26-
https://github.com/cleverage/process-bundle-ui-demo/blob/main/config/packages/process/demo.debug.yaml
26+
```yaml
27+
clever_age_process:
28+
configurations:
29+
project_prefix.debug_example:
30+
tasks:
31+
debug_example:
32+
service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
33+
options:
34+
output:
35+
id: 123
36+
firstname: Test1
37+
lastname: Test2
38+
outputs: [debug]
39+
debug:
40+
service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask'
41+
```

docs/reference/tasks/die_task.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,11 @@ None
2222
Example
2323
----------------
2424

25-
https://github.com/cleverage/process-bundle-ui-demo/blob/main/config/packages/process/demo.die.yaml
25+
```yaml
26+
clever_age_process:
27+
configurations:
28+
project_prefix.die_example:
29+
tasks:
30+
die_example:
31+
service: '@CleverAge\ProcessBundle\Task\Debug\DieTask'
32+
```

docs/reference/tasks/dummy_task.md

+31
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,34 @@ Possible outputs
1717
----------------
1818

1919
`any`: re-output given input
20+
21+
Example
22+
-------
23+
24+
```yaml
25+
clever_age_process:
26+
configurations:
27+
project_prefix.dummy_example:
28+
tasks:
29+
dummy_example:
30+
service: '@CleverAge\ProcessBundle\Task\DummyTask'
31+
outputs: [output1, output2]
32+
output1:
33+
service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
34+
options:
35+
output:
36+
id: 123
37+
firstname: Test1
38+
lastname: Test2
39+
outputs: [debug]
40+
output2:
41+
service: '@CleverAge\ProcessBundle\Task\ConstantOutputTask'
42+
options:
43+
output:
44+
id: 456
45+
firstname: Test3
46+
lastname: Test4
47+
outputs: [ debug ]
48+
debug:
49+
service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask'
50+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
CounterTask
2+
==================
3+
4+
This is a dummy task mostly intended for testing purpose.
5+
6+
Forward any input to the error output.
7+
8+
Task reference
9+
--------------
10+
11+
* **Service**: `CleverAge\ProcessBundle\Task\Debug\ErrorForwarderTask`
12+
13+
Accepted inputs
14+
---------------
15+
16+
`any`
17+
18+
Possible outputs
19+
----------------
20+
21+
`any`: directly error_output given `output` option
22+
23+
Example
24+
-------
25+
26+
```yaml
27+
clever_age_process:
28+
configurations:
29+
project_prefix.error_forwarder_example:
30+
tasks:
31+
error_forwarder_example:
32+
service: '@CleverAge\ProcessBundle\Task\ConstantIterableOutputTask'
33+
options:
34+
output:
35+
error1: Error 1
36+
error2: Error 2
37+
error3: Error 3
38+
outputs: [error_forwarder]
39+
error_forwarder:
40+
service: '@CleverAge\ProcessBundle\Task\Debug\ErrorForwarderTask'
41+
42+
```

docs/reference/tasks/event_dispatcher_task.md

+20-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,24 @@ Possible outputs
2222
Options
2323
-------
2424

25-
| Code | Type | Required | Default | Description |
26-
| ---- | ---- | :------: | ------- | ----------- |
27-
| `event_name` | `string` | **X** | | Format for normalization ("json", "xml", ... an empty string should also work) |
28-
| `passive` | `bool` | | `true` | Pass input to output |
25+
| Code | Type | Required | Default | Description |
26+
|--------------|----------|:---------:|----------|----------------------|
27+
| `event_name` | `string` | **X** | | |
28+
| `passive` | `bool` | | `true` | Pass input to output |
2929

30+
Example
31+
-------
32+
33+
```yaml
34+
clever_age_process:
35+
configurations:
36+
project_prefix.event_dispatcher_example:
37+
tasks:
38+
event_dispatcher_example:
39+
service: '@CleverAge\ProcessBundle\Task\Event\EventDispatcherTask'
40+
options:
41+
event_name: 'myapp.myevent'
42+
outputs: [debug]
43+
debug:
44+
service: '@CleverAge\ProcessBundle\Task\Debug\DebugTask'
45+
```
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
StopwatchTask
2+
=============
3+
4+
Log all the __root__ events of the Stopwatch component.
5+
6+
Task reference
7+
--------------
8+
9+
* **Service**: `CleverAge\ProcessBundle\Task\Debug\StopwatchTask`
10+
11+
Accepted inputs
12+
---------------
13+
14+
`any`
15+
16+
Example
17+
-------
18+
19+
```yaml
20+
clever_age_process:
21+
configurations:
22+
project_prefix.stopwatch_example:
23+
tasks:
24+
stopwatch_example:
25+
service: '@CleverAge\ProcessBundle\Task\Debug\StopwatchTask'
26+
```

src/Task/Debug/DebugTask.php

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
/**
2121
* Dump the content of the input.
22-
*
23-
* @example https://github.com/cleverage/process-bundle-ui-demo/blob/main/config/packages/process/demo.debug.yaml
2422
*/
2523
class DebugTask implements TaskInterface
2624
{

src/Task/Debug/DieTask.php

-4
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,16 @@
1515

1616
use CleverAge\ProcessBundle\Model\ProcessState;
1717
use CleverAge\ProcessBundle\Model\TaskInterface;
18-
use Symfony\Component\Console\Helper\Helper;
1918

2019
/**
2120
* Class DieTask.
2221
*
2322
* Stops the process brutally
24-
*
25-
* @example https://github.com/cleverage/process-bundle-ui-demo/blob/main/config/packages/process/demo.die.yaml
2623
*/
2724
class DieTask implements TaskInterface
2825
{
2926
public function execute(ProcessState $state): never
3027
{
31-
var_dump(Helper::formatMemory(memory_get_peak_usage(true)));
3228
exit;
3329
}
3430
}

src/Task/Debug/StopwatchTask.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Symfony\Component\Stopwatch\Stopwatch;
2020

2121
/**
22-
* Ouputs the stopwatch the content of the input.
22+
* Log all the __root__ events of the Stopwatch component.
2323
*/
2424
class StopwatchTask implements TaskInterface
2525
{

0 commit comments

Comments
 (0)