Files
356bf41c2c Document Workflow Update internals (#6448)
## What changed?
<!-- Describe what has changed in this PR -->
Document Workflow Update internals.

## Why?
<!-- Tell your future self why have you made these changes -->
For better visibility on how Workflow Update is implemented.

---------

Co-authored-by: Stephan Behnke <[email protected]>
2024-09-03 12:09:06 -07:00

74 lines
2.9 KiB
Go

// The MIT License
//
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
//
// Copyright (c) 2020 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package update
import (
"context"
historypb "go.temporal.io/api/history/v1"
updatepb "go.temporal.io/api/update/v1"
persistencespb "go.temporal.io/server/api/persistence/v1"
"go.temporal.io/server/internal/effect"
)
type (
// UpdateStore represents the update package's requirements for reading Updates from the store.
UpdateStore interface {
VisitUpdates(visitor func(updID string, updInfo *persistencespb.UpdateInfo))
GetUpdateOutcome(ctx context.Context, updateID string) (*updatepb.Outcome, error)
GetCurrentVersion() int64
IsWorkflowExecutionRunning() bool
}
// EventStore is the interface that an Update needs to read and write events
// and to be notified when buffered writes have been flushed. It is the
// expectation of this code that writes to EventStore will return before the
// data has been made durable. Callbacks attached to the EventStore via
// OnAfterCommit and OnAfterRollback *must* be called after the EventStore
// state is successfully written or is discarded.
EventStore interface {
effect.Controller
// AddWorkflowExecutionUpdateAcceptedEvent writes an Update accepted
// event. The data may not be durable when this function returns.
AddWorkflowExecutionUpdateAcceptedEvent(
updateID string,
acceptedRequestMessageId string,
acceptedRequestSequencingEventId int64,
acceptedRequest *updatepb.Request,
) (*historypb.HistoryEvent, error)
// AddWorkflowExecutionUpdateCompletedEvent writes an Update completed
// event. The data may not be durable when this function returns.
AddWorkflowExecutionUpdateCompletedEvent(
acceptedEventID int64,
resp *updatepb.Response,
) (*historypb.HistoryEvent, error)
// CanAddEvent returns true if an event can be added to the EventStore.
CanAddEvent() bool
}
)