-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from bcc-code/feat/queue-based-retry-policy
feat: queue based retry policies.
- Loading branch information
Showing
28 changed files
with
117 additions
and
264 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 |
---|---|---|
@@ -1,14 +1,39 @@ | ||
package wfutils | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/bcc-code/bcc-media-flows/activities" | ||
"github.com/bcc-code/bcc-media-flows/environment" | ||
"go.temporal.io/sdk/temporal" | ||
"go.temporal.io/sdk/workflow" | ||
) | ||
|
||
// ExecuteWithQueue executes the specified activity with the correct task queue | ||
func ExecuteWithQueue(ctx workflow.Context, activity any, params ...any) workflow.Future { | ||
options := workflow.GetActivityOptions(ctx) | ||
options.TaskQueue = activities.GetQueueForActivity(activity) | ||
|
||
switch options.TaskQueue { | ||
case environment.GetWorkerQueue(): | ||
if options.RetryPolicy == nil { | ||
options.RetryPolicy = &temporal.RetryPolicy{ | ||
MaximumAttempts: 10, | ||
InitialInterval: 30 * time.Second, | ||
MaximumInterval: 60 * time.Minute, | ||
} | ||
} | ||
// usual reason for this failing is invalid files or tweaks to ffmpeg commands | ||
case environment.GetTranscodeQueue(), environment.GetAudioQueue(): | ||
if options.RetryPolicy == nil { | ||
options.RetryPolicy = &temporal.RetryPolicy{ | ||
MaximumAttempts: 5, | ||
InitialInterval: 30 * time.Second, | ||
MaximumInterval: 30 * time.Second, | ||
} | ||
} | ||
} | ||
|
||
ctx = workflow.WithActivityOptions(ctx, options) | ||
return workflow.ExecuteActivity(ctx, activity, params...) | ||
} |
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
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
Oops, something went wrong.