Skip to content
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

Move commonly used get & update function to api package #3311

Merged
merged 2 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ update-mockgen:

update-proto-plugins:
@printf $(COLOR) "Install/update proto plugins..."
@go install github.com/temporalio/gogo-protobuf/protoc-gen-gogoslick@latest
@go install github.com/temporalio/gogo-protobuf/protoc-gen-gogoslick@master
wxing1292 marked this conversation as resolved.
Show resolved Hide resolved
# This to download sources of gogo-protobuf which are required to build proto files.
@GO111MODULE=off go get github.com/temporalio/gogo-protobuf/protoc-gen-gogoslick
@go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
Expand Down
26 changes: 26 additions & 0 deletions service/history/api/update_workflow_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,36 @@ package api
import (
"context"

clockspb "go.temporal.io/server/api/clock/v1"
"go.temporal.io/server/common/definition"
"go.temporal.io/server/service/history/shard"
"go.temporal.io/server/service/history/workflow"
)

func GetAndUpdateWorkflowWithNew(
ctx context.Context,
reqClock *clockspb.VectorClock,
consistencyCheckFn MutableStateConsistencyPredicate,
workflowKey definition.WorkflowKey,
action UpdateWorkflowActionFunc,
newWorkflowFn func() (workflow.Context, workflow.MutableState, error),
shard shard.Context,
workflowConsistencyChecker WorkflowConsistencyChecker,
) (retError error) {
workflowContext, err := workflowConsistencyChecker.GetWorkflowContext(
ctx,
reqClock,
consistencyCheckFn,
workflowKey,
)
if err != nil {
return err
}
defer func() { workflowContext.GetReleaseFn()(retError) }()

return UpdateWorkflowWithNew(shard, ctx, workflowContext, action, newWorkflowFn)
}

func UpdateWorkflowWithNew(
shard shard.Context,
ctx context.Context,
Expand Down
Loading