Skip to content

Commit

Permalink
Use internal types in persistence store parser (cadence-workflow#3821)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjdawson2016 authored Dec 7, 2020
1 parent 2675fb9 commit d59208a
Show file tree
Hide file tree
Showing 17 changed files with 2,034 additions and 427 deletions.
1,637 changes: 1,637 additions & 0 deletions common/persistence/serialization/getters.go

Large diffs are not rendered by default.

140 changes: 70 additions & 70 deletions common/persistence/serialization/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import (

"go.uber.org/thriftrw/wire"

"github.com/uber/cadence/.gen/go/sqlblobs"
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/persistence"
"github.com/uber/cadence/common/types"
)

type (
Expand Down Expand Up @@ -92,15 +92,15 @@ type (
// HistoryTreeInfo blob in a serialization agnostic format
HistoryTreeInfo struct {
CreatedTimestamp *time.Time
Ancestors []*HistoryBranchRange
Ancestors []*types.HistoryBranchRange
Info *string
}

// WorkflowExecutionInfo blob in a serialization agnostic format
WorkflowExecutionInfo struct {
ParentDomainID *string
ParentDomainID UUID
ParentWorkflowID *string
ParentRunID *string
ParentRunID UUID
InitiatedID *int64
CompletionEventBatchID *int64
CompletionEvent []byte
Expand Down Expand Up @@ -201,7 +201,7 @@ type (
InitiatedEvent []byte
InitiatedEventEncoding *string
StartedWorkflowID *string
StartedRunID *string
StartedRunID UUID
StartedEvent []byte
StartedEventEncoding *string
CreateRequestID *string
Expand Down Expand Up @@ -238,7 +238,7 @@ type (
// TaskInfo blob in a serialization agnostic format
TaskInfo struct {
WorkflowID *string
RunID *string
RunID UUID
ScheduleID *int64
ExpiryTimestamp *time.Time
CreatedTimestamp *time.Time
Expand All @@ -254,13 +254,13 @@ type (

// TransferTaskInfo blob in a serialization agnostic format
TransferTaskInfo struct {
DomainID *string
DomainID UUID
WorkflowID *string
RunID *string
RunID UUID
TaskType *int16
TargetDomainID *string
TargetDomainID UUID
TargetWorkflowID *string
TargetRunID *string
TargetRunID UUID
TaskList *string
TargetChildWorkflowOnly *bool
ScheduleID *int64
Expand All @@ -270,9 +270,9 @@ type (

// TimerTaskInfo blob in a serialization agnostic format
TimerTaskInfo struct {
DomainID *string
DomainID UUID
WorkflowID *string
RunID *string
RunID UUID
TaskType *int16
TimeoutType *int16
Version *int64
Expand All @@ -282,9 +282,9 @@ type (

// ReplicationTaskInfo blob in a serialization agnostic format
ReplicationTaskInfo struct {
DomainID *string
DomainID UUID
WorkflowID *string
RunID *string
RunID UUID
TaskType *int16
Version *int64
FirstEventID *int64
Expand All @@ -303,72 +303,72 @@ type (
// a single encoder which encodes into one format and a collection of decoders.
// Parser selects the appropriate decoder for the provided blob.
Parser interface {
ShardInfoToBlob(*sqlblobs.ShardInfo) (persistence.DataBlob, error)
DomainInfoToBlob(*sqlblobs.DomainInfo) (persistence.DataBlob, error)
HistoryTreeInfoToBlob(*sqlblobs.HistoryTreeInfo) (persistence.DataBlob, error)
WorkflowExecutionInfoToBlob(*sqlblobs.WorkflowExecutionInfo) (persistence.DataBlob, error)
ActivityInfoToBlob(*sqlblobs.ActivityInfo) (persistence.DataBlob, error)
ChildExecutionInfoToBlob(*sqlblobs.ChildExecutionInfo) (persistence.DataBlob, error)
SignalInfoToBlob(*sqlblobs.SignalInfo) (persistence.DataBlob, error)
RequestCancelInfoToBlob(*sqlblobs.RequestCancelInfo) (persistence.DataBlob, error)
TimerInfoToBlob(*sqlblobs.TimerInfo) (persistence.DataBlob, error)
TaskInfoToBlob(*sqlblobs.TaskInfo) (persistence.DataBlob, error)
TaskListInfoToBlob(*sqlblobs.TaskListInfo) (persistence.DataBlob, error)
TransferTaskInfoToBlob(*sqlblobs.TransferTaskInfo) (persistence.DataBlob, error)
TimerTaskInfoToBlob(*sqlblobs.TimerTaskInfo) (persistence.DataBlob, error)
ReplicationTaskInfoToBlob(*sqlblobs.ReplicationTaskInfo) (persistence.DataBlob, error)
ShardInfoToBlob(*ShardInfo) (persistence.DataBlob, error)
DomainInfoToBlob(*DomainInfo) (persistence.DataBlob, error)
HistoryTreeInfoToBlob(*HistoryTreeInfo) (persistence.DataBlob, error)
WorkflowExecutionInfoToBlob(*WorkflowExecutionInfo) (persistence.DataBlob, error)
ActivityInfoToBlob(*ActivityInfo) (persistence.DataBlob, error)
ChildExecutionInfoToBlob(*ChildExecutionInfo) (persistence.DataBlob, error)
SignalInfoToBlob(*SignalInfo) (persistence.DataBlob, error)
RequestCancelInfoToBlob(*RequestCancelInfo) (persistence.DataBlob, error)
TimerInfoToBlob(*TimerInfo) (persistence.DataBlob, error)
TaskInfoToBlob(*TaskInfo) (persistence.DataBlob, error)
TaskListInfoToBlob(*TaskListInfo) (persistence.DataBlob, error)
TransferTaskInfoToBlob(*TransferTaskInfo) (persistence.DataBlob, error)
TimerTaskInfoToBlob(*TimerTaskInfo) (persistence.DataBlob, error)
ReplicationTaskInfoToBlob(*ReplicationTaskInfo) (persistence.DataBlob, error)

ShardInfoFromBlob([]byte, string) (*sqlblobs.ShardInfo, error)
DomainInfoFromBlob([]byte, string) (*sqlblobs.DomainInfo, error)
HistoryTreeInfoFromBlob([]byte, string) (*sqlblobs.HistoryTreeInfo, error)
WorkflowExecutionInfoFromBlob([]byte, string) (*sqlblobs.WorkflowExecutionInfo, error)
ActivityInfoFromBlob([]byte, string) (*sqlblobs.ActivityInfo, error)
ChildExecutionInfoFromBlob([]byte, string) (*sqlblobs.ChildExecutionInfo, error)
SignalInfoFromBlob([]byte, string) (*sqlblobs.SignalInfo, error)
RequestCancelInfoFromBlob([]byte, string) (*sqlblobs.RequestCancelInfo, error)
TimerInfoFromBlob([]byte, string) (*sqlblobs.TimerInfo, error)
TaskInfoFromBlob([]byte, string) (*sqlblobs.TaskInfo, error)
TaskListInfoFromBlob([]byte, string) (*sqlblobs.TaskListInfo, error)
TransferTaskInfoFromBlob([]byte, string) (*sqlblobs.TransferTaskInfo, error)
TimerTaskInfoFromBlob([]byte, string) (*sqlblobs.TimerTaskInfo, error)
ReplicationTaskInfoFromBlob([]byte, string) (*sqlblobs.ReplicationTaskInfo, error)
ShardInfoFromBlob([]byte, string) (*ShardInfo, error)
DomainInfoFromBlob([]byte, string) (*DomainInfo, error)
HistoryTreeInfoFromBlob([]byte, string) (*HistoryTreeInfo, error)
WorkflowExecutionInfoFromBlob([]byte, string) (*WorkflowExecutionInfo, error)
ActivityInfoFromBlob([]byte, string) (*ActivityInfo, error)
ChildExecutionInfoFromBlob([]byte, string) (*ChildExecutionInfo, error)
SignalInfoFromBlob([]byte, string) (*SignalInfo, error)
RequestCancelInfoFromBlob([]byte, string) (*RequestCancelInfo, error)
TimerInfoFromBlob([]byte, string) (*TimerInfo, error)
TaskInfoFromBlob([]byte, string) (*TaskInfo, error)
TaskListInfoFromBlob([]byte, string) (*TaskListInfo, error)
TransferTaskInfoFromBlob([]byte, string) (*TransferTaskInfo, error)
TimerTaskInfoFromBlob([]byte, string) (*TimerTaskInfo, error)
ReplicationTaskInfoFromBlob([]byte, string) (*ReplicationTaskInfo, error)
}

// encoder is used to serialize structs. Each encoder implementation uses one serialization format.
encoder interface {
shardInfoToBlob(*sqlblobs.ShardInfo) ([]byte, error)
domainInfoToBlob(*sqlblobs.DomainInfo) ([]byte, error)
historyTreeInfoToBlob(*sqlblobs.HistoryTreeInfo) ([]byte, error)
workflowExecutionInfoToBlob(*sqlblobs.WorkflowExecutionInfo) ([]byte, error)
activityInfoToBlob(*sqlblobs.ActivityInfo) ([]byte, error)
childExecutionInfoToBlob(*sqlblobs.ChildExecutionInfo) ([]byte, error)
signalInfoToBlob(*sqlblobs.SignalInfo) ([]byte, error)
requestCancelInfoToBlob(*sqlblobs.RequestCancelInfo) ([]byte, error)
timerInfoToBlob(*sqlblobs.TimerInfo) ([]byte, error)
taskInfoToBlob(*sqlblobs.TaskInfo) ([]byte, error)
taskListInfoToBlob(*sqlblobs.TaskListInfo) ([]byte, error)
transferTaskInfoToBlob(*sqlblobs.TransferTaskInfo) ([]byte, error)
timerTaskInfoToBlob(*sqlblobs.TimerTaskInfo) ([]byte, error)
replicationTaskInfoToBlob(*sqlblobs.ReplicationTaskInfo) ([]byte, error)
shardInfoToBlob(*ShardInfo) ([]byte, error)
domainInfoToBlob(*DomainInfo) ([]byte, error)
historyTreeInfoToBlob(*HistoryTreeInfo) ([]byte, error)
workflowExecutionInfoToBlob(*WorkflowExecutionInfo) ([]byte, error)
activityInfoToBlob(*ActivityInfo) ([]byte, error)
childExecutionInfoToBlob(*ChildExecutionInfo) ([]byte, error)
signalInfoToBlob(*SignalInfo) ([]byte, error)
requestCancelInfoToBlob(*RequestCancelInfo) ([]byte, error)
timerInfoToBlob(*TimerInfo) ([]byte, error)
taskInfoToBlob(*TaskInfo) ([]byte, error)
taskListInfoToBlob(*TaskListInfo) ([]byte, error)
transferTaskInfoToBlob(*TransferTaskInfo) ([]byte, error)
timerTaskInfoToBlob(*TimerTaskInfo) ([]byte, error)
replicationTaskInfoToBlob(*ReplicationTaskInfo) ([]byte, error)
encodingType() common.EncodingType
}

// decoder is used to deserialize structs. Each decoder implementation uses one serialization format.
decoder interface {
shardInfoFromBlob([]byte) (*sqlblobs.ShardInfo, error)
domainInfoFromBlob([]byte) (*sqlblobs.DomainInfo, error)
historyTreeInfoFromBlob([]byte) (*sqlblobs.HistoryTreeInfo, error)
workflowExecutionInfoFromBlob([]byte) (*sqlblobs.WorkflowExecutionInfo, error)
activityInfoFromBlob([]byte) (*sqlblobs.ActivityInfo, error)
childExecutionInfoFromBlob([]byte) (*sqlblobs.ChildExecutionInfo, error)
signalInfoFromBlob([]byte) (*sqlblobs.SignalInfo, error)
requestCancelInfoFromBlob([]byte) (*sqlblobs.RequestCancelInfo, error)
timerInfoFromBlob([]byte) (*sqlblobs.TimerInfo, error)
taskInfoFromBlob([]byte) (*sqlblobs.TaskInfo, error)
taskListInfoFromBlob([]byte) (*sqlblobs.TaskListInfo, error)
transferTaskInfoFromBlob([]byte) (*sqlblobs.TransferTaskInfo, error)
timerTaskInfoFromBlob([]byte) (*sqlblobs.TimerTaskInfo, error)
replicationTaskInfoFromBlob([]byte) (*sqlblobs.ReplicationTaskInfo, error)
shardInfoFromBlob([]byte) (*ShardInfo, error)
domainInfoFromBlob([]byte) (*DomainInfo, error)
historyTreeInfoFromBlob([]byte) (*HistoryTreeInfo, error)
workflowExecutionInfoFromBlob([]byte) (*WorkflowExecutionInfo, error)
activityInfoFromBlob([]byte) (*ActivityInfo, error)
childExecutionInfoFromBlob([]byte) (*ChildExecutionInfo, error)
signalInfoFromBlob([]byte) (*SignalInfo, error)
requestCancelInfoFromBlob([]byte) (*RequestCancelInfo, error)
timerInfoFromBlob([]byte) (*TimerInfo, error)
taskInfoFromBlob([]byte) (*TaskInfo, error)
taskListInfoFromBlob([]byte) (*TaskListInfo, error)
transferTaskInfoFromBlob([]byte) (*TransferTaskInfo, error)
timerTaskInfoFromBlob([]byte) (*TimerTaskInfo, error)
replicationTaskInfoFromBlob([]byte) (*ReplicationTaskInfo, error)
}

thriftRWType interface {
Expand Down
Loading

0 comments on commit d59208a

Please sign in to comment.