Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace EachSequential with ForEach #461

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading