-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
History size and suggest continue as new (#269)
* Track history size * Add example integration test for continuing as new
- Loading branch information
1 parent
0540942
commit 263e975
Showing
9 changed files
with
134 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'activities/hello_world_activity' | ||
|
||
# Demonstrates how to use history_size to determine when to continue as new | ||
class ContinueAsNewWorkflow < Temporal::Workflow | ||
def execute(hello_count, bytes_max, run = 1) | ||
while hello_count.positive? && workflow.history_size.bytes < bytes_max | ||
HelloWorldActivity.execute!("Alice Long#{'long' * 100}name") | ||
hello_count -= 1 | ||
end | ||
|
||
workflow.logger.info("Workflow history size: #{workflow.history_size}, remaining hellos: #{hello_count}") | ||
|
||
return workflow.continue_as_new(hello_count, bytes_max, run + 1) if hello_count.positive? | ||
|
||
{ | ||
runs: run | ||
} | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module Temporal | ||
class Workflow | ||
class History | ||
Size = Struct.new( | ||
:bytes, # integer, total number of bytes used | ||
:events, # integer, total number of history events used | ||
:suggest_continue_as_new, # boolean, true if server history length limits are being approached | ||
keyword_init: true) | ||
end | ||
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
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
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
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