Skip to content

Commit

Permalink
feat: replace EachSequential with ForEach (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
shrutimantri authored Nov 18, 2024
1 parent 4ce66b0 commit 1fe694e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 64 deletions.
40 changes: 20 additions & 20 deletions src/main/java/io/kestra/plugin/gcp/bigquery/Trigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@
@Example(
title = "Wait for a sql query to return results and iterate through rows.",
full = true,
code = {
"id: bigquery-listen",
"namespace: company.team",
"",
"tasks:",
" - id: each",
" type: io.kestra.plugin.core.flow.EachSequential",
" tasks:",
" - id: return",
" type: io.kestra.plugin.core.debug.Return",
" format: \"{{ taskrun.value }}\"",
" value: \"{{ trigger.rows }}\"",
"",
"triggers:",
" - id: watch",
" type: io.kestra.plugin.gcp.bigquery.Trigger",
" interval: \"PT5M\"",
" sql: \"SELECT * FROM `myproject.mydataset.mytable`\"",
" fetch: true"
}
code = """
id: bigquery_listen
namespace: company.team
tasks:
- id: each
type: io.kestra.plugin.core.flow.ForEach
values: "{{ trigger.rows }}"
tasks:
- id: return
type: io.kestra.plugin.core.debug.Return
format: "{{ taskrun.value }}"
triggers:
- id: watch
type: io.kestra.plugin.gcp.bigquery.Trigger
interval: "PT5M"
sql: "SELECT * FROM `myproject.mydataset.mytable`"
fetch: true
"""
)
}
)
Expand Down
88 changes: 44 additions & 44 deletions src/main/java/io/kestra/plugin/gcp/gcs/Trigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,54 +41,54 @@
@Example(
title = "Wait for a list of files on a GCS bucket, and iterate through the files.",
full = true,
code = {
"id: gcs-listen",
"namespace: company.team",
"",
"tasks:",
" - id: each",
" type: io.kestra.plugin.core.flow.EachSequential",
" tasks:",
" - id: return",
" type: io.kestra.plugin.core.debug.Return",
" format: \"{{ taskrun.value }}\"",
" value: \"{{ trigger.blobs | jq('.[].uri') }}\"",
"",
"triggers:",
" - id: watch",
" type: io.kestra.plugin.gcp.gcs.Trigger",
" interval: \"PT5M\"",
" from: gs://my-bucket/kestra/listen/",
" action: MOVE",
" moveDirectory: gs://my-bucket/kestra/archive/",
}
code = """
id: gcs_listen
namespace: company.team
tasks:
- id: each
type: io.kestra.plugin.core.flow.ForEach
values: "{{ trigger.blobs | jq('.[].uri') }}"
tasks:
- id: return
type: io.kestra.plugin.core.debug.Return
format: "{{ taskrun.value }}"
triggers:
- id: watch
type: io.kestra.plugin.gcp.gcs.Trigger
interval: "PT5M"
from: gs://my-bucket/kestra/listen/
action: MOVE
moveDirectory: gs://my-bucket/kestra/archive/
"""
),
@Example(
title = "Wait for a list of files on a GCS bucket and iterate through the files. Delete files manually after processing to prevent infinite triggering.",
full = true,
code = {
"id: gcs-listen",
"namespace: company.team",
"",
"tasks:",
" - id: each",
" type: io.kestra.plugin.core.flow.EachSequential",
" tasks:",
" - id: return",
" type: io.kestra.plugin.core.debug.Return",
" format: \"{{ taskrun.value }}\"",
" - id: delete",
" type: io.kestra.plugin.gcp.gcs.Delete",
" uri: \"{{ taskrun.value }}\"",
" value: \"{{ trigger.blobs | jq('.[].uri') }}\"",
"",
"triggers:",
" - id: watch",
" type: io.kestra.plugin.gcp.gcs.Trigger",
" interval: \"PT5M\"",
" from: gs://my-bucket/kestra/listen/",
" action: NONE",
}
code = """
id: gcs_listen
namespace: company.team
tasks:
- id: each
type: io.kestra.plugin.core.flow.EachSequential
values: "{{ trigger.blobs | jq('.[].uri') }}"
tasks:
- id: return
type: io.kestra.plugin.core.debug.Return
format: "{{ taskrun.value }}"
- id: delete
type: io.kestra.plugin.gcp.gcs.Delete
uri: "{{ taskrun.value }}"
triggers:
- id: watch
type: io.kestra.plugin.gcp.gcs.Trigger
interval: "PT5M"
from: gs://my-bucket/kestra/listen/
action: NONE
"""
)
}
)
Expand Down

0 comments on commit 1fe694e

Please sign in to comment.