-
Notifications
You must be signed in to change notification settings - Fork 41
Workflow context getters #39
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
Conversation
…work fine work 1 consumer <-> 1 producer, but set/get event accepts multiple consumers
…rns a workflow ID if any
| // GetWorkflowID retrieves the workflow ID from the context if called within a DBOS workflow | ||
| func GetWorkflowID(ctx context.Context) (string, error) { | ||
| wfState, ok := ctx.Value(workflowStateKey).(*workflowState) | ||
| if !ok || wfState == nil { | ||
| return "", errors.New("not within a DBOS workflow context") | ||
| } | ||
| return wfState.workflowID, nil | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetWorkflowID
| // Add custom migration table name to avoid conflicts with user migrations | ||
| // Parse the URL to properly determine where to add the query parameter | ||
| parsedURL, err := url.Parse(databaseURL) | ||
| if err != nil { | ||
| return newInitializationError(fmt.Sprintf("failed to parse database URL: %v", err)) | ||
| } | ||
|
|
||
| // Check if query parameters already exist | ||
| separator := "?" | ||
| if parsedURL.RawQuery != "" { | ||
| separator = "&" | ||
| } | ||
| databaseURL += separator + "x-migrations-table=" + _DBOS_MIGRATION_TABLE | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dedicated migration table
kraftp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! There should also be a GetStepID
Ha, yes. Will add in another PR |
dbos_test.gofile