api

package
v1.32.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 65 Imported by: 0

Documentation

Overview

Package api is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	UpdateWorkflowWithNewWorkflowTask = &UpdateWorkflowAction{
		CreateWorkflowTask: true,
	}
	UpdateWorkflowWithoutWorkflowTask = &UpdateWorkflowAction{
		CreateWorkflowTask: false,
	}
	UpdateWorkflowTerminate = &UpdateWorkflowAction{
		CreateWorkflowTask: false,
		AbortUpdates:       true,
	}
)
View Source
var ErrUseCurrentExecution = errors.New("ErrUseCurrentExecution")

ErrUseCurrentExecution is a sentinel error to indicate to the caller to use the current workflow execution instead of creating a new one

Functions

func ClientSupportsTranOrSpecEvents

func ClientSupportsTranOrSpecEvents(ctx context.Context) bool

ClientSupportsTranOrSpecEvents detects if client supports transient events Default to include transient events for clients, only CLI and UI are explicitly excluded for backward compatability

func CreateMutableState

func CreateMutableState(
	shard historyi.ShardContext,
	namespaceEntry *namespace.Namespace,
	executionTimeout *durationpb.Duration,
	runTimeout *durationpb.Duration,
	workflowID string,
	runID string,
) (historyi.MutableState, error)

func DeserializeHistoryToken

func DeserializeHistoryToken(bytes []byte) (*tokenspb.HistoryContinuation, error)

NOTE: DO NOT MODIFY UNLESS ALSO APPLIED TO ./service/frontend/token_deprecated.go

func DeserializeRawHistoryToken

func DeserializeRawHistoryToken(bytes []byte) (*tokenspb.RawHistoryContinuation, error)

NOTE: DO NOT MODIFY UNLESS ALSO APPLIED TO ./service/frontend/token_deprecated.go

func FixFollowEvents

func FixFollowEvents(
	ctx context.Context,
	versionChecker headers.VersionChecker,
	isCloseEventOnly bool,
	history *historypb.History,
) error

func GenerateFirstWorkflowTask

func GenerateFirstWorkflowTask(
	mutableState historyi.MutableState,
	parentInfo *workflowspb.ParentExecutionInfo,
	startEvent *historypb.HistoryEvent,
	bypassTaskGeneration bool,
) (int64, error)

func GeneratePaginationTokenV2Request

func GeneratePaginationTokenV2Request(
	request *historyservice.GetWorkflowExecutionRawHistoryV2Request,
	versionHistories *historyspb.VersionHistories,
) *tokenspb.RawHistoryContinuation

NOTE: DO NOT MODIFY UNLESS ALSO APPLIED TO ./service/frontend/token_deprecated.go

func GenerateRequestIDRefLink(namespace, workflowID, runID, requestID string, eventType enumspb.EventType) *commonpb.Link

GenerateRequestIDRefLink builds a Link with a RequestIdReference. Use this for events that are buffered at signal time (e.g. SIGNALED), where the concrete EventId is not yet known. The server resolves the RequestId to a real EventId once the buffer flushes.

func GenerateStartedEventRefLink(namespace, workflowID, runID string) *commonpb.Link

GenerateStartedEventRefLink builds a Link pointing to the WORKFLOW_EXECUTION_STARTED event. Use this for backlinks to workflow start: the started event is always EventId=1 (FirstEventID) and is never buffered, so a concrete EventReference is appropriate.

func GetActiveNamespace

func GetActiveNamespace(
	shard historyi.ShardContext,
	namespaceUUID namespace.ID,
	businessID string,
) (*namespace.Namespace, error)

func GetActivityScheduledEventID

func GetActivityScheduledEventID(
	activityID string,
	mutableState historyi.MutableState,
) (int64, error)

func GetAndUpdateWorkflowWithConsistencyCheck

func GetAndUpdateWorkflowWithConsistencyCheck(
	ctx context.Context,
	reqClock *clockspb.VectorClock,
	consistencyCheckFn MutableStateConsistencyPredicate,
	workflowKey definition.WorkflowKey,
	action UpdateWorkflowActionFunc,
	newWorkflowFn func() (historyi.WorkflowContext, historyi.MutableState, error),
	shardContext historyi.ShardContext,
	workflowConsistencyChecker WorkflowConsistencyChecker,
) (retError error)

func GetAndUpdateWorkflowWithNew

func GetAndUpdateWorkflowWithNew(
	ctx context.Context,
	reqClock *clockspb.VectorClock,
	workflowKey definition.WorkflowKey,
	action UpdateWorkflowActionFunc,
	newWorkflowFn func() (historyi.WorkflowContext, historyi.MutableState, error),
	shard historyi.ShardContext,
	workflowConsistencyChecker WorkflowConsistencyChecker,
) (retError error)

func GetHistory

func GetHistory(
	ctx context.Context,
	shardContext historyi.ShardContext,
	namespaceName namespace.Name,
	namespaceID namespace.ID,
	execution *commonpb.WorkflowExecution,
	firstEventID int64,
	nextEventID int64,
	pageSize int32,
	nextPageToken []byte,
	transientWorkflowTaskInfo *historyspb.TransientWorkflowTaskInfo,
	branchToken []byte,
	persistenceVisibilityMgr manager.VisibilityManager,
) (history *historypb.History, token []byte, retError error)

func GetHistoryReverse

func GetHistoryReverse(
	ctx context.Context,
	shardContext historyi.ShardContext,
	namespaceID namespace.ID,
	execution *commonpb.WorkflowExecution,
	nextEventID int64,
	lastFirstTxnID int64,
	pageSize int32,
	nextPageToken []byte,
	branchToken []byte,
	persistenceVisibilityMgr manager.VisibilityManager,
) (history *historypb.History, token []byte, lastFirstTransactionID int64, retError error)

func GetMutableState

func GetMutableState(
	ctx context.Context,
	shardContext historyi.ShardContext,
	workflowKey definition.WorkflowKey,
	workflowConsistencyChecker WorkflowConsistencyChecker,
) (_ *historyservice.GetMutableStateResponse, retError error)

func GetMutableStateWithConsistencyCheck

func GetMutableStateWithConsistencyCheck(
	ctx context.Context,
	shardContext historyi.ShardContext,
	workflowKey definition.WorkflowKey,
	currentVersion int64,
	currentEventID int64,
	versionedTransition *persistencespb.VersionedTransition,
	workflowConsistencyChecker WorkflowConsistencyChecker,
) (_ *historyservice.GetMutableStateResponse, retError error)

func GetNamespace

func GetNamespace(
	shard historyi.ShardContext,
	namespaceUUID namespace.ID,
) (*namespace.Namespace, error)

func GetOrPollWorkflowMutableState

func GetOrPollWorkflowMutableState(
	ctx context.Context,
	shardContext historyi.ShardContext,
	request *historyservice.GetMutableStateRequest,
	workflowConsistencyChecker WorkflowConsistencyChecker,
	eventNotifier events.Notifier,
) (*historyservice.GetMutableStateResponse, error)

func GetRawHistory

func GetRawHistory(
	ctx context.Context,
	shardContext historyi.ShardContext,
	namespaceName namespace.Name,
	namespaceID namespace.ID,
	execution *commonpb.WorkflowExecution,
	firstEventID int64,
	nextEventID int64,
	pageSize int32,
	token []byte,
	transientWorkflowTaskInfo *historyspb.TransientWorkflowTaskInfo,
	branchToken []byte,
) (_ []*commonpb.DataBlob, _ []byte, retError error)

func GetTaskCategory

func GetTaskCategory(categoryID int, registry tasks.TaskCategoryRegistry) (tasks.Category, error)

func IsActivityTaskNotFoundForToken

func IsActivityTaskNotFoundForToken(
	token *tokenspb.Task,
	ai *persistencespb.ActivityInfo,
	isCompletedByID *bool,
) bool

func IsHistoryEventOnCurrentBranch

func IsHistoryEventOnCurrentBranch(
	mutableState historyi.MutableState,
	eventID int64,
	eventVersion int64,
) (bool, error)

func IsRetryableError

func IsRetryableError(err error) bool

func MigrateWorkflowIDReusePolicyForRunningWorkflow

func MigrateWorkflowIDReusePolicyForRunningWorkflow(
	wfIDReusePolicy *enumspb.WorkflowIdReusePolicy,
	wfIDConflictPolicy *enumspb.WorkflowIdConflictPolicy,
)

func MutableStateToGetResponse

func MutableStateToGetResponse(
	mutableState historyi.MutableState,
) (*historyservice.GetMutableStateResponse, error)

func NewWorkflowVersionCheck

func NewWorkflowVersionCheck(
	shard historyi.ShardContext,
	prevLastWriteVersion int64,
	newMutableState historyi.MutableState,
) error

func NewWorkflowWithSignal

func NewWorkflowWithSignal(
	shard historyi.ShardContext,
	namespaceEntry *namespace.Namespace,
	workflowID string,
	runID string,
	startRequest *historyservice.StartWorkflowExecutionRequest,
	signalWithStartRequest *workflowservice.SignalWithStartWorkflowExecutionRequest,
) (historyi.MutableState, error)

func OverrideStartWorkflowExecutionRequest

func OverrideStartWorkflowExecutionRequest(
	request *workflowservice.StartWorkflowExecutionRequest,
	operation string,
	shard historyi.ShardContext,
	metricsHandler metrics.Handler,
)

func ProcessInternalRawHistory

func ProcessInternalRawHistory(
	requestContext context.Context,
	saProvider searchattribute.Provider,
	saMapperProvider searchattribute.MapperProvider,
	response *historyservice.GetWorkflowExecutionHistoryResponse,
	visibilityManager manager.VisibilityManager,
	versionChecker headers.VersionChecker,
	ns namespace.Name,
	isCloseEventOnly bool,
) error

ProcessInternalRawHistory processes history in the field response.History. History service can send history events in response.History.Events. In that case, process the events and move them to response.Response.History. Usually this is done by history service but when history.sendRawHistoryBetweenInternalServices is enabled, history service sends raw history events to frontend without any processing.

func ProcessOutgoingSearchAttributes

func ProcessOutgoingSearchAttributes(
	saProvider searchattribute.Provider,
	saMapperProvider searchattribute.MapperProvider,
	events []*historypb.HistoryEvent,
	ns namespace.Name,
	persistenceVisibilityMgr manager.VisibilityManager,
) error

func ReactivateVersionWorkflowIfPinned

func ReactivateVersionWorkflowIfPinned(
	ctx context.Context,
	namespaceEntry *namespace.Namespace,
	override *workflowpb.VersioningOverride,
	signaler VersionReactivationSignalerFn,
	enabled bool,
	shouldSkipReactivation bool,
	revisionNumber int64,
)

ReactivateVersionWorkflowIfPinned sends a reactivation signal to the version workflow when workflow execution options target a potentially DRAINED/INACTIVE version (for example, by specifying a Pinned or OneTime override via update options). This is a fire-and-forget operation - the signal is sent asynchronously and errors are logged by the signaler implementation. The signaler itself is responsible for per-pod dedup by revision number; cross-pod duplicates fold at the receiver via a deterministic UUID RequestId.

func ResolveWorkflowIDReusePolicy

func ResolveWorkflowIDReusePolicy(
	shardContext historyi.ShardContext,
	workflowKey definition.WorkflowKey,
	namespaceEntry *namespace.Namespace,
	currentStatus enumspb.WorkflowExecutionStatus,
	currentRequestIDs map[string]*persistencespb.RequestIDInfo,
	currentFirstExecutionRunID string,
	wfIDReusePolicy enumspb.WorkflowIdReusePolicy,
	currentWorkflowStartTime time.Time,
) error

func SerializeHistoryToken

func SerializeHistoryToken(token *tokenspb.HistoryContinuation) ([]byte, error)

NOTE: DO NOT MODIFY UNLESS ALSO APPLIED TO ./service/frontend/token_deprecated.go

func SerializeRawHistoryToken

func SerializeRawHistoryToken(token *tokenspb.RawHistoryContinuation) ([]byte, error)

NOTE: DO NOT MODIFY UNLESS ALSO APPLIED TO ./service/frontend/token_deprecated.go

func SetActivityTaskRunID

func SetActivityTaskRunID(
	ctx context.Context,
	token *tokenspb.Task,
	workflowConsistencyChecker WorkflowConsistencyChecker,
) error

func TrimHistoryNode

func TrimHistoryNode(
	ctx context.Context,
	shardContext historyi.ShardContext,
	workflowConsistencyChecker WorkflowConsistencyChecker,
	eventNotifier events.Notifier,
	namespaceID string,
	workflowID string,
	runID string,
)

func UpdateWorkflowWithNew

func UpdateWorkflowWithNew(
	shardContext historyi.ShardContext,
	ctx context.Context,
	workflowLease WorkflowLease,
	action UpdateWorkflowActionFunc,
	newWorkflowFn func() (historyi.WorkflowContext, historyi.MutableState, error),
) (retError error)

func ValidateBranchTokenForExecution

func ValidateBranchTokenForExecution(
	ctx context.Context,
	shardContext historyi.ShardContext,
	workflowConsistencyChecker WorkflowConsistencyChecker,
	eventNotifier events.Notifier,
	namespaceName namespace.Name,
	namespaceID namespace.ID,
	execution *commonpb.WorkflowExecution,
	requestBranchToken []byte,
) error

ValidateBranchTokenForExecution rejects a paging branch token that is not the execution's current one.

func ValidateNamespaceUUID

func ValidateNamespaceUUID(
	namespaceUUID namespace.ID,
) error

func ValidatePaginationTokenV2Request

func ValidatePaginationTokenV2Request(
	request *historyservice.GetWorkflowExecutionRawHistoryV2Request,
	token *tokenspb.RawHistoryContinuation,
) error

NOTE: DO NOT MODIFY UNLESS ALSO APPLIED TO ./service/frontend/token_deprecated.go

func ValidateReplicationConfig

func ValidateReplicationConfig(
	clusterMetadata cluster.Metadata,
) error

func ValidateSignal

func ValidateSignal(
	ctx context.Context,
	shard historyi.ShardContext,
	mutableState historyi.MutableState,
	signalPayloadSize int,
	signalHeaderSize int,
	operation string,
) error

func ValidateStart

func ValidateStart(
	ctx context.Context,
	shard historyi.ShardContext,
	namespaceEntry *namespace.Namespace,
	workflowID string,
	workflowInputSize int,
	workflowMemoSize int,
	workflowHeaderSize int,
	operation string,
) error

func ValidateStartWorkflowExecutionRequest

func ValidateStartWorkflowExecutionRequest(
	ctx context.Context,
	request *workflowservice.StartWorkflowExecutionRequest,
	shard historyi.ShardContext,
	namespaceEntry *namespace.Namespace,
	operation string,
) error

func ValidateTransientWorkflowTaskEvents

func ValidateTransientWorkflowTaskEvents(
	eventIDOffset int64,
	transientWorkflowTaskInfo *historyspb.TransientWorkflowTaskInfo,
) error

ValidateTransientWorkflowTaskEvents validates that transient workflow task events have sequential event IDs starting from the given offset. Returns an error if any event ID doesn't match the expected sequence.

func VerifyHistoryIsComplete

func VerifyHistoryIsComplete(
	logger log.Logger,
	firstEvent *historyspb.StrippedHistoryEvent,
	lastEvent *historyspb.StrippedHistoryEvent,
	eventCount int,
	expectedFirstEventID int64,
	expectedLastEventID int64,
	isFirstPage bool,
	isLastPage bool,
	pageSize int,
) error

Types

type CommandAttrValidator

type CommandAttrValidator struct {
	// contains filtered or unexported fields
}

func NewCommandAttrValidator

func NewCommandAttrValidator(
	namespaceRegistry namespace.Registry,
	config *configs.Config,
	searchAttributesValidator *searchattribute.Validator,
) *CommandAttrValidator

func (*CommandAttrValidator) ValidateActivityCancelAttributes

func (*CommandAttrValidator) ValidateActivityScheduleAttributes

func (v *CommandAttrValidator) ValidateActivityScheduleAttributes(
	namespaceID namespace.ID,
	attributes *commandpb.ScheduleActivityTaskCommandAttributes,
	runTimeout *durationpb.Duration,
	workflowTaskQueue string,
) (enumspb.WorkflowTaskFailedCause, error)

func (*CommandAttrValidator) ValidateCancelExternalWorkflowExecutionAttributes

func (v *CommandAttrValidator) ValidateCancelExternalWorkflowExecutionAttributes(
	namespaceID namespace.ID,
	workflowID string,
	targetNamespaceID namespace.ID,
	initiatedChildExecutionsInSession map[string]struct{},
	attributes *commandpb.RequestCancelExternalWorkflowExecutionCommandAttributes,
) (enumspb.WorkflowTaskFailedCause, error)

func (*CommandAttrValidator) ValidateCancelWorkflowExecutionAttributes

func (v *CommandAttrValidator) ValidateCancelWorkflowExecutionAttributes(
	attributes *commandpb.CancelWorkflowExecutionCommandAttributes,
) (enumspb.WorkflowTaskFailedCause, error)

func (*CommandAttrValidator) ValidateCommandSequence

func (v *CommandAttrValidator) ValidateCommandSequence(
	commands []*commandpb.Command,
) error

func (*CommandAttrValidator) ValidateCompleteWorkflowExecutionAttributes

func (v *CommandAttrValidator) ValidateCompleteWorkflowExecutionAttributes(
	attributes *commandpb.CompleteWorkflowExecutionCommandAttributes,
) (enumspb.WorkflowTaskFailedCause, error)

func (*CommandAttrValidator) ValidateContinueAsNewWorkflowExecutionAttributes

func (v *CommandAttrValidator) ValidateContinueAsNewWorkflowExecutionAttributes(
	namespaceName namespace.Name,
	attributes *commandpb.ContinueAsNewWorkflowExecutionCommandAttributes,
	executionInfo *persistencespb.WorkflowExecutionInfo,
) (enumspb.WorkflowTaskFailedCause, error)

func (*CommandAttrValidator) ValidateFailWorkflowExecutionAttributes

func (v *CommandAttrValidator) ValidateFailWorkflowExecutionAttributes(
	attributes *commandpb.FailWorkflowExecutionCommandAttributes,
) (enumspb.WorkflowTaskFailedCause, error)

func (*CommandAttrValidator) ValidateModifyWorkflowProperties

func (*CommandAttrValidator) ValidateProtocolMessageAttributes

func (v *CommandAttrValidator) ValidateProtocolMessageAttributes(
	namespaceID namespace.ID,
	attributes *commandpb.ProtocolMessageCommandAttributes,
	runTimeout *durationpb.Duration,
) (enumspb.WorkflowTaskFailedCause, error)

func (*CommandAttrValidator) ValidateRecordMarkerAttributes

func (v *CommandAttrValidator) ValidateRecordMarkerAttributes(
	attributes *commandpb.RecordMarkerCommandAttributes,
) (enumspb.WorkflowTaskFailedCause, error)

func (*CommandAttrValidator) ValidateSignalExternalWorkflowExecutionAttributes

func (v *CommandAttrValidator) ValidateSignalExternalWorkflowExecutionAttributes(
	namespaceID namespace.ID,
	workflowID string,
	targetNamespaceID namespace.ID,
	attributes *commandpb.SignalExternalWorkflowExecutionCommandAttributes,
) (enumspb.WorkflowTaskFailedCause, error)

func (*CommandAttrValidator) ValidateStartChildExecutionAttributes

func (v *CommandAttrValidator) ValidateStartChildExecutionAttributes(
	namespaceID namespace.ID,
	targetNamespaceID namespace.ID,
	targetNamespace namespace.Name,
	attributes *commandpb.StartChildWorkflowExecutionCommandAttributes,
	parentInfo *persistencespb.WorkflowExecutionInfo,
	defaultWorkflowTaskTimeoutFn dynamicconfig.DurationPropertyFnWithNamespaceFilter,
) (enumspb.WorkflowTaskFailedCause, error)

func (*CommandAttrValidator) ValidateTimerCancelAttributes

func (v *CommandAttrValidator) ValidateTimerCancelAttributes(
	attributes *commandpb.CancelTimerCommandAttributes,
) (enumspb.WorkflowTaskFailedCause, error)

func (*CommandAttrValidator) ValidateTimerScheduleAttributes

func (v *CommandAttrValidator) ValidateTimerScheduleAttributes(
	attributes *commandpb.StartTimerCommandAttributes,
) (enumspb.WorkflowTaskFailedCause, error)

func (*CommandAttrValidator) ValidateUpsertWorkflowSearchAttributes

func (v *CommandAttrValidator) ValidateUpsertWorkflowSearchAttributes(
	namespaceName namespace.Name,
	attributes *commandpb.UpsertWorkflowSearchAttributesCommandAttributes,
) (enumspb.WorkflowTaskFailedCause, error)

type MockWorkflowConsistencyChecker

type MockWorkflowConsistencyChecker struct {
	// contains filtered or unexported fields
}

MockWorkflowConsistencyChecker is a mock of WorkflowConsistencyChecker interface.

func NewMockWorkflowConsistencyChecker

func NewMockWorkflowConsistencyChecker(ctrl *gomock.Controller) *MockWorkflowConsistencyChecker

NewMockWorkflowConsistencyChecker creates a new mock instance.

func (*MockWorkflowConsistencyChecker) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockWorkflowConsistencyChecker) GetChasmLease

func (m *MockWorkflowConsistencyChecker) GetChasmLease(ctx context.Context, reqClock *clock.VectorClock, workflowKey definition.WorkflowKey, archetypeID chasm.ArchetypeID, lockPriority locks.Priority) (WorkflowLease, error)

GetChasmLease mocks base method.

func (*MockWorkflowConsistencyChecker) GetChasmLeaseWithConsistencyCheck

func (m *MockWorkflowConsistencyChecker) GetChasmLeaseWithConsistencyCheck(ctx context.Context, reqClock *clock.VectorClock, consistencyPredicate MutableStateConsistencyPredicate, workflowKey definition.WorkflowKey, archetypeID chasm.ArchetypeID, lockPriority locks.Priority) (WorkflowLease, error)

GetChasmLeaseWithConsistencyCheck mocks base method.

func (*MockWorkflowConsistencyChecker) GetCurrentChasmRunID

func (m *MockWorkflowConsistencyChecker) GetCurrentChasmRunID(ctx context.Context, namespaceID, workflowID string, archetypeID chasm.ArchetypeID, lockPriority locks.Priority) (string, error)

GetCurrentChasmRunID mocks base method.

func (*MockWorkflowConsistencyChecker) GetCurrentWorkflowRunID

func (m *MockWorkflowConsistencyChecker) GetCurrentWorkflowRunID(ctx context.Context, namespaceID, workflowID string, lockPriority locks.Priority) (string, error)

GetCurrentWorkflowRunID mocks base method.

func (*MockWorkflowConsistencyChecker) GetWorkflowCache

func (m *MockWorkflowConsistencyChecker) GetWorkflowCache() cache.Cache

GetWorkflowCache mocks base method.

func (*MockWorkflowConsistencyChecker) GetWorkflowLease

func (m *MockWorkflowConsistencyChecker) GetWorkflowLease(ctx context.Context, reqClock *clock.VectorClock, workflowKey definition.WorkflowKey, lockPriority locks.Priority) (WorkflowLease, error)

GetWorkflowLease mocks base method.

func (*MockWorkflowConsistencyChecker) GetWorkflowLeaseWithConsistencyCheck

func (m *MockWorkflowConsistencyChecker) GetWorkflowLeaseWithConsistencyCheck(ctx context.Context, reqClock *clock.VectorClock, consistencyPredicate MutableStateConsistencyPredicate, workflowKey definition.WorkflowKey, lockPriority locks.Priority) (WorkflowLease, error)

GetWorkflowLeaseWithConsistencyCheck mocks base method.

type MockWorkflowConsistencyCheckerMockRecorder

type MockWorkflowConsistencyCheckerMockRecorder struct {
	// contains filtered or unexported fields
}

MockWorkflowConsistencyCheckerMockRecorder is the mock recorder for MockWorkflowConsistencyChecker.

func (*MockWorkflowConsistencyCheckerMockRecorder) GetChasmLease

func (mr *MockWorkflowConsistencyCheckerMockRecorder) GetChasmLease(ctx, reqClock, workflowKey, archetypeID, lockPriority any) *gomock.Call

GetChasmLease indicates an expected call of GetChasmLease.

func (*MockWorkflowConsistencyCheckerMockRecorder) GetChasmLeaseWithConsistencyCheck

func (mr *MockWorkflowConsistencyCheckerMockRecorder) GetChasmLeaseWithConsistencyCheck(ctx, reqClock, consistencyPredicate, workflowKey, archetypeID, lockPriority any) *gomock.Call

GetChasmLeaseWithConsistencyCheck indicates an expected call of GetChasmLeaseWithConsistencyCheck.

func (*MockWorkflowConsistencyCheckerMockRecorder) GetCurrentChasmRunID

func (mr *MockWorkflowConsistencyCheckerMockRecorder) GetCurrentChasmRunID(ctx, namespaceID, workflowID, archetypeID, lockPriority any) *gomock.Call

GetCurrentChasmRunID indicates an expected call of GetCurrentChasmRunID.

func (*MockWorkflowConsistencyCheckerMockRecorder) GetCurrentWorkflowRunID

func (mr *MockWorkflowConsistencyCheckerMockRecorder) GetCurrentWorkflowRunID(ctx, namespaceID, workflowID, lockPriority any) *gomock.Call

GetCurrentWorkflowRunID indicates an expected call of GetCurrentWorkflowRunID.

func (*MockWorkflowConsistencyCheckerMockRecorder) GetWorkflowCache

func (mr *MockWorkflowConsistencyCheckerMockRecorder) GetWorkflowCache() *gomock.Call

GetWorkflowCache indicates an expected call of GetWorkflowCache.

func (*MockWorkflowConsistencyCheckerMockRecorder) GetWorkflowLease

func (mr *MockWorkflowConsistencyCheckerMockRecorder) GetWorkflowLease(ctx, reqClock, workflowKey, lockPriority any) *gomock.Call

GetWorkflowLease indicates an expected call of GetWorkflowLease.

func (*MockWorkflowConsistencyCheckerMockRecorder) GetWorkflowLeaseWithConsistencyCheck

func (mr *MockWorkflowConsistencyCheckerMockRecorder) GetWorkflowLeaseWithConsistencyCheck(ctx, reqClock, consistencyPredicate, workflowKey, lockPriority any) *gomock.Call

GetWorkflowLeaseWithConsistencyCheck indicates an expected call of GetWorkflowLeaseWithConsistencyCheck.

type MutableStateConsistencyPredicate

type MutableStateConsistencyPredicate func(mutableState historyi.MutableState) bool

type UpdateWorkflowAction

type UpdateWorkflowAction struct {
	Noop               bool
	CreateWorkflowTask bool
	// Abort all "Workflow Updates" (not persistence updates) after persistence operation is succeeded but WF lock is not released.
	AbortUpdates bool
}

type UpdateWorkflowActionFunc

type UpdateWorkflowActionFunc func(WorkflowLease) (*UpdateWorkflowAction, error)

func ResolveDuplicateWorkflowID

func ResolveDuplicateWorkflowID(
	shardContext historyi.ShardContext,
	workflowKey definition.WorkflowKey,
	namespaceEntry *namespace.Namespace,
	newRunID string,
	currentState enumsspb.WorkflowExecutionState,
	currentStatus enumspb.WorkflowExecutionStatus,
	currentRequestIDs map[string]*persistencespb.RequestIDInfo,
	currentFirstExecutionRunID string,
	wfIDReusePolicy enumspb.WorkflowIdReusePolicy,
	wfIDConflictPolicy enumspb.WorkflowIdConflictPolicy,
	currentWorkflowStartTime time.Time,
	parentExecutionInfo *workflowspb.ParentExecutionInfo,
	childWorkflowOnly bool,
) (UpdateWorkflowActionFunc, error)

ResolveDuplicateWorkflowID determines how to resolve a workflow ID duplication upon workflow start according to the WorkflowIdReusePolicy (for *completed* workflow) or WorkflowIdConflictPolicy (for *running* workflow).

NOTE: this function assumes the workflow id reuse policy Terminate-if-Running has been migrated to the workflow id conflict policy Terminate-Existing before it is invoked.

An action (ie "mitigate and allow"), an error (ie "deny") or neither (ie "allow") is returned.

func ResolveWorkflowIDConflictPolicy

func ResolveWorkflowIDConflictPolicy(
	shardContext historyi.ShardContext,
	workflowKey definition.WorkflowKey,
	namespaceEntry *namespace.Namespace,
	newRunID string,
	currentRequestIDs map[string]*persistencespb.RequestIDInfo,
	currentFirstExecutionRunID string,
	wfIDConflictPolicy enumspb.WorkflowIdConflictPolicy,
	currentWorkflowStartTime time.Time,
	parentExecutionInfo *workflowspb.ParentExecutionInfo,
	childWorkflowOnly bool,
) (UpdateWorkflowActionFunc, error)

type VersionReactivationSignalerFn

type VersionReactivationSignalerFn func(
	ctx context.Context,
	namespaceEntry *namespace.Namespace,
	deploymentName, buildID string,
	revisionNumber int64,
) error

VersionReactivationSignalerFn is a function type for sending reactivation signals to version workflows. This abstraction allows the history API layer to use the deployment client without importing it directly, avoiding import cycles between history/api and worker/workerdeployment packages. revisionNumber is the version's current revision per matching's view and is used by the signaler to compose a cluster-wide-deterministic RequestId on the signal for receiver-side dedup.

type VersionedRunID

type VersionedRunID struct {
	RunID            string
	LastWriteVersion int64
}

type WorkflowConsistencyChecker

type WorkflowConsistencyChecker interface {
	GetWorkflowCache() wcache.Cache
	GetCurrentWorkflowRunID(
		ctx context.Context,
		namespaceID string,
		workflowID string,
		lockPriority locks.Priority,
	) (string, error)
	GetWorkflowLease(
		ctx context.Context,
		reqClock *clockspb.VectorClock,
		workflowKey definition.WorkflowKey,
		lockPriority locks.Priority,
	) (WorkflowLease, error)

	GetWorkflowLeaseWithConsistencyCheck(
		ctx context.Context,
		reqClock *clockspb.VectorClock,
		consistencyPredicate MutableStateConsistencyPredicate,
		workflowKey definition.WorkflowKey,
		lockPriority locks.Priority,
	) (WorkflowLease, error)

	GetCurrentChasmRunID(
		ctx context.Context,
		namespaceID string,
		workflowID string,
		archetypeID chasm.ArchetypeID,
		lockPriority locks.Priority,
	) (string, error)

	GetChasmLease(
		ctx context.Context,
		reqClock *clockspb.VectorClock,
		workflowKey definition.WorkflowKey,
		archetypeID chasm.ArchetypeID,
		lockPriority locks.Priority,
	) (WorkflowLease, error)

	GetChasmLeaseWithConsistencyCheck(
		ctx context.Context,
		reqClock *clockspb.VectorClock,
		consistencyPredicate MutableStateConsistencyPredicate,
		workflowKey definition.WorkflowKey,
		archetypeID chasm.ArchetypeID,
		lockPriority locks.Priority,
	) (WorkflowLease, error)
}

type WorkflowConsistencyCheckerImpl

type WorkflowConsistencyCheckerImpl struct {
	// contains filtered or unexported fields
}

func NewWorkflowConsistencyChecker

func NewWorkflowConsistencyChecker(
	shardContext historyi.ShardContext,
	workflowCache wcache.Cache,
) *WorkflowConsistencyCheckerImpl

func (*WorkflowConsistencyCheckerImpl) GetChasmLease

func (c *WorkflowConsistencyCheckerImpl) GetChasmLease(
	ctx context.Context,
	reqClock *clockspb.VectorClock,
	workflowKey definition.WorkflowKey,
	archetypeID chasm.ArchetypeID,
	lockPriority locks.Priority,
) (WorkflowLease, error)

func (*WorkflowConsistencyCheckerImpl) GetChasmLeaseWithConsistencyCheck

func (c *WorkflowConsistencyCheckerImpl) GetChasmLeaseWithConsistencyCheck(
	ctx context.Context,
	reqClock *clockspb.VectorClock,
	consistencyPredicate MutableStateConsistencyPredicate,
	workflowKey definition.WorkflowKey,
	archetypeID chasm.ArchetypeID,
	lockPriority locks.Priority,
) (WorkflowLease, error)

func (*WorkflowConsistencyCheckerImpl) GetCurrentChasmRunID

func (c *WorkflowConsistencyCheckerImpl) GetCurrentChasmRunID(
	ctx context.Context,
	namespaceID string,
	workflowID string,
	archetypeID chasm.ArchetypeID,
	lockPriority locks.Priority,
) (runID string, retErr error)

func (*WorkflowConsistencyCheckerImpl) GetCurrentWorkflowRunID

func (c *WorkflowConsistencyCheckerImpl) GetCurrentWorkflowRunID(
	ctx context.Context,
	namespaceID string,
	workflowID string,
	lockPriority locks.Priority,
) (runID string, retErr error)

func (*WorkflowConsistencyCheckerImpl) GetWorkflowCache

func (c *WorkflowConsistencyCheckerImpl) GetWorkflowCache() wcache.Cache

func (*WorkflowConsistencyCheckerImpl) GetWorkflowLease

func (c *WorkflowConsistencyCheckerImpl) GetWorkflowLease(
	ctx context.Context,
	reqClock *clockspb.VectorClock,
	workflowKey definition.WorkflowKey,
	lockPriority locks.Priority,
) (WorkflowLease, error)

func (*WorkflowConsistencyCheckerImpl) GetWorkflowLeaseWithConsistencyCheck

func (c *WorkflowConsistencyCheckerImpl) GetWorkflowLeaseWithConsistencyCheck(
	ctx context.Context,
	reqClock *clockspb.VectorClock,
	consistencyPredicate MutableStateConsistencyPredicate,
	workflowKey definition.WorkflowKey,
	lockPriority locks.Priority,
) (WorkflowLease, error)

The code below should be used when custom workflow state validation is required. If consistencyPredicate failed (thus detecting a stale workflow state) workflow state will be cleared, and mutable state will be reloaded.

type WorkflowLease

type WorkflowLease interface {
	GetContext() historyi.WorkflowContext
	GetMutableState() historyi.MutableState
	GetReleaseFn() historyi.ReleaseWorkflowContextFunc
}

func NewWorkflowLease

func NewWorkflowLease(
	wfContext historyi.WorkflowContext,
	releaseFn historyi.ReleaseWorkflowContextFunc,
	mutableState historyi.MutableState,
) WorkflowLease

func NewWorkflowLeaseAndContext

func NewWorkflowLeaseAndContext(
	existingLease WorkflowLease,
	shardCtx historyi.ShardContext,
	ms historyi.MutableState,
) (WorkflowLease, error)

NOTE: must implement CreateOrUpdateLeaseFunc.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL