Created
December 4, 2025 04:39
-
-
Save DCCoder90/68c8981fbcbc44a7d25e6ccf2a601688 to your computer and use it in GitHub Desktop.
A go snippet showing how to handle a hard timeout with Temporal.io
This file contains hidden or 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
| func Workflow(ctx workflow.Context, details PaymentDetails) error { | |
| ao := workflow.ActivityOptions{ | |
| StartToCloseTimeout: 10 * time.Second // This is the X seconds limit, currently set to 10 seconds | |
| } | |
| ctx = workflow.WithActivityOptions(ctx, ao) | |
| var result string | |
| err := workflow.ExecuteActivity(ctx, ProcessPaymentActivity, details).Get(ctx, &result) | |
| if err != nil { | |
| // If we exhausted retries or hit a non-retryable error | |
| var timeoutErr *temporal.ApplicationError // or TimeoutError depending on SDK version | |
| if errors.As(err, &timeoutErr) { | |
| // Handle the timeout logic here, such as cleaning up | |
| return err | |
| } | |
| return err | |
| } | |
| return nil | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment