github.com/Jeffail/benthos/v3@v3.65.0/website/docs/components/processors/while.md (about) 1 --- 2 title: while 3 type: processor 4 status: stable 5 categories: ["Composition"] 6 --- 7 8 <!-- 9 THIS FILE IS AUTOGENERATED! 10 11 To make changes please edit the contents of: 12 lib/processor/while.go 13 --> 14 15 import Tabs from '@theme/Tabs'; 16 import TabItem from '@theme/TabItem'; 17 18 19 While is a processor that checks a [Bloblang query](/docs/guides/bloblang/about/) against messages and executes child processors on them for as long as the query resolves to true. 20 21 22 <Tabs defaultValue="common" values={[ 23 { label: 'Common', value: 'common', }, 24 { label: 'Advanced', value: 'advanced', }, 25 ]}> 26 27 <TabItem value="common"> 28 29 ```yaml 30 # Common config fields, showing default values 31 label: "" 32 while: 33 at_least_once: false 34 check: "" 35 processors: [] 36 ``` 37 38 </TabItem> 39 <TabItem value="advanced"> 40 41 ```yaml 42 # All config fields, showing default values 43 label: "" 44 while: 45 at_least_once: false 46 max_loops: 0 47 check: "" 48 processors: [] 49 ``` 50 51 </TabItem> 52 </Tabs> 53 54 The field `at_least_once`, if true, ensures that the child processors are always executed at least one time (like a do .. while loop.) 55 56 The field `max_loops`, if greater than zero, caps the number of loops for a message batch to this value. 57 58 If following a loop execution the number of messages in a batch is reduced to zero the loop is exited regardless of the condition result. If following a loop execution there are more than 1 message batches the query is checked against the first batch only. 59 60 ## Fields 61 62 ### `at_least_once` 63 64 Whether to always run the child processors at least one time. 65 66 67 Type: `bool` 68 Default: `false` 69 70 ### `max_loops` 71 72 An optional maximum number of loops to execute. Helps protect against accidentally creating infinite loops. 73 74 75 Type: `int` 76 Default: `0` 77 78 ### `check` 79 80 A [Bloblang query](/docs/guides/bloblang/about/) that should return a boolean value indicating whether the while loop should execute again. 81 82 83 Type: `string` 84 Default: `""` 85 86 ```yaml 87 # Examples 88 89 check: errored() 90 91 check: this.urls.unprocessed.length() > 0 92 ``` 93 94 ### `processors` 95 96 A list of child processors to execute on each loop. 97 98 99 Type: `array` 100 Default: `[]` 101 102