Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 2.02 KB

counter_task.md

File metadata and controls

60 lines (46 loc) · 2.02 KB

CounterTask

Counts the number of times the task is executed and only outputs the current count every flush_every executions (the task is skipped the rest of the time). When flushed (at the end of the upstream iteration), it outputs the final count, unless this count is a multiple of flush_every (in which case it has already been sent).

Task reference

  • Service: CleverAge\ProcessBundle\Task\CounterTask
  • Code: counter (task: counter)
  • Flushable task

Accepted inputs

Input is ignored (only the number of executions matters)

Possible outputs

int: the number of times the task has been executed so far

Options

Code Type Required Default Description
flush_every int X Output the count every N executions (N = this option, a positive integer, see notes)

Examples

  • Count 9 iterated items, outputting 3, 6 and 9; with flush_every: 4 it would output 4, 8, then 9 on flush
# Task configuration level
entry:
  task: constant_iterable_output
  options:
    output: [1, 2, 3, 4, 5, 6, 7, 8, 9]
  outputs: [counter]
counter:
  task: counter
  options:
    flush_every: 3
  outputs: [debug]

Notes

  • flush() can be called several times during a process (see Advanced workflow), e.g. once at the end of the upstream iteration and once when the counter itself is resolved. The final count is only outputted by the first call; the next ones are skipped.
  • flush_every: 0 is rejected when the options are resolved (InvalidOptionsException) since 5.10: it failed on the first execution (Modulo by zero). A negative value works as its absolute value (-3 as 3): it is deprecated since 5.10 and will be rejected in v6.0.