- export は子供にだけ公開される。
- subtask で store しても親に反映される。
Last active
June 25, 2020 16:12
-
-
Save buzztaiki/68f7b72d0e51c1d3106eaf96662c2c75 to your computer and use it in GitHub Desktop.
Digdag Variable Scope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
class StoreTask | |
def call(name:) | |
Digdag.env.store(name.to_sym => name) | |
end | |
end | |
class ExportAndChildTask | |
def call(name:) | |
Digdag.env.export(name.to_sym => name) | |
Digdag.env.add_subtask(EchoTask, :call, var: name) | |
end | |
end | |
class StoreAndChildTask | |
def call(name:) | |
Digdag.env.store(name.to_sym => name) | |
Digdag.env.add_subtask(EchoTask, :call, var: name) | |
end | |
end | |
class EchoTask | |
def call(var:) | |
puts var | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timezone: UTC | |
_export: | |
rb: | |
require: 'tasks' | |
+step1: | |
_export: | |
export_step1: export_step1 | |
+step1_1: | |
echo>: ${export_step1} | |
+step2: | |
rb>: ExportAndChildTask.call | |
name: export_step2 | |
+step3: | |
rb>: StoreAndChildTask.call | |
name: store_step3 | |
+step4: | |
+step4_1: | |
rb>: StoreTask.call | |
name: store_step4_1 | |
+step4_2: | |
echo>: ${store_step4_1} | |
# ERROR! | |
# +echo1: | |
# echo>: ${export_step1} | |
# ERROR! | |
# +echo2: | |
# echo>: ${export_step2} | |
+echo3: | |
echo>: ${store_step3} | |
+echo4: | |
echo>: ${store_step4_1} |
Author
buzztaiki
commented
Jun 25, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment