לכל פריט
Flow node
forEachlogicמריץ את השלבים שאחריו פעם אחת לכל פריט ברשימה, בזה אחר זה, ואז ממשיך אחרי האחרון.
במבט אחד
| מאפיין | ערך |
|---|---|
| Node field | forEach (set instead of stepRef on a FlowNode) |
| Side effects | no |
A FlowNode sets exactly one of stepRef, branch, filter, forEach, wait and approval.
הגדרות
The value of the node field, with these settings.
| הגדרה | סוג | ברירת מחדל | תיאור |
|---|---|---|---|
itemsחובה | string | - | Items is a placeholder naming a list, e.g. {read-sheet.rows}. |
maxItems | integer | - | MaxItems is the most items the list may have; the default is 100 and the most that can be asked for is 1000. |
endחובה | string | - | End is the node that closes the loop and runs once after the last item. It is where the body's last node points. |
ה-JSON Schema המלא של ההגדרות: forEach.schema.json.
שימוש בתהליך
flow.yaml
apiVersion: lumen.ai/v1alpha1
kind: Connector
metadata:
name: my-email-forward
namespace: tenant-acme
spec:
classRef: {name: email-forward}
config: {}
---
apiVersion: lumen.ai/v1alpha1
kind: Flow
metadata:
name: foreach-example
namespace: tenant-acme
spec:
displayName: "For each"
triggers:
- id: start
ref: {name: email-arrives}
connectorRef: {name: my-email-forward}
next: [sheet]
nodes:
- id: sheet
stepRef: {name: read-spreadsheet}
config: {headerRow: 1}
next: [rows]
- id: rows
forEach: {items: "{sheet.rows}", maxItems: 20, end: done}
next: [say]
- id: say
stepRef: {name: notify-in-app}
config:
to: admins
title: "Row {each.index}"
body: "{each.item}"
next: [done]
- id: done
stepRef: {name: notify-in-app}
config:
to: admins
title: "All {rows.count} rows done"
הדף עזר לכם?