• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

uber / cadence / 0186e47c-902b-4c78-9a2f-38a5b8fc9749

15 Mar 2023 09:16AM UTC coverage: 57.076% (-0.1%) from 57.197%
0186e47c-902b-4c78-9a2f-38a5b8fc9749

push

buildkite

GitHub
ES: single interface for different ES/OpenSearch versions (#5158)

85274 of 149404 relevant lines covered (57.08%)

2294.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

58.66
/common/persistence/dataManagerInterfaces.go
1
// Copyright (c) 2017-2020 Uber Technologies, Inc.
2
// Portions of the Software are attributed to Copyright (c) 2020 Temporal Technologies Inc.
3
//
4
// Permission is hereby granted, free of charge, to any person obtaining a copy
5
// of this software and associated documentation files (the "Software"), to deal
6
// in the Software without restriction, including without limitation the rights
7
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
// copies of the Software, and to permit persons to whom the Software is
9
// furnished to do so, subject to the following conditions:
10
//
11
// The above copyright notice and this permission notice shall be included in
12
// all copies or substantial portions of the Software.
13
//
14
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
// THE SOFTWARE.
21

22
//go:generate mockgen -package $GOPACKAGE -source $GOFILE -destination dataManagerInterfaces_mock.go -self_package github.com/uber/cadence/common/persistence
23

24
package persistence
25

26
import (
27
        "context"
28
        "fmt"
29
        "strings"
30
        "time"
31

32
        "github.com/pborman/uuid"
33

34
        workflow "github.com/uber/cadence/.gen/go/shared"
35
        "github.com/uber/cadence/common"
36
        "github.com/uber/cadence/common/checksum"
37
        "github.com/uber/cadence/common/codec"
38
        "github.com/uber/cadence/common/types"
39
)
40

41
// Domain status
42
const (
43
        DomainStatusRegistered = iota
44
        DomainStatusDeprecated
45
        DomainStatusDeleted
46
)
47

48
const (
49
        // EventStoreVersion is already deprecated, this is used for forward
50
        // compatibility (so that rollback is possible).
51
        // TODO we can remove it after fixing all the query templates and when
52
        // we decide the compatibility is no longer needed.
53
        EventStoreVersion = 2
54
)
55

56
// CreateWorkflowMode workflow creation mode
57
type CreateWorkflowMode int
58

59
// QueueType is an enum that represents various queue types in persistence
60
type QueueType int
61

62
// Queue types used in queue table
63
// Use positive numbers for queue type
64
// Negative numbers are reserved for DLQ
65
const (
66
        DomainReplicationQueueType QueueType = iota + 1
67
)
68

69
// Create Workflow Execution Mode
70
const (
71
        // Fail if current record exists
72
        // Only applicable for CreateWorkflowExecution
73
        CreateWorkflowModeBrandNew CreateWorkflowMode = iota
74
        // Update current record only if workflow is closed
75
        // Only applicable for CreateWorkflowExecution
76
        CreateWorkflowModeWorkflowIDReuse
77
        // Update current record only if workflow is open
78
        // Only applicable for UpdateWorkflowExecution
79
        CreateWorkflowModeContinueAsNew
80
        // Do not update current record since workflow to
81
        // applicable for CreateWorkflowExecution, UpdateWorkflowExecution
82
        CreateWorkflowModeZombie
83
)
84

85
// UpdateWorkflowMode update mode
86
type UpdateWorkflowMode int
87

88
// Update Workflow Execution Mode
89
const (
90
        // Update workflow, including current record
91
        // NOTE: update on current record is a condition update
92
        UpdateWorkflowModeUpdateCurrent UpdateWorkflowMode = iota
93
        // Update workflow, without current record
94
        // NOTE: current record CANNOT point to the workflow to be updated
95
        UpdateWorkflowModeBypassCurrent
96
        // Update workflow, ignoring current record
97
        // NOTE: current record may or may not point to the workflow
98
        // this mode should only be used for (re-)generating workflow tasks
99
        // and there's no other changes to the workflow
100
        UpdateWorkflowModeIgnoreCurrent
101
)
102

103
// ConflictResolveWorkflowMode conflict resolve mode
104
type ConflictResolveWorkflowMode int
105

106
// Conflict Resolve Workflow Mode
107
const (
108
        // Conflict resolve workflow, including current record
109
        // NOTE: update on current record is a condition update
110
        ConflictResolveWorkflowModeUpdateCurrent ConflictResolveWorkflowMode = iota
111
        // Conflict resolve workflow, without current record
112
        // NOTE: current record CANNOT point to the workflow to be updated
113
        ConflictResolveWorkflowModeBypassCurrent
114
)
115

116
// Workflow execution states
117
const (
118
        WorkflowStateCreated = iota
119
        WorkflowStateRunning
120
        WorkflowStateCompleted
121
        WorkflowStateZombie
122
        WorkflowStateVoid
123
        WorkflowStateCorrupted
124
)
125

126
// Workflow execution close status
127
const (
128
        WorkflowCloseStatusNone = iota
129
        WorkflowCloseStatusCompleted
130
        WorkflowCloseStatusFailed
131
        WorkflowCloseStatusCanceled
132
        WorkflowCloseStatusTerminated
133
        WorkflowCloseStatusContinuedAsNew
134
        WorkflowCloseStatusTimedOut
135
)
136

137
// Types of task lists
138
const (
139
        TaskListTypeDecision = iota
140
        TaskListTypeActivity
141
)
142

143
// Kinds of task lists
144
const (
145
        TaskListKindNormal = iota
146
        TaskListKindSticky
147
)
148

149
// Transfer task types
150
const (
151
        TransferTaskTypeDecisionTask = iota
152
        TransferTaskTypeActivityTask
153
        TransferTaskTypeCloseExecution
154
        TransferTaskTypeCancelExecution
155
        TransferTaskTypeStartChildExecution
156
        TransferTaskTypeSignalExecution
157
        TransferTaskTypeRecordWorkflowStarted
158
        TransferTaskTypeResetWorkflow
159
        TransferTaskTypeUpsertWorkflowSearchAttributes
160
        TransferTaskTypeRecordWorkflowClosed
161
        TransferTaskTypeRecordChildExecutionCompleted
162
        TransferTaskTypeApplyParentClosePolicy
163
)
164

165
// Types of cross-cluster tasks
166
const (
167
        CrossClusterTaskTypeStartChildExecution = iota + 1
168
        CrossClusterTaskTypeCancelExecution
169
        CrossClusterTaskTypeSignalExecution
170
        CrossClusterTaskTypeRecordChildExeuctionCompleted
171
        CrossClusterTaskTypeApplyParentClosePolicy
172
)
173

174
// Types of replication tasks
175
const (
176
        ReplicationTaskTypeHistory = iota
177
        ReplicationTaskTypeSyncActivity
178
        ReplicationTaskTypeFailoverMarker
179
)
180

181
// Types of timers
182
const (
183
        TaskTypeDecisionTimeout = iota
184
        TaskTypeActivityTimeout
185
        TaskTypeUserTimer
186
        TaskTypeWorkflowTimeout
187
        TaskTypeDeleteHistoryEvent
188
        TaskTypeActivityRetryTimer
189
        TaskTypeWorkflowBackoffTimer
190
)
191

192
// UnknownNumRowsAffected is returned when the number of rows that an API affected cannot be determined
193
const UnknownNumRowsAffected = -1
194

195
// Types of workflow backoff timeout
196
const (
197
        WorkflowBackoffTimeoutTypeRetry = iota
198
        WorkflowBackoffTimeoutTypeCron
199
)
200

201
const (
202
        // InitialFailoverNotificationVersion is the initial failover version for a domain
203
        InitialFailoverNotificationVersion int64 = 0
204

205
        // TransferTaskTransferTargetWorkflowID is the the dummy workflow ID for transfer tasks of types
206
        // that do not have a target workflow
207
        TransferTaskTransferTargetWorkflowID = "20000000-0000-f000-f000-000000000001"
208
        // TransferTaskTransferTargetRunID is the the dummy run ID for transfer tasks of types
209
        // that do not have a target workflow
210
        TransferTaskTransferTargetRunID = "30000000-0000-f000-f000-000000000002"
211
        // CrossClusterTaskDefaultTargetRunID is the the dummy run ID for cross-cluster tasks of types
212
        // that do not have a target workflow
213
        CrossClusterTaskDefaultTargetRunID = TransferTaskTransferTargetRunID
214

215
        // indicate invalid workflow state transition
216
        invalidStateTransitionMsg = "unable to change workflow state from %v to %v, close status %v"
217
)
218

219
const numItemsInGarbageInfo = 3
220

221
type ConfigType int
222

223
const (
224
        DynamicConfig ConfigType = iota
225
)
226

227
type (
228
        // InvalidPersistenceRequestError represents invalid request to persistence
229
        InvalidPersistenceRequestError struct {
230
                Msg string
231
        }
232

233
        // CurrentWorkflowConditionFailedError represents a failed conditional update for current workflow record
234
        CurrentWorkflowConditionFailedError struct {
235
                Msg string
236
        }
237

238
        // ConditionFailedError represents a failed conditional update for execution record
239
        ConditionFailedError struct {
240
                Msg string
241
        }
242

243
        // ShardAlreadyExistError is returned when conditionally creating a shard fails
244
        ShardAlreadyExistError struct {
245
                Msg string
246
        }
247

248
        // ShardOwnershipLostError is returned when conditional update fails due to RangeID for the shard
249
        ShardOwnershipLostError struct {
250
                ShardID int
251
                Msg     string
252
        }
253

254
        // WorkflowExecutionAlreadyStartedError is returned when creating a new workflow failed.
255
        WorkflowExecutionAlreadyStartedError struct {
256
                Msg              string
257
                StartRequestID   string
258
                RunID            string
259
                State            int
260
                CloseStatus      int
261
                LastWriteVersion int64
262
        }
263

264
        // TimeoutError is returned when a write operation fails due to a timeout
265
        TimeoutError struct {
266
                Msg string
267
        }
268

269
        // DBUnavailableError is returned when the database is unavailable, could be for various reasons.
270
        DBUnavailableError struct {
271
                Msg string
272
        }
273

274
        // TransactionSizeLimitError is returned when the transaction size is too large
275
        TransactionSizeLimitError struct {
276
                Msg string
277
        }
278

279
        // ShardInfo describes a shard
280
        ShardInfo struct {
281
                ShardID                           int                               `json:"shard_id"`
282
                Owner                             string                            `json:"owner"`
283
                RangeID                           int64                             `json:"range_id"`
284
                StolenSinceRenew                  int                               `json:"stolen_since_renew"`
285
                UpdatedAt                         time.Time                         `json:"updated_at"`
286
                ReplicationAckLevel               int64                             `json:"replication_ack_level"`
287
                ReplicationDLQAckLevel            map[string]int64                  `json:"replication_dlq_ack_level"`
288
                TransferAckLevel                  int64                             `json:"transfer_ack_level"`
289
                TimerAckLevel                     time.Time                         `json:"timer_ack_level"`
290
                ClusterTransferAckLevel           map[string]int64                  `json:"cluster_transfer_ack_level"`
291
                ClusterTimerAckLevel              map[string]time.Time              `json:"cluster_timer_ack_level"`
292
                TransferProcessingQueueStates     *types.ProcessingQueueStates      `json:"transfer_processing_queue_states"`
293
                CrossClusterProcessingQueueStates *types.ProcessingQueueStates      `json:"cross_cluster_queue_states"`
294
                TimerProcessingQueueStates        *types.ProcessingQueueStates      `json:"timer_processing_queue_states"`
295
                ClusterReplicationLevel           map[string]int64                  `json:"cluster_replication_level"`
296
                DomainNotificationVersion         int64                             `json:"domain_notification_version"`
297
                PendingFailoverMarkers            []*types.FailoverMarkerAttributes `json:"pending_failover_markers"`
298
        }
299

300
        // WorkflowExecutionInfo describes a workflow execution
301
        WorkflowExecutionInfo struct {
302
                DomainID                           string
303
                WorkflowID                         string
304
                RunID                              string
305
                FirstExecutionRunID                string
306
                ParentDomainID                     string
307
                ParentWorkflowID                   string
308
                ParentRunID                        string
309
                InitiatedID                        int64
310
                CompletionEventBatchID             int64
311
                CompletionEvent                    *types.HistoryEvent
312
                TaskList                           string
313
                WorkflowTypeName                   string
314
                WorkflowTimeout                    int32
315
                DecisionStartToCloseTimeout        int32
316
                ExecutionContext                   []byte
317
                State                              int
318
                CloseStatus                        int
319
                LastFirstEventID                   int64
320
                LastEventTaskID                    int64
321
                NextEventID                        int64
322
                LastProcessedEvent                 int64
323
                StartTimestamp                     time.Time
324
                LastUpdatedTimestamp               time.Time
325
                CreateRequestID                    string
326
                SignalCount                        int32
327
                DecisionVersion                    int64
328
                DecisionScheduleID                 int64
329
                DecisionStartedID                  int64
330
                DecisionRequestID                  string
331
                DecisionTimeout                    int32
332
                DecisionAttempt                    int64
333
                DecisionStartedTimestamp           int64
334
                DecisionScheduledTimestamp         int64
335
                DecisionOriginalScheduledTimestamp int64
336
                CancelRequested                    bool
337
                CancelRequestID                    string
338
                StickyTaskList                     string
339
                StickyScheduleToStartTimeout       int32
340
                ClientLibraryVersion               string
341
                ClientFeatureVersion               string
342
                ClientImpl                         string
343
                AutoResetPoints                    *types.ResetPoints
344
                Memo                               map[string][]byte
345
                SearchAttributes                   map[string][]byte
346
                // for retry
347
                Attempt            int32
348
                HasRetryPolicy     bool
349
                InitialInterval    int32
350
                BackoffCoefficient float64
351
                MaximumInterval    int32
352
                ExpirationTime     time.Time
353
                MaximumAttempts    int32
354
                NonRetriableErrors []string
355
                BranchToken        []byte
356
                // Cron
357
                CronSchedule      string
358
                IsCron            bool
359
                ExpirationSeconds int32 // TODO: is this field useful?
360
        }
361

362
        // ExecutionStats is the statistics about workflow execution
363
        ExecutionStats struct {
364
                HistorySize int64
365
        }
366

367
        // ReplicationState represents mutable state information for global domains.
368
        // This information is used by replication protocol when applying events from remote clusters
369
        // TODO: remove this struct after all 2DC workflows complete
370
        ReplicationState struct {
371
                CurrentVersion      int64
372
                StartVersion        int64
373
                LastWriteVersion    int64
374
                LastWriteEventID    int64
375
                LastReplicationInfo map[string]*ReplicationInfo
376
        }
377

378
        // CurrentWorkflowExecution describes a current execution record
379
        CurrentWorkflowExecution struct {
380
                DomainID     string
381
                WorkflowID   string
382
                RunID        string
383
                State        int
384
                CurrentRunID string
385
        }
386

387
        // TransferTaskInfo describes a transfer task
388
        TransferTaskInfo struct {
389
                DomainID                string
390
                WorkflowID              string
391
                RunID                   string
392
                VisibilityTimestamp     time.Time
393
                TaskID                  int64
394
                TargetDomainID          string
395
                TargetDomainIDs         map[string]struct{} // used for ApplyParentPolicy request
396
                TargetWorkflowID        string
397
                TargetRunID             string
398
                TargetChildWorkflowOnly bool
399
                TaskList                string
400
                TaskType                int
401
                ScheduleID              int64
402
                Version                 int64
403
                RecordVisibility        bool
404
        }
405

406
        // CrossClusterTaskInfo describes a cross-cluster task
407
        // Cross cluster tasks are exactly like transfer tasks so
408
        // instead of creating another struct and duplicating the same
409
        // logic everywhere. We reuse TransferTaskInfo
410
        CrossClusterTaskInfo = TransferTaskInfo
411

412
        // ReplicationTaskInfo describes the replication task created for replication of history events
413
        ReplicationTaskInfo struct {
414
                DomainID          string
415
                WorkflowID        string
416
                RunID             string
417
                TaskID            int64
418
                TaskType          int
419
                FirstEventID      int64
420
                NextEventID       int64
421
                Version           int64
422
                ScheduledID       int64
423
                BranchToken       []byte
424
                NewRunBranchToken []byte
425
                CreationTime      int64
426
        }
427

428
        // TimerTaskInfo describes a timer task.
429
        TimerTaskInfo struct {
430
                DomainID            string
431
                WorkflowID          string
432
                RunID               string
433
                VisibilityTimestamp time.Time
434
                TaskID              int64
435
                TaskType            int
436
                TimeoutType         int
437
                EventID             int64
438
                ScheduleAttempt     int64
439
                Version             int64
440
        }
441

442
        // TaskListInfo describes a state of a task list implementation.
443
        TaskListInfo struct {
444
                DomainID    string
445
                Name        string
446
                TaskType    int
447
                RangeID     int64
448
                AckLevel    int64
449
                Kind        int
450
                Expiry      time.Time
451
                LastUpdated time.Time
452
        }
453

454
        // TaskInfo describes either activity or decision task
455
        TaskInfo struct {
456
                DomainID               string
457
                WorkflowID             string
458
                RunID                  string
459
                TaskID                 int64
460
                ScheduleID             int64
461
                ScheduleToStartTimeout int32
462
                Expiry                 time.Time
463
                CreatedTime            time.Time
464
        }
465

466
        // TaskKey gives primary key info for a specific task
467
        TaskKey struct {
468
                DomainID     string
469
                TaskListName string
470
                TaskType     int
471
                TaskID       int64
472
        }
473

474
        // Task is the generic interface for workflow tasks
475
        Task interface {
476
                GetType() int
477
                GetVersion() int64
478
                SetVersion(version int64)
479
                GetTaskID() int64
480
                SetTaskID(id int64)
481
                GetVisibilityTimestamp() time.Time
482
                SetVisibilityTimestamp(timestamp time.Time)
483
        }
484

485
        // ActivityTask identifies a transfer task for activity
486
        ActivityTask struct {
487
                VisibilityTimestamp time.Time
488
                TaskID              int64
489
                DomainID            string
490
                TaskList            string
491
                ScheduleID          int64
492
                Version             int64
493
        }
494

495
        // DecisionTask identifies a transfer task for decision
496
        DecisionTask struct {
497
                VisibilityTimestamp time.Time
498
                TaskID              int64
499
                DomainID            string
500
                TaskList            string
501
                ScheduleID          int64
502
                Version             int64
503
                RecordVisibility    bool
504
        }
505

506
        // RecordWorkflowStartedTask identifites a transfer task for writing visibility open execution record
507
        RecordWorkflowStartedTask struct {
508
                VisibilityTimestamp time.Time
509
                TaskID              int64
510
                Version             int64
511
        }
512

513
        // ResetWorkflowTask identifites a transfer task to reset workflow
514
        ResetWorkflowTask struct {
515
                VisibilityTimestamp time.Time
516
                TaskID              int64
517
                Version             int64
518
        }
519

520
        // CloseExecutionTask identifies a transfer task for deletion of execution
521
        CloseExecutionTask struct {
522
                VisibilityTimestamp time.Time
523
                TaskID              int64
524
                Version             int64
525
        }
526

527
        // DeleteHistoryEventTask identifies a timer task for deletion of history events of completed execution.
528
        DeleteHistoryEventTask struct {
529
                VisibilityTimestamp time.Time
530
                TaskID              int64
531
                Version             int64
532
        }
533

534
        // DecisionTimeoutTask identifies a timeout task.
535
        DecisionTimeoutTask struct {
536
                VisibilityTimestamp time.Time
537
                TaskID              int64
538
                EventID             int64
539
                ScheduleAttempt     int64
540
                TimeoutType         int
541
                Version             int64
542
        }
543

544
        // WorkflowTimeoutTask identifies a timeout task.
545
        WorkflowTimeoutTask struct {
546
                VisibilityTimestamp time.Time
547
                TaskID              int64
548
                Version             int64
549
        }
550

551
        // CancelExecutionTask identifies a transfer task for cancel of execution
552
        CancelExecutionTask struct {
553
                VisibilityTimestamp     time.Time
554
                TaskID                  int64
555
                TargetDomainID          string
556
                TargetWorkflowID        string
557
                TargetRunID             string
558
                TargetChildWorkflowOnly bool
559
                InitiatedID             int64
560
                Version                 int64
561
        }
562

563
        // SignalExecutionTask identifies a transfer task for signal execution
564
        SignalExecutionTask struct {
565
                VisibilityTimestamp     time.Time
566
                TaskID                  int64
567
                TargetDomainID          string
568
                TargetWorkflowID        string
569
                TargetRunID             string
570
                TargetChildWorkflowOnly bool
571
                InitiatedID             int64
572
                Version                 int64
573
        }
574

575
        // UpsertWorkflowSearchAttributesTask identifies a transfer task for upsert search attributes
576
        UpsertWorkflowSearchAttributesTask struct {
577
                VisibilityTimestamp time.Time
578
                TaskID              int64
579
                // this version is not used by task processing for validation,
580
                // instead, the version is used by elastic search
581
                Version int64
582
        }
583

584
        // StartChildExecutionTask identifies a transfer task for starting child execution
585
        StartChildExecutionTask struct {
586
                VisibilityTimestamp time.Time
587
                TaskID              int64
588
                TargetDomainID      string
589
                TargetWorkflowID    string
590
                InitiatedID         int64
591
                Version             int64
592
        }
593

594
        // RecordWorkflowClosedTask identifies a transfer task for writing visibility close execution record
595
        RecordWorkflowClosedTask struct {
596
                VisibilityTimestamp time.Time
597
                TaskID              int64
598
                Version             int64
599
        }
600

601
        // RecordChildExecutionCompletedTask identifies a task for recording the competion of a child workflow
602
        RecordChildExecutionCompletedTask struct {
603
                VisibilityTimestamp time.Time
604
                TaskID              int64
605
                TargetDomainID      string
606
                TargetWorkflowID    string
607
                TargetRunID         string
608
                Version             int64
609
        }
610

611
        // ApplyParentClosePolicyTask identifies a task for applying parent close policy
612
        ApplyParentClosePolicyTask struct {
613
                VisibilityTimestamp time.Time
614
                TaskID              int64
615
                TargetDomainIDs     map[string]struct{}
616
                Version             int64
617
        }
618

619
        // CrossClusterStartChildExecutionTask is the cross-cluster version of StartChildExecutionTask
620
        CrossClusterStartChildExecutionTask struct {
621
                StartChildExecutionTask
622

623
                TargetCluster string
624
        }
625

626
        // CrossClusterCancelExecutionTask is the cross-cluster version of CancelExecutionTask
627
        CrossClusterCancelExecutionTask struct {
628
                CancelExecutionTask
629

630
                TargetCluster string
631
        }
632

633
        // CrossClusterSignalExecutionTask is the cross-cluster version of SignalExecutionTask
634
        CrossClusterSignalExecutionTask struct {
635
                SignalExecutionTask
636

637
                TargetCluster string
638
        }
639

640
        // CrossClusterRecordChildExecutionCompletedTask is the cross-cluster version of RecordChildExecutionCompletedTask
641
        CrossClusterRecordChildExecutionCompletedTask struct {
642
                RecordChildExecutionCompletedTask
643

644
                TargetCluster string
645
        }
646

647
        // CrossClusterApplyParentClosePolicyTask is the cross-cluster version of ApplyParentClosePolicyTask
648
        CrossClusterApplyParentClosePolicyTask struct {
649
                ApplyParentClosePolicyTask
650

651
                TargetCluster string
652
        }
653

654
        // ActivityTimeoutTask identifies a timeout task.
655
        ActivityTimeoutTask struct {
656
                VisibilityTimestamp time.Time
657
                TaskID              int64
658
                TimeoutType         int
659
                EventID             int64
660
                Attempt             int64
661
                Version             int64
662
        }
663

664
        // UserTimerTask identifies a timeout task.
665
        UserTimerTask struct {
666
                VisibilityTimestamp time.Time
667
                TaskID              int64
668
                EventID             int64
669
                Version             int64
670
        }
671

672
        // ActivityRetryTimerTask to schedule a retry task for activity
673
        ActivityRetryTimerTask struct {
674
                VisibilityTimestamp time.Time
675
                TaskID              int64
676
                EventID             int64
677
                Version             int64
678
                Attempt             int32
679
        }
680

681
        // WorkflowBackoffTimerTask to schedule first decision task for retried workflow
682
        WorkflowBackoffTimerTask struct {
683
                VisibilityTimestamp time.Time
684
                TaskID              int64
685
                EventID             int64 // TODO this attribute is not used?
686
                Version             int64
687
                TimeoutType         int // 0 for retry, 1 for cron.
688
        }
689

690
        // HistoryReplicationTask is the replication task created for shipping history replication events to other clusters
691
        HistoryReplicationTask struct {
692
                VisibilityTimestamp time.Time
693
                TaskID              int64
694
                FirstEventID        int64
695
                NextEventID         int64
696
                Version             int64
697
                BranchToken         []byte
698
                NewRunBranchToken   []byte
699
        }
700

701
        // SyncActivityTask is the replication task created for shipping activity info to other clusters
702
        SyncActivityTask struct {
703
                VisibilityTimestamp time.Time
704
                TaskID              int64
705
                Version             int64
706
                ScheduledID         int64
707
        }
708

709
        // FailoverMarkerTask is the marker for graceful failover
710
        FailoverMarkerTask struct {
711
                TaskID              int64
712
                VisibilityTimestamp time.Time
713
                Version             int64
714
                DomainID            string
715
        }
716

717
        // ReplicationInfo represents the information stored for last replication event details per cluster
718
        ReplicationInfo struct {
719
                Version     int64
720
                LastEventID int64
721
        }
722

723
        // VersionHistoryItem contains the event id and the associated version
724
        VersionHistoryItem struct {
725
                EventID int64
726
                Version int64
727
        }
728

729
        // VersionHistory provides operations on version history
730
        VersionHistory struct {
731
                BranchToken []byte
732
                Items       []*VersionHistoryItem
733
        }
734

735
        // VersionHistories contains a set of VersionHistory
736
        VersionHistories struct {
737
                CurrentVersionHistoryIndex int
738
                Histories                  []*VersionHistory
739
        }
740

741
        // WorkflowMutableState indicates workflow related state
742
        WorkflowMutableState struct {
743
                ActivityInfos       map[int64]*ActivityInfo
744
                TimerInfos          map[string]*TimerInfo
745
                ChildExecutionInfos map[int64]*ChildExecutionInfo
746
                RequestCancelInfos  map[int64]*RequestCancelInfo
747
                SignalInfos         map[int64]*SignalInfo
748
                SignalRequestedIDs  map[string]struct{}
749
                ExecutionInfo       *WorkflowExecutionInfo
750
                ExecutionStats      *ExecutionStats
751
                BufferedEvents      []*types.HistoryEvent
752
                VersionHistories    *VersionHistories
753
                ReplicationState    *ReplicationState // TODO: remove this after all 2DC workflows complete
754
                Checksum            checksum.Checksum
755
        }
756

757
        // ActivityInfo details.
758
        ActivityInfo struct {
759
                Version                  int64
760
                ScheduleID               int64
761
                ScheduledEventBatchID    int64
762
                ScheduledEvent           *types.HistoryEvent
763
                ScheduledTime            time.Time
764
                StartedID                int64
765
                StartedEvent             *types.HistoryEvent
766
                StartedTime              time.Time
767
                DomainID                 string
768
                ActivityID               string
769
                RequestID                string
770
                Details                  []byte
771
                ScheduleToStartTimeout   int32
772
                ScheduleToCloseTimeout   int32
773
                StartToCloseTimeout      int32
774
                HeartbeatTimeout         int32
775
                CancelRequested          bool
776
                CancelRequestID          int64
777
                LastHeartBeatUpdatedTime time.Time
778
                TimerTaskStatus          int32
779
                // For retry
780
                Attempt            int32
781
                StartedIdentity    string
782
                TaskList           string
783
                HasRetryPolicy     bool
784
                InitialInterval    int32
785
                BackoffCoefficient float64
786
                MaximumInterval    int32
787
                ExpirationTime     time.Time
788
                MaximumAttempts    int32
789
                NonRetriableErrors []string
790
                LastFailureReason  string
791
                LastWorkerIdentity string
792
                LastFailureDetails []byte
793
                // Not written to database - This is used only for deduping heartbeat timer creation
794
                LastHeartbeatTimeoutVisibilityInSeconds int64
795
        }
796

797
        // TimerInfo details - metadata about user timer info.
798
        TimerInfo struct {
799
                Version    int64
800
                TimerID    string
801
                StartedID  int64
802
                ExpiryTime time.Time
803
                TaskStatus int64
804
        }
805

806
        // ChildExecutionInfo has details for pending child executions.
807
        ChildExecutionInfo struct {
808
                Version               int64
809
                InitiatedID           int64
810
                InitiatedEventBatchID int64
811
                InitiatedEvent        *types.HistoryEvent
812
                StartedID             int64
813
                StartedWorkflowID     string
814
                StartedRunID          string
815
                StartedEvent          *types.HistoryEvent
816
                CreateRequestID       string
817
                DomainID              string
818
                DomainNameDEPRECATED  string // deprecated: please use DomainID field instead
819
                WorkflowTypeName      string
820
                ParentClosePolicy     types.ParentClosePolicy
821
        }
822

823
        // RequestCancelInfo has details for pending external workflow cancellations
824
        RequestCancelInfo struct {
825
                Version               int64
826
                InitiatedEventBatchID int64
827
                InitiatedID           int64
828
                CancelRequestID       string
829
        }
830

831
        // SignalInfo has details for pending external workflow signal
832
        SignalInfo struct {
833
                Version               int64
834
                InitiatedEventBatchID int64
835
                InitiatedID           int64
836
                SignalRequestID       string
837
                SignalName            string
838
                Input                 []byte
839
                Control               []byte
840
        }
841

842
        // CreateShardRequest is used to create a shard in executions table
843
        CreateShardRequest struct {
844
                ShardInfo *ShardInfo
845
        }
846

847
        // GetShardRequest is used to get shard information
848
        GetShardRequest struct {
849
                ShardID int
850
        }
851

852
        // GetShardResponse is the response to GetShard
853
        GetShardResponse struct {
854
                ShardInfo *ShardInfo
855
        }
856

857
        // UpdateShardRequest is used to update shard information
858
        UpdateShardRequest struct {
859
                ShardInfo       *ShardInfo
860
                PreviousRangeID int64
861
        }
862

863
        // CreateWorkflowExecutionRequest is used to write a new workflow execution
864
        CreateWorkflowExecutionRequest struct {
865
                RangeID int64
866

867
                Mode CreateWorkflowMode
868

869
                PreviousRunID            string
870
                PreviousLastWriteVersion int64
871

872
                NewWorkflowSnapshot WorkflowSnapshot
873

874
                DomainName string
875
        }
876

877
        // CreateWorkflowExecutionResponse is the response to CreateWorkflowExecutionRequest
878
        CreateWorkflowExecutionResponse struct {
879
                MutableStateUpdateSessionStats *MutableStateUpdateSessionStats
880
        }
881

882
        // GetWorkflowExecutionRequest is used to retrieve the info of a workflow execution
883
        GetWorkflowExecutionRequest struct {
884
                DomainID   string
885
                Execution  types.WorkflowExecution
886
                DomainName string
887
        }
888

889
        // GetWorkflowExecutionResponse is the response to GetworkflowExecutionRequest
890
        GetWorkflowExecutionResponse struct {
891
                State             *WorkflowMutableState
892
                MutableStateStats *MutableStateStats
893
        }
894

895
        // GetCurrentExecutionRequest is used to retrieve the current RunId for an execution
896
        GetCurrentExecutionRequest struct {
897
                DomainID   string
898
                WorkflowID string
899
                DomainName string
900
        }
901

902
        // ListCurrentExecutionsRequest is request to ListCurrentExecutions
903
        ListCurrentExecutionsRequest struct {
904
                PageSize  int
905
                PageToken []byte
906
        }
907

908
        // ListCurrentExecutionsResponse is the response to ListCurrentExecutionsRequest
909
        ListCurrentExecutionsResponse struct {
910
                Executions []*CurrentWorkflowExecution
911
                PageToken  []byte
912
        }
913

914
        // IsWorkflowExecutionExistsRequest is used to check if the concrete execution exists
915
        IsWorkflowExecutionExistsRequest struct {
916
                DomainID   string
917
                DomainName string
918
                WorkflowID string
919
                RunID      string
920
        }
921

922
        // ListConcreteExecutionsRequest is request to ListConcreteExecutions
923
        ListConcreteExecutionsRequest struct {
924
                PageSize  int
925
                PageToken []byte
926
        }
927

928
        // ListConcreteExecutionsResponse is response to ListConcreteExecutions
929
        ListConcreteExecutionsResponse struct {
930
                Executions []*ListConcreteExecutionsEntity
931
                PageToken  []byte
932
        }
933

934
        // ListConcreteExecutionsEntity is a single entity in ListConcreteExecutionsResponse
935
        ListConcreteExecutionsEntity struct {
936
                ExecutionInfo    *WorkflowExecutionInfo
937
                VersionHistories *VersionHistories
938
        }
939

940
        // GetCurrentExecutionResponse is the response to GetCurrentExecution
941
        GetCurrentExecutionResponse struct {
942
                StartRequestID   string
943
                RunID            string
944
                State            int
945
                CloseStatus      int
946
                LastWriteVersion int64
947
        }
948

949
        // IsWorkflowExecutionExistsResponse is the response to IsWorkflowExecutionExists
950
        IsWorkflowExecutionExistsResponse struct {
951
                Exists bool
952
        }
953

954
        // UpdateWorkflowExecutionRequest is used to update a workflow execution
955
        UpdateWorkflowExecutionRequest struct {
956
                RangeID int64
957

958
                Mode UpdateWorkflowMode
959

960
                UpdateWorkflowMutation WorkflowMutation
961

962
                NewWorkflowSnapshot *WorkflowSnapshot
963

964
                Encoding common.EncodingType // optional binary encoding type
965

966
                DomainName string
967
        }
968

969
        // ConflictResolveWorkflowExecutionRequest is used to reset workflow execution state for a single run
970
        ConflictResolveWorkflowExecutionRequest struct {
971
                RangeID int64
972

973
                Mode ConflictResolveWorkflowMode
974

975
                // workflow to be resetted
976
                ResetWorkflowSnapshot WorkflowSnapshot
977

978
                // maybe new workflow
979
                NewWorkflowSnapshot *WorkflowSnapshot
980

981
                // current workflow
982
                CurrentWorkflowMutation *WorkflowMutation
983

984
                Encoding common.EncodingType // optional binary encoding type
985

986
                DomainName string
987
        }
988

989
        // WorkflowEvents is used as generic workflow history events transaction container
990
        WorkflowEvents struct {
991
                DomainID    string
992
                WorkflowID  string
993
                RunID       string
994
                BranchToken []byte
995
                Events      []*types.HistoryEvent
996
        }
997

998
        // WorkflowMutation is used as generic workflow execution state mutation
999
        WorkflowMutation struct {
1000
                ExecutionInfo    *WorkflowExecutionInfo
1001
                ExecutionStats   *ExecutionStats
1002
                VersionHistories *VersionHistories
1003

1004
                UpsertActivityInfos       []*ActivityInfo
1005
                DeleteActivityInfos       []int64
1006
                UpsertTimerInfos          []*TimerInfo
1007
                DeleteTimerInfos          []string
1008
                UpsertChildExecutionInfos []*ChildExecutionInfo
1009
                DeleteChildExecutionInfos []int64
1010
                UpsertRequestCancelInfos  []*RequestCancelInfo
1011
                DeleteRequestCancelInfos  []int64
1012
                UpsertSignalInfos         []*SignalInfo
1013
                DeleteSignalInfos         []int64
1014
                UpsertSignalRequestedIDs  []string
1015
                DeleteSignalRequestedIDs  []string
1016
                NewBufferedEvents         []*types.HistoryEvent
1017
                ClearBufferedEvents       bool
1018

1019
                TransferTasks     []Task
1020
                CrossClusterTasks []Task
1021
                ReplicationTasks  []Task
1022
                TimerTasks        []Task
1023

1024
                Condition int64
1025
                Checksum  checksum.Checksum
1026
        }
1027

1028
        // WorkflowSnapshot is used as generic workflow execution state snapshot
1029
        WorkflowSnapshot struct {
1030
                ExecutionInfo    *WorkflowExecutionInfo
1031
                ExecutionStats   *ExecutionStats
1032
                VersionHistories *VersionHistories
1033

1034
                ActivityInfos       []*ActivityInfo
1035
                TimerInfos          []*TimerInfo
1036
                ChildExecutionInfos []*ChildExecutionInfo
1037
                RequestCancelInfos  []*RequestCancelInfo
1038
                SignalInfos         []*SignalInfo
1039
                SignalRequestedIDs  []string
1040

1041
                TransferTasks     []Task
1042
                CrossClusterTasks []Task
1043
                ReplicationTasks  []Task
1044
                TimerTasks        []Task
1045

1046
                Condition int64
1047
                Checksum  checksum.Checksum
1048
        }
1049

1050
        // DeleteWorkflowExecutionRequest is used to delete a workflow execution
1051
        DeleteWorkflowExecutionRequest struct {
1052
                DomainID   string
1053
                WorkflowID string
1054
                RunID      string
1055
                DomainName string
1056
        }
1057

1058
        // DeleteCurrentWorkflowExecutionRequest is used to delete the current workflow execution
1059
        DeleteCurrentWorkflowExecutionRequest struct {
1060
                DomainID   string
1061
                WorkflowID string
1062
                RunID      string
1063
                DomainName string
1064
        }
1065

1066
        // GetTransferTasksRequest is used to read tasks from the transfer task queue
1067
        GetTransferTasksRequest struct {
1068
                ReadLevel     int64
1069
                MaxReadLevel  int64
1070
                BatchSize     int
1071
                NextPageToken []byte
1072
        }
1073

1074
        // GetTransferTasksResponse is the response to GetTransferTasksRequest
1075
        GetTransferTasksResponse struct {
1076
                Tasks         []*TransferTaskInfo
1077
                NextPageToken []byte
1078
        }
1079

1080
        // GetCrossClusterTasksRequest is used to read tasks from the cross-cluster task queue
1081
        GetCrossClusterTasksRequest struct {
1082
                TargetCluster string
1083
                ReadLevel     int64
1084
                MaxReadLevel  int64
1085
                BatchSize     int
1086
                NextPageToken []byte
1087
        }
1088

1089
        // GetCrossClusterTasksResponse is the response to GetCrossClusterTasksRequest
1090
        GetCrossClusterTasksResponse struct {
1091
                Tasks         []*CrossClusterTaskInfo
1092
                NextPageToken []byte
1093
        }
1094

1095
        // GetReplicationTasksRequest is used to read tasks from the replication task queue
1096
        GetReplicationTasksRequest struct {
1097
                ReadLevel     int64
1098
                MaxReadLevel  int64
1099
                BatchSize     int
1100
                NextPageToken []byte
1101
        }
1102

1103
        // GetReplicationTasksResponse is the response to GetReplicationTask
1104
        GetReplicationTasksResponse struct {
1105
                Tasks         []*ReplicationTaskInfo
1106
                NextPageToken []byte
1107
        }
1108

1109
        // CompleteTransferTaskRequest is used to complete a task in the transfer task queue
1110
        CompleteTransferTaskRequest struct {
1111
                TaskID int64
1112
        }
1113

1114
        // RangeCompleteTransferTaskRequest is used to complete a range of tasks in the transfer task queue
1115
        RangeCompleteTransferTaskRequest struct {
1116
                ExclusiveBeginTaskID int64
1117
                InclusiveEndTaskID   int64
1118
                PageSize             int
1119
        }
1120

1121
        // RangeCompleteTransferTaskResponse is the response of RangeCompleteTransferTask
1122
        RangeCompleteTransferTaskResponse struct {
1123
                TasksCompleted int
1124
        }
1125

1126
        // CompleteCrossClusterTaskRequest is used to complete a task in the cross-cluster task queue
1127
        CompleteCrossClusterTaskRequest struct {
1128
                TargetCluster string
1129
                TaskID        int64
1130
        }
1131

1132
        // RangeCompleteCrossClusterTaskRequest is used to complete a range of tasks in the cross-cluster task queue
1133
        RangeCompleteCrossClusterTaskRequest struct {
1134
                TargetCluster        string
1135
                ExclusiveBeginTaskID int64
1136
                InclusiveEndTaskID   int64
1137
                PageSize             int
1138
        }
1139

1140
        // RangeCompleteCrossClusterTaskResponse is the response of RangeCompleteCrossClusterTask
1141
        RangeCompleteCrossClusterTaskResponse struct {
1142
                TasksCompleted int
1143
        }
1144

1145
        // CompleteReplicationTaskRequest is used to complete a task in the replication task queue
1146
        CompleteReplicationTaskRequest struct {
1147
                TaskID int64
1148
        }
1149

1150
        // RangeCompleteReplicationTaskRequest is used to complete a range of task in the replication task queue
1151
        RangeCompleteReplicationTaskRequest struct {
1152
                InclusiveEndTaskID int64
1153
                PageSize           int
1154
        }
1155

1156
        // RangeCompleteReplicationTaskResponse is the response of RangeCompleteReplicationTask
1157
        RangeCompleteReplicationTaskResponse struct {
1158
                TasksCompleted int
1159
        }
1160

1161
        // PutReplicationTaskToDLQRequest is used to put a replication task to dlq
1162
        PutReplicationTaskToDLQRequest struct {
1163
                SourceClusterName string
1164
                TaskInfo          *ReplicationTaskInfo
1165
                DomainName        string
1166
        }
1167

1168
        // GetReplicationTasksFromDLQRequest is used to get replication tasks from dlq
1169
        GetReplicationTasksFromDLQRequest struct {
1170
                SourceClusterName string
1171
                GetReplicationTasksRequest
1172
        }
1173

1174
        // GetReplicationDLQSizeRequest is used to get one replication task from dlq
1175
        GetReplicationDLQSizeRequest struct {
1176
                SourceClusterName string
1177
        }
1178

1179
        // DeleteReplicationTaskFromDLQRequest is used to delete replication task from DLQ
1180
        DeleteReplicationTaskFromDLQRequest struct {
1181
                SourceClusterName string
1182
                TaskID            int64
1183
        }
1184

1185
        //RangeDeleteReplicationTaskFromDLQRequest is used to delete replication tasks from DLQ
1186
        RangeDeleteReplicationTaskFromDLQRequest struct {
1187
                SourceClusterName    string
1188
                ExclusiveBeginTaskID int64
1189
                InclusiveEndTaskID   int64
1190
                PageSize             int
1191
        }
1192

1193
        //RangeDeleteReplicationTaskFromDLQResponse is the response of RangeDeleteReplicationTaskFromDLQ
1194
        RangeDeleteReplicationTaskFromDLQResponse struct {
1195
                TasksCompleted int
1196
        }
1197

1198
        // GetReplicationTasksFromDLQResponse is the response for GetReplicationTasksFromDLQ
1199
        GetReplicationTasksFromDLQResponse = GetReplicationTasksResponse
1200

1201
        // GetReplicationDLQSizeResponse is the response for GetReplicationDLQSize
1202
        GetReplicationDLQSizeResponse struct {
1203
                Size int64
1204
        }
1205

1206
        // RangeCompleteTimerTaskRequest is used to complete a range of tasks in the timer task queue
1207
        RangeCompleteTimerTaskRequest struct {
1208
                InclusiveBeginTimestamp time.Time
1209
                ExclusiveEndTimestamp   time.Time
1210
                PageSize                int
1211
        }
1212

1213
        // RangeCompleteTimerTaskResponse is the response of RangeCompleteTimerTask
1214
        RangeCompleteTimerTaskResponse struct {
1215
                TasksCompleted int
1216
        }
1217

1218
        // CompleteTimerTaskRequest is used to complete a task in the timer task queue
1219
        CompleteTimerTaskRequest struct {
1220
                VisibilityTimestamp time.Time
1221
                TaskID              int64
1222
        }
1223

1224
        // LeaseTaskListRequest is used to request lease of a task list
1225
        LeaseTaskListRequest struct {
1226
                DomainID     string
1227
                DomainName   string
1228
                TaskList     string
1229
                TaskType     int
1230
                TaskListKind int
1231
                RangeID      int64
1232
        }
1233

1234
        // LeaseTaskListResponse is response to LeaseTaskListRequest
1235
        LeaseTaskListResponse struct {
1236
                TaskListInfo *TaskListInfo
1237
        }
1238

1239
        // UpdateTaskListRequest is used to update task list implementation information
1240
        UpdateTaskListRequest struct {
1241
                TaskListInfo *TaskListInfo
1242
                DomainName   string
1243
        }
1244

1245
        // UpdateTaskListResponse is the response to UpdateTaskList
1246
        UpdateTaskListResponse struct {
1247
        }
1248

1249
        // ListTaskListRequest contains the request params needed to invoke ListTaskList API
1250
        ListTaskListRequest struct {
1251
                PageSize  int
1252
                PageToken []byte
1253
        }
1254

1255
        // ListTaskListResponse is the response from ListTaskList API
1256
        ListTaskListResponse struct {
1257
                Items         []TaskListInfo
1258
                NextPageToken []byte
1259
        }
1260

1261
        // DeleteTaskListRequest contains the request params needed to invoke DeleteTaskList API
1262
        DeleteTaskListRequest struct {
1263
                DomainID     string
1264
                DomainName   string
1265
                TaskListName string
1266
                TaskListType int
1267
                RangeID      int64
1268
        }
1269

1270
        // CreateTasksRequest is used to create a new task for a workflow exectution
1271
        CreateTasksRequest struct {
1272
                TaskListInfo *TaskListInfo
1273
                Tasks        []*CreateTaskInfo
1274
                DomainName   string
1275
        }
1276

1277
        // CreateTaskInfo describes a task to be created in CreateTasksRequest
1278
        CreateTaskInfo struct {
1279
                Execution types.WorkflowExecution
1280
                Data      *TaskInfo
1281
                TaskID    int64
1282
        }
1283

1284
        // CreateTasksResponse is the response to CreateTasksRequest
1285
        CreateTasksResponse struct {
1286
        }
1287

1288
        // GetTasksRequest is used to retrieve tasks of a task list
1289
        GetTasksRequest struct {
1290
                DomainID     string
1291
                TaskList     string
1292
                TaskType     int
1293
                ReadLevel    int64  // range exclusive
1294
                MaxReadLevel *int64 // optional: range inclusive when specified
1295
                BatchSize    int
1296
                DomainName   string
1297
        }
1298

1299
        // GetTasksResponse is the response to GetTasksRequests
1300
        GetTasksResponse struct {
1301
                Tasks []*TaskInfo
1302
        }
1303

1304
        // CompleteTaskRequest is used to complete a task
1305
        CompleteTaskRequest struct {
1306
                TaskList   *TaskListInfo
1307
                TaskID     int64
1308
                DomainName string
1309
        }
1310

1311
        // CompleteTasksLessThanRequest contains the request params needed to invoke CompleteTasksLessThan API
1312
        CompleteTasksLessThanRequest struct {
1313
                DomainID     string
1314
                TaskListName string
1315
                TaskType     int
1316
                TaskID       int64 // Tasks less than or equal to this ID will be completed
1317
                Limit        int   // Limit on the max number of tasks that can be completed. Required param
1318
                DomainName   string
1319
        }
1320

1321
        // CompleteTasksLessThanResponse is the response of CompleteTasksLessThan
1322
        CompleteTasksLessThanResponse struct {
1323
                TasksCompleted int
1324
        }
1325

1326
        // GetOrphanTasksRequest contains the request params need to invoke the GetOrphanTasks API
1327
        GetOrphanTasksRequest struct {
1328
                Limit int
1329
        }
1330

1331
        // GetOrphanTasksResponse is the response to GetOrphanTasksRequests
1332
        GetOrphanTasksResponse struct {
1333
                Tasks []*TaskKey
1334
        }
1335

1336
        // GetTimerIndexTasksRequest is the request for GetTimerIndexTasks
1337
        // TODO: replace this with an iterator that can configure min and max index.
1338
        GetTimerIndexTasksRequest struct {
1339
                MinTimestamp  time.Time
1340
                MaxTimestamp  time.Time
1341
                BatchSize     int
1342
                NextPageToken []byte
1343
        }
1344

1345
        // GetTimerIndexTasksResponse is the response for GetTimerIndexTasks
1346
        GetTimerIndexTasksResponse struct {
1347
                Timers        []*TimerTaskInfo
1348
                NextPageToken []byte
1349
        }
1350

1351
        // DomainInfo describes the domain entity
1352
        DomainInfo struct {
1353
                ID          string
1354
                Name        string
1355
                Status      int
1356
                Description string
1357
                OwnerEmail  string
1358
                Data        map[string]string
1359
        }
1360

1361
        // DomainConfig describes the domain configuration
1362
        DomainConfig struct {
1363
                // NOTE: this retention is in days, not in seconds
1364
                Retention                int32
1365
                EmitMetric               bool
1366
                HistoryArchivalStatus    types.ArchivalStatus
1367
                HistoryArchivalURI       string
1368
                VisibilityArchivalStatus types.ArchivalStatus
1369
                VisibilityArchivalURI    string
1370
                BadBinaries              types.BadBinaries
1371
        }
1372

1373
        // DomainReplicationConfig describes the cross DC domain replication configuration
1374
        DomainReplicationConfig struct {
1375
                ActiveClusterName string
1376
                Clusters          []*ClusterReplicationConfig
1377
        }
1378

1379
        // ClusterReplicationConfig describes the cross DC cluster replication configuration
1380
        ClusterReplicationConfig struct {
1381
                ClusterName string
1382
                // Note: if adding new properties of non-primitive types, remember to update GetCopy()
1383
        }
1384

1385
        // CreateDomainRequest is used to create the domain
1386
        CreateDomainRequest struct {
1387
                Info              *DomainInfo
1388
                Config            *DomainConfig
1389
                ReplicationConfig *DomainReplicationConfig
1390
                IsGlobalDomain    bool
1391
                ConfigVersion     int64
1392
                FailoverVersion   int64
1393
                LastUpdatedTime   int64
1394
        }
1395

1396
        // CreateDomainResponse is the response for CreateDomain
1397
        CreateDomainResponse struct {
1398
                ID string
1399
        }
1400

1401
        // GetDomainRequest is used to read domain
1402
        GetDomainRequest struct {
1403
                ID   string
1404
                Name string
1405
        }
1406

1407
        // GetDomainResponse is the response for GetDomain
1408
        GetDomainResponse struct {
1409
                Info                        *DomainInfo
1410
                Config                      *DomainConfig
1411
                ReplicationConfig           *DomainReplicationConfig
1412
                IsGlobalDomain              bool
1413
                ConfigVersion               int64
1414
                FailoverVersion             int64
1415
                FailoverNotificationVersion int64
1416
                PreviousFailoverVersion     int64
1417
                FailoverEndTime             *int64
1418
                LastUpdatedTime             int64
1419
                NotificationVersion         int64
1420
        }
1421

1422
        // UpdateDomainRequest is used to update domain
1423
        UpdateDomainRequest struct {
1424
                Info                        *DomainInfo
1425
                Config                      *DomainConfig
1426
                ReplicationConfig           *DomainReplicationConfig
1427
                ConfigVersion               int64
1428
                FailoverVersion             int64
1429
                FailoverNotificationVersion int64
1430
                PreviousFailoverVersion     int64
1431
                FailoverEndTime             *int64
1432
                LastUpdatedTime             int64
1433
                NotificationVersion         int64
1434
        }
1435

1436
        // DeleteDomainRequest is used to delete domain entry from domains table
1437
        DeleteDomainRequest struct {
1438
                ID string
1439
        }
1440

1441
        // DeleteDomainByNameRequest is used to delete domain entry from domains_by_name table
1442
        DeleteDomainByNameRequest struct {
1443
                Name string
1444
        }
1445

1446
        // ListDomainsRequest is used to list domains
1447
        ListDomainsRequest struct {
1448
                PageSize      int
1449
                NextPageToken []byte
1450
        }
1451

1452
        // ListDomainsResponse is the response for GetDomain
1453
        ListDomainsResponse struct {
1454
                Domains       []*GetDomainResponse
1455
                NextPageToken []byte
1456
        }
1457

1458
        // GetMetadataResponse is the response for GetMetadata
1459
        GetMetadataResponse struct {
1460
                NotificationVersion int64
1461
        }
1462

1463
        // MutableStateStats is the size stats for MutableState
1464
        MutableStateStats struct {
1465
                // Total size of mutable state
1466
                MutableStateSize int
1467

1468
                // Breakdown of size into more granular stats
1469
                ExecutionInfoSize  int
1470
                ActivityInfoSize   int
1471
                TimerInfoSize      int
1472
                ChildInfoSize      int
1473
                SignalInfoSize     int
1474
                BufferedEventsSize int
1475

1476
                // Item count for various information captured within mutable state
1477
                ActivityInfoCount      int
1478
                TimerInfoCount         int
1479
                ChildInfoCount         int
1480
                SignalInfoCount        int
1481
                RequestCancelInfoCount int
1482
                BufferedEventsCount    int
1483
        }
1484

1485
        // MutableStateUpdateSessionStats is size stats for mutableState updating session
1486
        MutableStateUpdateSessionStats struct {
1487
                MutableStateSize int // Total size of mutable state update
1488

1489
                // Breakdown of mutable state size update for more granular stats
1490
                ExecutionInfoSize  int
1491
                ActivityInfoSize   int
1492
                TimerInfoSize      int
1493
                ChildInfoSize      int
1494
                SignalInfoSize     int
1495
                BufferedEventsSize int
1496

1497
                // Item counts in this session update
1498
                ActivityInfoCount      int
1499
                TimerInfoCount         int
1500
                ChildInfoCount         int
1501
                SignalInfoCount        int
1502
                RequestCancelInfoCount int
1503

1504
                // Deleted item counts in this session update
1505
                DeleteActivityInfoCount      int
1506
                DeleteTimerInfoCount         int
1507
                DeleteChildInfoCount         int
1508
                DeleteSignalInfoCount        int
1509
                DeleteRequestCancelInfoCount int
1510

1511
                TransferTasksCount    int
1512
                CrossClusterTaskCount int
1513
                TimerTasksCount       int
1514
                ReplicationTasksCount int
1515
        }
1516

1517
        // UpdateWorkflowExecutionResponse is response for UpdateWorkflowExecutionRequest
1518
        UpdateWorkflowExecutionResponse struct {
1519
                MutableStateUpdateSessionStats *MutableStateUpdateSessionStats
1520
        }
1521

1522
        // ConflictResolveWorkflowExecutionResponse is response for ConflictResolveWorkflowExecutionRequest
1523
        ConflictResolveWorkflowExecutionResponse struct {
1524
                MutableStateUpdateSessionStats *MutableStateUpdateSessionStats
1525
        }
1526

1527
        // AppendHistoryNodesRequest is used to append a batch of history nodes
1528
        AppendHistoryNodesRequest struct {
1529
                // true if this is the first append request to the branch
1530
                IsNewBranch bool
1531
                // the info for clean up data in background
1532
                Info string
1533
                // The branch to be appended
1534
                BranchToken []byte
1535
                // The batch of events to be appended. The first eventID will become the nodeID of this batch
1536
                Events []*types.HistoryEvent
1537
                // requested TransactionID for this write operation. For the same eventID, the node with larger TransactionID always wins
1538
                TransactionID int64
1539
                // optional binary encoding type
1540
                Encoding common.EncodingType
1541
                // The shard to get history node data
1542
                ShardID *int
1543

1544
                //DomainName to get metrics created with the domain
1545
                DomainName string
1546
        }
1547

1548
        // AppendHistoryNodesResponse is a response to AppendHistoryNodesRequest
1549
        AppendHistoryNodesResponse struct {
1550
                // The data blob that was persisted to database
1551
                DataBlob DataBlob
1552
        }
1553

1554
        // ReadHistoryBranchRequest is used to read a history branch
1555
        ReadHistoryBranchRequest struct {
1556
                // The branch to be read
1557
                BranchToken []byte
1558
                // Get the history nodes from MinEventID. Inclusive.
1559
                MinEventID int64
1560
                // Get the history nodes upto MaxEventID.  Exclusive.
1561
                MaxEventID int64
1562
                // Maximum number of batches of events per page. Not that number of events in a batch >=1, it is not number of events per page.
1563
                // However for a single page, it is also possible that the returned events is less than PageSize (event zero events) due to stale events.
1564
                PageSize int
1565
                // Token to continue reading next page of history append transactions.  Pass in empty slice for first page
1566
                NextPageToken []byte
1567
                // The shard to get history branch data
1568
                ShardID *int
1569

1570
                DomainName string
1571
        }
1572

1573
        // ReadHistoryBranchResponse is the response to ReadHistoryBranchRequest
1574
        ReadHistoryBranchResponse struct {
1575
                // History events
1576
                HistoryEvents []*types.HistoryEvent
1577
                // Token to read next page if there are more events beyond page size.
1578
                // Use this to set NextPageToken on ReadHistoryBranchRequest to read the next page.
1579
                // Empty means we have reached the last page, not need to continue
1580
                NextPageToken []byte
1581
                // Size of history read from store
1582
                Size int
1583
                // the first_event_id of last loaded batch
1584
                LastFirstEventID int64
1585
        }
1586

1587
        // ReadHistoryBranchByBatchResponse is the response to ReadHistoryBranchRequest
1588
        ReadHistoryBranchByBatchResponse struct {
1589
                // History events by batch
1590
                History []*types.History
1591
                // Token to read next page if there are more events beyond page size.
1592
                // Use this to set NextPageToken on ReadHistoryBranchRequest to read the next page.
1593
                // Empty means we have reached the last page, not need to continue
1594
                NextPageToken []byte
1595
                // Size of history read from store
1596
                Size int
1597
                // the first_event_id of last loaded batch
1598
                LastFirstEventID int64
1599
        }
1600

1601
        // ReadRawHistoryBranchResponse is the response to ReadHistoryBranchRequest
1602
        ReadRawHistoryBranchResponse struct {
1603
                // HistoryEventBlobs history event blobs
1604
                HistoryEventBlobs []*DataBlob
1605
                // Token to read next page if there are more events beyond page size.
1606
                // Use this to set NextPageToken on ReadHistoryBranchRequest to read the next page.
1607
                // Empty means we have reached the last page, not need to continue
1608
                NextPageToken []byte
1609
                // Size of history read from store
1610
                Size int
1611
        }
1612

1613
        // ForkHistoryBranchRequest is used to fork a history branch
1614
        ForkHistoryBranchRequest struct {
1615
                // The base branch to fork from
1616
                ForkBranchToken []byte
1617
                // The nodeID to fork from, the new branch will start from ( inclusive ), the base branch will stop at(exclusive)
1618
                // Application must provide a void forking nodeID, it must be a valid nodeID in that branch. A valid nodeID is the firstEventID of a valid batch of events.
1619
                // And ForkNodeID > 1 because forking from 1 doesn't make any sense.
1620
                ForkNodeID int64
1621
                // the info for clean up data in background
1622
                Info string
1623
                // The shard to get history branch data
1624
                ShardID *int
1625
                //DomainName to create metrics for Domain Cost Attribution
1626
                DomainName string
1627
        }
1628

1629
        // ForkHistoryBranchResponse is the response to ForkHistoryBranchRequest
1630
        ForkHistoryBranchResponse struct {
1631
                // branchToken to represent the new branch
1632
                NewBranchToken []byte
1633
        }
1634

1635
        // CompleteForkBranchRequest is used to complete forking
1636
        CompleteForkBranchRequest struct {
1637
                // the new branch returned from ForkHistoryBranchRequest
1638
                BranchToken []byte
1639
                // true means the fork is success, will update the flag, otherwise will delete the new branch
1640
                Success bool
1641
                // The shard to update history branch data
1642
                ShardID *int
1643
        }
1644

1645
        // DeleteHistoryBranchRequest is used to remove a history branch
1646
        DeleteHistoryBranchRequest struct {
1647
                // branch to be deleted
1648
                BranchToken []byte
1649
                // The shard to delete history branch data
1650
                ShardID *int
1651
                //DomainName to generate metrics for Domain Cost Attribution
1652
                DomainName string
1653
        }
1654

1655
        // GetHistoryTreeRequest is used to retrieve branch info of a history tree
1656
        GetHistoryTreeRequest struct {
1657
                // A UUID of a tree
1658
                TreeID string
1659
                // Get data from this shard
1660
                ShardID *int
1661
                // optional: can provide treeID via branchToken if treeID is empty
1662
                BranchToken []byte
1663
                //DomainName to create metrics
1664
                DomainName string
1665
        }
1666

1667
        // HistoryBranchDetail contains detailed information of a branch
1668
        HistoryBranchDetail struct {
1669
                TreeID   string
1670
                BranchID string
1671
                ForkTime time.Time
1672
                Info     string
1673
        }
1674

1675
        // GetHistoryTreeResponse is a response to GetHistoryTreeRequest
1676
        GetHistoryTreeResponse struct {
1677
                // all branches of a tree
1678
                Branches []*workflow.HistoryBranch
1679
        }
1680

1681
        // GetAllHistoryTreeBranchesRequest is a request of GetAllHistoryTreeBranches
1682
        GetAllHistoryTreeBranchesRequest struct {
1683
                // pagination token
1684
                NextPageToken []byte
1685
                // maximum number of branches returned per page
1686
                PageSize int
1687
        }
1688

1689
        // GetAllHistoryTreeBranchesResponse is a response to GetAllHistoryTreeBranches
1690
        GetAllHistoryTreeBranchesResponse struct {
1691
                // pagination token
1692
                NextPageToken []byte
1693
                // all branches of all trees
1694
                Branches []HistoryBranchDetail
1695
        }
1696

1697
        // CreateFailoverMarkersRequest is request to create failover markers
1698
        CreateFailoverMarkersRequest struct {
1699
                RangeID int64
1700
                Markers []*FailoverMarkerTask
1701
        }
1702

1703
        // FetchDynamicConfigResponse is a response to FetchDynamicConfigResponse
1704
        FetchDynamicConfigResponse struct {
1705
                Snapshot *DynamicConfigSnapshot
1706
        }
1707

1708
        // UpdateDynamicConfigRequest is a request to update dynamic config with snapshot
1709
        UpdateDynamicConfigRequest struct {
1710
                Snapshot *DynamicConfigSnapshot
1711
        }
1712

1713
        DynamicConfigSnapshot struct {
1714
                Version int64
1715
                Values  *types.DynamicConfigBlob
1716
        }
1717

1718
        // Closeable is an interface for any entity that supports a close operation to release resources
1719
        Closeable interface {
1720
                Close()
1721
        }
1722

1723
        // ShardManager is used to manage all shards
1724
        ShardManager interface {
1725
                Closeable
1726
                GetName() string
1727
                CreateShard(ctx context.Context, request *CreateShardRequest) error
1728
                GetShard(ctx context.Context, request *GetShardRequest) (*GetShardResponse, error)
1729
                UpdateShard(ctx context.Context, request *UpdateShardRequest) error
1730
        }
1731

1732
        // ExecutionManager is used to manage workflow executions
1733
        ExecutionManager interface {
1734
                Closeable
1735
                GetName() string
1736
                GetShardID() int
1737

1738
                CreateWorkflowExecution(ctx context.Context, request *CreateWorkflowExecutionRequest) (*CreateWorkflowExecutionResponse, error)
1739
                GetWorkflowExecution(ctx context.Context, request *GetWorkflowExecutionRequest) (*GetWorkflowExecutionResponse, error)
1740
                UpdateWorkflowExecution(ctx context.Context, request *UpdateWorkflowExecutionRequest) (*UpdateWorkflowExecutionResponse, error)
1741
                ConflictResolveWorkflowExecution(ctx context.Context, request *ConflictResolveWorkflowExecutionRequest) (*ConflictResolveWorkflowExecutionResponse, error)
1742
                DeleteWorkflowExecution(ctx context.Context, request *DeleteWorkflowExecutionRequest) error
1743
                DeleteCurrentWorkflowExecution(ctx context.Context, request *DeleteCurrentWorkflowExecutionRequest) error
1744
                GetCurrentExecution(ctx context.Context, request *GetCurrentExecutionRequest) (*GetCurrentExecutionResponse, error)
1745
                IsWorkflowExecutionExists(ctx context.Context, request *IsWorkflowExecutionExistsRequest) (*IsWorkflowExecutionExistsResponse, error)
1746

1747
                // Transfer task related methods
1748
                GetTransferTasks(ctx context.Context, request *GetTransferTasksRequest) (*GetTransferTasksResponse, error)
1749
                CompleteTransferTask(ctx context.Context, request *CompleteTransferTaskRequest) error
1750
                RangeCompleteTransferTask(ctx context.Context, request *RangeCompleteTransferTaskRequest) (*RangeCompleteTransferTaskResponse, error)
1751

1752
                // Cross-cluster related methods
1753
                GetCrossClusterTasks(ctx context.Context, request *GetCrossClusterTasksRequest) (*GetCrossClusterTasksResponse, error)
1754
                CompleteCrossClusterTask(ctx context.Context, request *CompleteCrossClusterTaskRequest) error
1755
                RangeCompleteCrossClusterTask(ctx context.Context, request *RangeCompleteCrossClusterTaskRequest) (*RangeCompleteCrossClusterTaskResponse, error)
1756

1757
                // Replication task related methods
1758
                GetReplicationTasks(ctx context.Context, request *GetReplicationTasksRequest) (*GetReplicationTasksResponse, error)
1759
                CompleteReplicationTask(ctx context.Context, request *CompleteReplicationTaskRequest) error
1760
                RangeCompleteReplicationTask(ctx context.Context, request *RangeCompleteReplicationTaskRequest) (*RangeCompleteReplicationTaskResponse, error)
1761
                PutReplicationTaskToDLQ(ctx context.Context, request *PutReplicationTaskToDLQRequest) error
1762
                GetReplicationTasksFromDLQ(ctx context.Context, request *GetReplicationTasksFromDLQRequest) (*GetReplicationTasksFromDLQResponse, error)
1763
                GetReplicationDLQSize(ctx context.Context, request *GetReplicationDLQSizeRequest) (*GetReplicationDLQSizeResponse, error)
1764
                DeleteReplicationTaskFromDLQ(ctx context.Context, request *DeleteReplicationTaskFromDLQRequest) error
1765
                RangeDeleteReplicationTaskFromDLQ(ctx context.Context, request *RangeDeleteReplicationTaskFromDLQRequest) (*RangeDeleteReplicationTaskFromDLQResponse, error)
1766
                CreateFailoverMarkerTasks(ctx context.Context, request *CreateFailoverMarkersRequest) error
1767

1768
                // Timer related methods.
1769
                GetTimerIndexTasks(ctx context.Context, request *GetTimerIndexTasksRequest) (*GetTimerIndexTasksResponse, error)
1770
                CompleteTimerTask(ctx context.Context, request *CompleteTimerTaskRequest) error
1771
                RangeCompleteTimerTask(ctx context.Context, request *RangeCompleteTimerTaskRequest) (*RangeCompleteTimerTaskResponse, error)
1772

1773
                // Scan operations
1774
                ListConcreteExecutions(ctx context.Context, request *ListConcreteExecutionsRequest) (*ListConcreteExecutionsResponse, error)
1775
                ListCurrentExecutions(ctx context.Context, request *ListCurrentExecutionsRequest) (*ListCurrentExecutionsResponse, error)
1776
        }
1777

1778
        // ExecutionManagerFactory creates an instance of ExecutionManager for a given shard
1779
        ExecutionManagerFactory interface {
1780
                Closeable
1781
                NewExecutionManager(shardID int) (ExecutionManager, error)
1782
        }
1783

1784
        // TaskManager is used to manage tasks
1785
        TaskManager interface {
1786
                Closeable
1787
                GetName() string
1788
                LeaseTaskList(ctx context.Context, request *LeaseTaskListRequest) (*LeaseTaskListResponse, error)
1789
                UpdateTaskList(ctx context.Context, request *UpdateTaskListRequest) (*UpdateTaskListResponse, error)
1790
                ListTaskList(ctx context.Context, request *ListTaskListRequest) (*ListTaskListResponse, error)
1791
                DeleteTaskList(ctx context.Context, request *DeleteTaskListRequest) error
1792
                CreateTasks(ctx context.Context, request *CreateTasksRequest) (*CreateTasksResponse, error)
1793
                GetTasks(ctx context.Context, request *GetTasksRequest) (*GetTasksResponse, error)
1794
                CompleteTask(ctx context.Context, request *CompleteTaskRequest) error
1795
                CompleteTasksLessThan(ctx context.Context, request *CompleteTasksLessThanRequest) (*CompleteTasksLessThanResponse, error)
1796
                GetOrphanTasks(ctx context.Context, request *GetOrphanTasksRequest) (*GetOrphanTasksResponse, error)
1797
        }
1798

1799
        // HistoryManager is used to manager workflow history events
1800
        HistoryManager interface {
1801
                Closeable
1802
                GetName() string
1803

1804
                // The below are history V2 APIs
1805
                // V2 regards history events growing as a tree, decoupled from workflow concepts
1806
                // For Cadence, treeID is new runID, except for fork(reset), treeID will be the runID that it forks from.
1807

1808
                // AppendHistoryNodes add(or override) a batch of nodes to a history branch
1809
                AppendHistoryNodes(ctx context.Context, request *AppendHistoryNodesRequest) (*AppendHistoryNodesResponse, error)
1810
                // ReadHistoryBranch returns history node data for a branch
1811
                ReadHistoryBranch(ctx context.Context, request *ReadHistoryBranchRequest) (*ReadHistoryBranchResponse, error)
1812
                // ReadHistoryBranchByBatch returns history node data for a branch ByBatch
1813
                ReadHistoryBranchByBatch(ctx context.Context, request *ReadHistoryBranchRequest) (*ReadHistoryBranchByBatchResponse, error)
1814
                // ReadRawHistoryBranch returns history node raw data for a branch ByBatch
1815
                // NOTE: this API should only be used by 3+DC
1816
                ReadRawHistoryBranch(ctx context.Context, request *ReadHistoryBranchRequest) (*ReadRawHistoryBranchResponse, error)
1817
                // ForkHistoryBranch forks a new branch from a old branch
1818
                ForkHistoryBranch(ctx context.Context, request *ForkHistoryBranchRequest) (*ForkHistoryBranchResponse, error)
1819
                // DeleteHistoryBranch removes a branch
1820
                // If this is the last branch to delete, it will also remove the root node
1821
                DeleteHistoryBranch(ctx context.Context, request *DeleteHistoryBranchRequest) error
1822
                // GetHistoryTree returns all branch information of a tree
1823
                GetHistoryTree(ctx context.Context, request *GetHistoryTreeRequest) (*GetHistoryTreeResponse, error)
1824
                // GetAllHistoryTreeBranches returns all branches of all trees
1825
                GetAllHistoryTreeBranches(ctx context.Context, request *GetAllHistoryTreeBranchesRequest) (*GetAllHistoryTreeBranchesResponse, error)
1826
        }
1827

1828
        // DomainManager is used to manage metadata CRUD for domain entities
1829
        DomainManager interface {
1830
                Closeable
1831
                GetName() string
1832
                CreateDomain(ctx context.Context, request *CreateDomainRequest) (*CreateDomainResponse, error)
1833
                GetDomain(ctx context.Context, request *GetDomainRequest) (*GetDomainResponse, error)
1834
                UpdateDomain(ctx context.Context, request *UpdateDomainRequest) error
1835
                DeleteDomain(ctx context.Context, request *DeleteDomainRequest) error
1836
                DeleteDomainByName(ctx context.Context, request *DeleteDomainByNameRequest) error
1837
                ListDomains(ctx context.Context, request *ListDomainsRequest) (*ListDomainsResponse, error)
1838
                GetMetadata(ctx context.Context) (*GetMetadataResponse, error)
1839
        }
1840

1841
        // QueueManager is used to manage queue store
1842
        QueueManager interface {
1843
                Closeable
1844
                EnqueueMessage(ctx context.Context, messagePayload []byte) error
1845
                ReadMessages(ctx context.Context, lastMessageID int64, maxCount int) ([]*QueueMessage, error)
1846
                DeleteMessagesBefore(ctx context.Context, messageID int64) error
1847
                UpdateAckLevel(ctx context.Context, messageID int64, clusterName string) error
1848
                GetAckLevels(ctx context.Context) (map[string]int64, error)
1849
                EnqueueMessageToDLQ(ctx context.Context, messagePayload []byte) error
1850
                ReadMessagesFromDLQ(ctx context.Context, firstMessageID int64, lastMessageID int64, pageSize int, pageToken []byte) ([]*QueueMessage, []byte, error)
1851
                DeleteMessageFromDLQ(ctx context.Context, messageID int64) error
1852
                RangeDeleteMessagesFromDLQ(ctx context.Context, firstMessageID int64, lastMessageID int64) error
1853
                UpdateDLQAckLevel(ctx context.Context, messageID int64, clusterName string) error
1854
                GetDLQAckLevels(ctx context.Context) (map[string]int64, error)
1855
                GetDLQSize(ctx context.Context) (int64, error)
1856
        }
1857

1858
        // QueueMessage is the message that stores in the queue
1859
        QueueMessage struct {
1860
                ID        int64     `json:"message_id"`
1861
                QueueType QueueType `json:"queue_type"`
1862
                Payload   []byte    `json:"message_payload"`
1863
        }
1864

1865
        ConfigStoreManager interface {
1866
                Closeable
1867
                FetchDynamicConfig(ctx context.Context) (*FetchDynamicConfigResponse, error)
1868
                UpdateDynamicConfig(ctx context.Context, request *UpdateDynamicConfigRequest) error
1869
                //can add functions for config types other than dynamic config
1870
        }
1871
)
1872

1873
func (e *InvalidPersistenceRequestError) Error() string {
×
1874
        return e.Msg
×
1875
}
×
1876

1877
func (e *CurrentWorkflowConditionFailedError) Error() string {
×
1878
        return e.Msg
×
1879
}
×
1880

1881
func (e *ConditionFailedError) Error() string {
×
1882
        return e.Msg
×
1883
}
×
1884

1885
func (e *ShardAlreadyExistError) Error() string {
×
1886
        return e.Msg
×
1887
}
×
1888

1889
func (e *ShardOwnershipLostError) Error() string {
×
1890
        return e.Msg
×
1891
}
×
1892

1893
func (e *WorkflowExecutionAlreadyStartedError) Error() string {
×
1894
        return e.Msg
×
1895
}
×
1896

1897
func (e *TimeoutError) Error() string {
×
1898
        return e.Msg
×
1899
}
×
1900

1901
func (e *DBUnavailableError) Error() string {
×
1902
        return e.Msg
×
1903
}
×
1904

1905
func (e *TransactionSizeLimitError) Error() string {
×
1906
        return e.Msg
×
1907
}
×
1908

1909
// IsTimeoutError check whether error is TimeoutError
1910
func IsTimeoutError(err error) bool {
×
1911
        _, ok := err.(*TimeoutError)
×
1912
        return ok
×
1913
}
×
1914

1915
// GetType returns the type of the activity task
1916
func (a *ActivityTask) GetType() int {
801✔
1917
        return TransferTaskTypeActivityTask
801✔
1918
}
801✔
1919

1920
// GetVersion returns the version of the activity task
1921
func (a *ActivityTask) GetVersion() int64 {
738✔
1922
        return a.Version
738✔
1923
}
738✔
1924

1925
// SetVersion returns the version of the activity task
1926
func (a *ActivityTask) SetVersion(version int64) {
×
1927
        a.Version = version
×
1928
}
×
1929

1930
// GetTaskID returns the sequence ID of the activity task
1931
func (a *ActivityTask) GetTaskID() int64 {
402✔
1932
        return a.TaskID
402✔
1933
}
402✔
1934

1935
// SetTaskID sets the sequence ID of the activity task
1936
func (a *ActivityTask) SetTaskID(id int64) {
402✔
1937
        a.TaskID = id
402✔
1938
}
402✔
1939

1940
// GetVisibilityTimestamp get the visibility timestamp
1941
func (a *ActivityTask) GetVisibilityTimestamp() time.Time {
801✔
1942
        return a.VisibilityTimestamp
801✔
1943
}
801✔
1944

1945
// SetVisibilityTimestamp set the visibility timestamp
1946
func (a *ActivityTask) SetVisibilityTimestamp(timestamp time.Time) {
402✔
1947
        a.VisibilityTimestamp = timestamp
402✔
1948
}
402✔
1949

1950
// GetType returns the type of the decision task
1951
func (d *DecisionTask) GetType() int {
2,691✔
1952
        return TransferTaskTypeDecisionTask
2,691✔
1953
}
2,691✔
1954

1955
// GetVersion returns the version of the decision task
1956
func (d *DecisionTask) GetVersion() int64 {
2,119✔
1957
        return d.Version
2,119✔
1958
}
2,119✔
1959

1960
// SetVersion returns the version of the decision task
1961
func (d *DecisionTask) SetVersion(version int64) {
×
1962
        d.Version = version
×
1963
}
×
1964

1965
// GetTaskID returns the sequence ID of the decision task.
1966
func (d *DecisionTask) GetTaskID() int64 {
1,347✔
1967
        return d.TaskID
1,347✔
1968
}
1,347✔
1969

1970
// SetTaskID sets the sequence ID of the decision task
1971
func (d *DecisionTask) SetTaskID(id int64) {
1,375✔
1972
        d.TaskID = id
1,375✔
1973
}
1,375✔
1974

1975
// GetVisibilityTimestamp get the visibility timestamp
1976
func (d *DecisionTask) GetVisibilityTimestamp() time.Time {
2,719✔
1977
        return d.VisibilityTimestamp
2,719✔
1978
}
2,719✔
1979

1980
// SetVisibilityTimestamp set the visibility timestamp
1981
func (d *DecisionTask) SetVisibilityTimestamp(timestamp time.Time) {
1,360✔
1982
        d.VisibilityTimestamp = timestamp
1,360✔
1983
}
1,360✔
1984

1985
// GetType returns the type of the record workflow started task
1986
func (a *RecordWorkflowStartedTask) GetType() int {
1,297✔
1987
        return TransferTaskTypeRecordWorkflowStarted
1,297✔
1988
}
1,297✔
1989

1990
// GetVersion returns the version of the record workflow started task
1991
func (a *RecordWorkflowStartedTask) GetVersion() int64 {
1,283✔
1992
        return a.Version
1,283✔
1993
}
1,283✔
1994

1995
// SetVersion returns the version of the record workflow started task
1996
func (a *RecordWorkflowStartedTask) SetVersion(version int64) {
×
1997
        a.Version = version
×
1998
}
×
1999

2000
// GetTaskID returns the sequence ID of the record workflow started task
2001
func (a *RecordWorkflowStartedTask) GetTaskID() int64 {
650✔
2002
        return a.TaskID
650✔
2003
}
650✔
2004

2005
// SetTaskID sets the sequence ID of the record workflow started task
2006
func (a *RecordWorkflowStartedTask) SetTaskID(id int64) {
678✔
2007
        a.TaskID = id
678✔
2008
}
678✔
2009

2010
// GetVisibilityTimestamp get the visibility timestamp
2011
func (a *RecordWorkflowStartedTask) GetVisibilityTimestamp() time.Time {
1,325✔
2012
        return a.VisibilityTimestamp
1,325✔
2013
}
1,325✔
2014

2015
// SetVisibilityTimestamp set the visibility timestamp
2016
func (a *RecordWorkflowStartedTask) SetVisibilityTimestamp(timestamp time.Time) {
663✔
2017
        a.VisibilityTimestamp = timestamp
663✔
2018
}
663✔
2019

2020
// GetType returns the type of the ResetWorkflowTask
2021
func (a *ResetWorkflowTask) GetType() int {
×
2022
        return TransferTaskTypeResetWorkflow
×
2023
}
×
2024

2025
// GetVersion returns the version of the ResetWorkflowTask
2026
func (a *ResetWorkflowTask) GetVersion() int64 {
×
2027
        return a.Version
×
2028
}
×
2029

2030
// SetVersion returns the version of the ResetWorkflowTask
2031
func (a *ResetWorkflowTask) SetVersion(version int64) {
×
2032
        a.Version = version
×
2033
}
×
2034

2035
// GetTaskID returns the sequence ID of the ResetWorkflowTask
2036
func (a *ResetWorkflowTask) GetTaskID() int64 {
×
2037
        return a.TaskID
×
2038
}
×
2039

2040
// SetTaskID sets the sequence ID of the ResetWorkflowTask
2041
func (a *ResetWorkflowTask) SetTaskID(id int64) {
×
2042
        a.TaskID = id
×
2043
}
×
2044

2045
// GetVisibilityTimestamp get the visibility timestamp
2046
func (a *ResetWorkflowTask) GetVisibilityTimestamp() time.Time {
×
2047
        return a.VisibilityTimestamp
×
2048
}
×
2049

2050
// SetVisibilityTimestamp set the visibility timestamp
2051
func (a *ResetWorkflowTask) SetVisibilityTimestamp(timestamp time.Time) {
×
2052
        a.VisibilityTimestamp = timestamp
×
2053
}
×
2054

2055
// GetType returns the type of the close execution task
2056
func (a *CloseExecutionTask) GetType() int {
1,001✔
2057
        return TransferTaskTypeCloseExecution
1,001✔
2058
}
1,001✔
2059

2060
// GetVersion returns the version of the close execution task
2061
func (a *CloseExecutionTask) GetVersion() int64 {
1,001✔
2062
        return a.Version
1,001✔
2063
}
1,001✔
2064

2065
// SetVersion returns the version of the close execution task
2066
func (a *CloseExecutionTask) SetVersion(version int64) {
×
2067
        a.Version = version
×
2068
}
×
2069

2070
// GetTaskID returns the sequence ID of the close execution task
2071
func (a *CloseExecutionTask) GetTaskID() int64 {
502✔
2072
        return a.TaskID
502✔
2073
}
502✔
2074

2075
// SetTaskID sets the sequence ID of the close execution task
2076
func (a *CloseExecutionTask) SetTaskID(id int64) {
502✔
2077
        a.TaskID = id
502✔
2078
}
502✔
2079

2080
// GetVisibilityTimestamp get the visibility timestamp
2081
func (a *CloseExecutionTask) GetVisibilityTimestamp() time.Time {
1,001✔
2082
        return a.VisibilityTimestamp
1,001✔
2083
}
1,001✔
2084

2085
// SetVisibilityTimestamp set the visibility timestamp
2086
func (a *CloseExecutionTask) SetVisibilityTimestamp(timestamp time.Time) {
502✔
2087
        a.VisibilityTimestamp = timestamp
502✔
2088
}
502✔
2089

2090
// GetType returns the type of the delete execution task
2091
func (a *DeleteHistoryEventTask) GetType() int {
1,001✔
2092
        return TaskTypeDeleteHistoryEvent
1,001✔
2093
}
1,001✔
2094

2095
// GetVersion returns the version of the delete execution task
2096
func (a *DeleteHistoryEventTask) GetVersion() int64 {
1,500✔
2097
        return a.Version
1,500✔
2098
}
1,500✔
2099

2100
// SetVersion returns the version of the delete execution task
2101
func (a *DeleteHistoryEventTask) SetVersion(version int64) {
×
2102
        a.Version = version
×
2103
}
×
2104

2105
// GetTaskID returns the sequence ID of the delete execution task
2106
func (a *DeleteHistoryEventTask) GetTaskID() int64 {
1,001✔
2107
        return a.TaskID
1,001✔
2108
}
1,001✔
2109

2110
// SetTaskID sets the sequence ID of the delete execution task
2111
func (a *DeleteHistoryEventTask) SetTaskID(id int64) {
502✔
2112
        a.TaskID = id
502✔
2113
}
502✔
2114

2115
// GetVisibilityTimestamp get the visibility timestamp
2116
func (a *DeleteHistoryEventTask) GetVisibilityTimestamp() time.Time {
2,498✔
2117
        return a.VisibilityTimestamp
2,498✔
2118
}
2,498✔
2119

2120
// SetVisibilityTimestamp set the visibility timestamp
2121
func (a *DeleteHistoryEventTask) SetVisibilityTimestamp(timestamp time.Time) {
51✔
2122
        a.VisibilityTimestamp = timestamp
51✔
2123
}
51✔
2124

2125
// GetType returns the type of the timer task
2126
func (d *DecisionTimeoutTask) GetType() int {
2,409✔
2127
        return TaskTypeDecisionTimeout
2,409✔
2128
}
2,409✔
2129

2130
// GetVersion returns the version of the timer task
2131
func (d *DecisionTimeoutTask) GetVersion() int64 {
3,603✔
2132
        return d.Version
3,603✔
2133
}
3,603✔
2134

2135
// SetVersion returns the version of the timer task
2136
func (d *DecisionTimeoutTask) SetVersion(version int64) {
×
2137
        d.Version = version
×
2138
}
×
2139

2140
// GetTaskID returns the sequence ID.
2141
func (d *DecisionTimeoutTask) GetTaskID() int64 {
2,409✔
2142
        return d.TaskID
2,409✔
2143
}
2,409✔
2144

2145
// SetTaskID sets the sequence ID.
2146
func (d *DecisionTimeoutTask) SetTaskID(id int64) {
1,206✔
2147
        d.TaskID = id
1,206✔
2148
}
1,206✔
2149

2150
// GetVisibilityTimestamp gets the visibility time stamp
2151
func (d *DecisionTimeoutTask) GetVisibilityTimestamp() time.Time {
6,009✔
2152
        return d.VisibilityTimestamp
6,009✔
2153
}
6,009✔
2154

2155
// SetVisibilityTimestamp gets the visibility time stamp
2156
func (d *DecisionTimeoutTask) SetVisibilityTimestamp(t time.Time) {
21✔
2157
        d.VisibilityTimestamp = t
21✔
2158
}
21✔
2159

2160
// GetType returns the type of the timer task
2161
func (a *ActivityTimeoutTask) GetType() int {
1,453✔
2162
        return TaskTypeActivityTimeout
1,453✔
2163
}
1,453✔
2164

2165
// GetVersion returns the version of the timer task
2166
func (a *ActivityTimeoutTask) GetVersion() int64 {
2,160✔
2167
        return a.Version
2,160✔
2168
}
2,160✔
2169

2170
// SetVersion returns the version of the timer task
2171
func (a *ActivityTimeoutTask) SetVersion(version int64) {
×
2172
        a.Version = version
×
2173
}
×
2174

2175
// GetTaskID returns the sequence ID.
2176
func (a *ActivityTimeoutTask) GetTaskID() int64 {
1,453✔
2177
        return a.TaskID
1,453✔
2178
}
1,453✔
2179

2180
// SetTaskID sets the sequence ID.
2181
func (a *ActivityTimeoutTask) SetTaskID(id int64) {
728✔
2182
        a.TaskID = id
728✔
2183
}
728✔
2184

2185
// GetVisibilityTimestamp gets the visibility time stamp
2186
func (a *ActivityTimeoutTask) GetVisibilityTimestamp() time.Time {
3,610✔
2187
        return a.VisibilityTimestamp
3,610✔
2188
}
3,610✔
2189

2190
// SetVisibilityTimestamp gets the visibility time stamp
2191
func (a *ActivityTimeoutTask) SetVisibilityTimestamp(t time.Time) {
11✔
2192
        a.VisibilityTimestamp = t
11✔
2193
}
11✔
2194

2195
// GetType returns the type of the timer task
2196
func (u *UserTimerTask) GetType() int {
63✔
2197
        return TaskTypeUserTimer
63✔
2198
}
63✔
2199

2200
// GetVersion returns the version of the timer task
2201
func (u *UserTimerTask) GetVersion() int64 {
90✔
2202
        return u.Version
90✔
2203
}
90✔
2204

2205
// SetVersion returns the version of the timer task
2206
func (u *UserTimerTask) SetVersion(version int64) {
×
2207
        u.Version = version
×
2208
}
×
2209

2210
// GetTaskID returns the sequence ID of the timer task.
2211
func (u *UserTimerTask) GetTaskID() int64 {
63✔
2212
        return u.TaskID
63✔
2213
}
63✔
2214

2215
// SetTaskID sets the sequence ID of the timer task.
2216
func (u *UserTimerTask) SetTaskID(id int64) {
33✔
2217
        u.TaskID = id
33✔
2218
}
33✔
2219

2220
// GetVisibilityTimestamp gets the visibility time stamp
2221
func (u *UserTimerTask) GetVisibilityTimestamp() time.Time {
150✔
2222
        return u.VisibilityTimestamp
150✔
2223
}
150✔
2224

2225
// SetVisibilityTimestamp gets the visibility time stamp
2226
func (u *UserTimerTask) SetVisibilityTimestamp(t time.Time) {
×
2227
        u.VisibilityTimestamp = t
×
2228
}
×
2229

2230
// GetType returns the type of the retry timer task
2231
func (r *ActivityRetryTimerTask) GetType() int {
18✔
2232
        return TaskTypeActivityRetryTimer
18✔
2233
}
18✔
2234

2235
// GetVersion returns the version of the retry timer task
2236
func (r *ActivityRetryTimerTask) GetVersion() int64 {
27✔
2237
        return r.Version
27✔
2238
}
27✔
2239

2240
// SetVersion returns the version of the retry timer task
2241
func (r *ActivityRetryTimerTask) SetVersion(version int64) {
×
2242
        r.Version = version
×
2243
}
×
2244

2245
// GetTaskID returns the sequence ID.
2246
func (r *ActivityRetryTimerTask) GetTaskID() int64 {
18✔
2247
        return r.TaskID
18✔
2248
}
18✔
2249

2250
// SetTaskID sets the sequence ID.
2251
func (r *ActivityRetryTimerTask) SetTaskID(id int64) {
9✔
2252
        r.TaskID = id
9✔
2253
}
9✔
2254

2255
// GetVisibilityTimestamp gets the visibility time stamp
2256
func (r *ActivityRetryTimerTask) GetVisibilityTimestamp() time.Time {
45✔
2257
        return r.VisibilityTimestamp
45✔
2258
}
45✔
2259

2260
// SetVisibilityTimestamp gets the visibility time stamp
2261
func (r *ActivityRetryTimerTask) SetVisibilityTimestamp(t time.Time) {
×
2262
        r.VisibilityTimestamp = t
×
2263
}
×
2264

2265
// GetType returns the type of the retry timer task
2266
func (r *WorkflowBackoffTimerTask) GetType() int {
141✔
2267
        return TaskTypeWorkflowBackoffTimer
141✔
2268
}
141✔
2269

2270
// GetVersion returns the version of the retry timer task
2271
func (r *WorkflowBackoffTimerTask) GetVersion() int64 {
144✔
2272
        return r.Version
144✔
2273
}
144✔
2274

2275
// SetVersion returns the version of the retry timer task
2276
func (r *WorkflowBackoffTimerTask) SetVersion(version int64) {
×
2277
        r.Version = version
×
2278
}
×
2279

2280
// GetTaskID returns the sequence ID.
2281
func (r *WorkflowBackoffTimerTask) GetTaskID() int64 {
141✔
2282
        return r.TaskID
141✔
2283
}
141✔
2284

2285
// SetTaskID sets the sequence ID.
2286
func (r *WorkflowBackoffTimerTask) SetTaskID(id int64) {
72✔
2287
        r.TaskID = id
72✔
2288
}
72✔
2289

2290
// GetVisibilityTimestamp gets the visibility time stamp
2291
func (r *WorkflowBackoffTimerTask) GetVisibilityTimestamp() time.Time {
282✔
2292
        return r.VisibilityTimestamp
282✔
2293
}
282✔
2294

2295
// SetVisibilityTimestamp gets the visibility time stamp
2296
func (r *WorkflowBackoffTimerTask) SetVisibilityTimestamp(t time.Time) {
3✔
2297
        r.VisibilityTimestamp = t
3✔
2298
}
3✔
2299

2300
// GetType returns the type of the timeout task.
2301
func (u *WorkflowTimeoutTask) GetType() int {
1,283✔
2302
        return TaskTypeWorkflowTimeout
1,283✔
2303
}
1,283✔
2304

2305
// GetVersion returns the version of the timeout task
2306
func (u *WorkflowTimeoutTask) GetVersion() int64 {
1,958✔
2307
        return u.Version
1,958✔
2308
}
1,958✔
2309

2310
// SetVersion returns the version of the timeout task
2311
func (u *WorkflowTimeoutTask) SetVersion(version int64) {
×
2312
        u.Version = version
×
2313
}
×
2314

2315
// GetTaskID returns the sequence ID of the cancel transfer task.
2316
func (u *WorkflowTimeoutTask) GetTaskID() int64 {
1,325✔
2317
        return u.TaskID
1,325✔
2318
}
1,325✔
2319

2320
// SetTaskID sets the sequence ID of the cancel transfer task.
2321
func (u *WorkflowTimeoutTask) SetTaskID(id int64) {
678✔
2322
        u.TaskID = id
678✔
2323
}
678✔
2324

2325
// GetVisibilityTimestamp gets the visibility time stamp
2326
func (u *WorkflowTimeoutTask) GetVisibilityTimestamp() time.Time {
3,266✔
2327
        return u.VisibilityTimestamp
3,266✔
2328
}
3,266✔
2329

2330
// SetVisibilityTimestamp gets the visibility time stamp
2331
func (u *WorkflowTimeoutTask) SetVisibilityTimestamp(t time.Time) {
3✔
2332
        u.VisibilityTimestamp = t
3✔
2333
}
3✔
2334

2335
// GetType returns the type of the cancel transfer task
2336
func (u *CancelExecutionTask) GetType() int {
15✔
2337
        return TransferTaskTypeCancelExecution
15✔
2338
}
15✔
2339

2340
// GetVersion returns the version of the cancel transfer task
2341
func (u *CancelExecutionTask) GetVersion() int64 {
15✔
2342
        return u.Version
15✔
2343
}
15✔
2344

2345
// SetVersion returns the version of the cancel transfer task
2346
func (u *CancelExecutionTask) SetVersion(version int64) {
×
2347
        u.Version = version
×
2348
}
×
2349

2350
// GetTaskID returns the sequence ID of the cancel transfer task.
2351
func (u *CancelExecutionTask) GetTaskID() int64 {
9✔
2352
        return u.TaskID
9✔
2353
}
9✔
2354

2355
// SetTaskID sets the sequence ID of the cancel transfer task.
2356
func (u *CancelExecutionTask) SetTaskID(id int64) {
9✔
2357
        u.TaskID = id
9✔
2358
}
9✔
2359

2360
// GetVisibilityTimestamp get the visibility timestamp
2361
func (u *CancelExecutionTask) GetVisibilityTimestamp() time.Time {
15✔
2362
        return u.VisibilityTimestamp
15✔
2363
}
15✔
2364

2365
// SetVisibilityTimestamp set the visibility timestamp
2366
func (u *CancelExecutionTask) SetVisibilityTimestamp(timestamp time.Time) {
9✔
2367
        u.VisibilityTimestamp = timestamp
9✔
2368
}
9✔
2369

2370
// GetType returns the type of the signal transfer task
2371
func (u *SignalExecutionTask) GetType() int {
27✔
2372
        return TransferTaskTypeSignalExecution
27✔
2373
}
27✔
2374

2375
// GetVersion returns the version of the signal transfer task
2376
func (u *SignalExecutionTask) GetVersion() int64 {
27✔
2377
        return u.Version
27✔
2378
}
27✔
2379

2380
// SetVersion returns the version of the signal transfer task
2381
func (u *SignalExecutionTask) SetVersion(version int64) {
×
2382
        u.Version = version
×
2383
}
×
2384

2385
// GetTaskID returns the sequence ID of the signal transfer task.
2386
func (u *SignalExecutionTask) GetTaskID() int64 {
15✔
2387
        return u.TaskID
15✔
2388
}
15✔
2389

2390
// SetTaskID sets the sequence ID of the signal transfer task.
2391
func (u *SignalExecutionTask) SetTaskID(id int64) {
15✔
2392
        u.TaskID = id
15✔
2393
}
15✔
2394

2395
// GetVisibilityTimestamp get the visibility timestamp
2396
func (u *SignalExecutionTask) GetVisibilityTimestamp() time.Time {
27✔
2397
        return u.VisibilityTimestamp
27✔
2398
}
27✔
2399

2400
// SetVisibilityTimestamp set the visibility timestamp
2401
func (u *SignalExecutionTask) SetVisibilityTimestamp(timestamp time.Time) {
15✔
2402
        u.VisibilityTimestamp = timestamp
15✔
2403
}
15✔
2404

2405
// GetType returns the type of the record child execution completed task
2406
func (u *RecordChildExecutionCompletedTask) GetType() int {
×
2407
        return TransferTaskTypeRecordChildExecutionCompleted
×
2408
}
×
2409

2410
// GetVersion returns the version of the signal transfer task
2411
func (u *RecordChildExecutionCompletedTask) GetVersion() int64 {
×
2412
        return u.Version
×
2413
}
×
2414

2415
// SetVersion returns the version of the signal transfer task
2416
func (u *RecordChildExecutionCompletedTask) SetVersion(version int64) {
×
2417
        u.Version = version
×
2418
}
×
2419

2420
// GetTaskID returns the sequence ID of the signal transfer task.
2421
func (u *RecordChildExecutionCompletedTask) GetTaskID() int64 {
×
2422
        return u.TaskID
×
2423
}
×
2424

2425
// SetTaskID sets the sequence ID of the signal transfer task.
2426
func (u *RecordChildExecutionCompletedTask) SetTaskID(id int64) {
×
2427
        u.TaskID = id
×
2428
}
×
2429

2430
// GetVisibilityTimestamp get the visibility timestamp
2431
func (u *RecordChildExecutionCompletedTask) GetVisibilityTimestamp() time.Time {
×
2432
        return u.VisibilityTimestamp
×
2433
}
×
2434

2435
// SetVisibilityTimestamp set the visibility timestamp
2436
func (u *RecordChildExecutionCompletedTask) SetVisibilityTimestamp(timestamp time.Time) {
×
2437
        u.VisibilityTimestamp = timestamp
×
2438
}
×
2439

2440
// GetType returns the type of the apply parent close policy task
2441
func (u *ApplyParentClosePolicyTask) GetType() int {
×
2442
        return TransferTaskTypeApplyParentClosePolicy
×
2443
}
×
2444

2445
// GetVersion returns the version of the cancel transfer task
2446
func (u *ApplyParentClosePolicyTask) GetVersion() int64 {
×
2447
        return u.Version
×
2448
}
×
2449

2450
// SetVersion returns the version of the cancel transfer task
2451
func (u *ApplyParentClosePolicyTask) SetVersion(version int64) {
×
2452
        u.Version = version
×
2453
}
×
2454

2455
// GetTaskID returns the sequence ID of the cancel transfer task.
2456
func (u *ApplyParentClosePolicyTask) GetTaskID() int64 {
×
2457
        return u.TaskID
×
2458
}
×
2459

2460
// SetTaskID sets the sequence ID of the cancel transfer task.
2461
func (u *ApplyParentClosePolicyTask) SetTaskID(id int64) {
×
2462
        u.TaskID = id
×
2463
}
×
2464

2465
// GetVisibilityTimestamp get the visibility timestamp
2466
func (u *ApplyParentClosePolicyTask) GetVisibilityTimestamp() time.Time {
×
2467
        return u.VisibilityTimestamp
×
2468
}
×
2469

2470
// SetVisibilityTimestamp set the visibility timestamp
2471
func (u *ApplyParentClosePolicyTask) SetVisibilityTimestamp(timestamp time.Time) {
×
2472
        u.VisibilityTimestamp = timestamp
×
2473
}
×
2474

2475
// GetType returns the type of the upsert search attributes transfer task
2476
func (u *UpsertWorkflowSearchAttributesTask) GetType() int {
18✔
2477
        return TransferTaskTypeUpsertWorkflowSearchAttributes
18✔
2478
}
18✔
2479

2480
// GetVersion returns the version of the upsert search attributes transfer task
2481
func (u *UpsertWorkflowSearchAttributesTask) GetVersion() int64 {
18✔
2482
        return u.Version
18✔
2483
}
18✔
2484

2485
// SetVersion returns the version of the upsert search attributes transfer task
2486
func (u *UpsertWorkflowSearchAttributesTask) SetVersion(version int64) {
×
2487
        u.Version = version
×
2488
}
×
2489

2490
// GetTaskID returns the sequence ID of the signal transfer task.
2491
func (u *UpsertWorkflowSearchAttributesTask) GetTaskID() int64 {
9✔
2492
        return u.TaskID
9✔
2493
}
9✔
2494

2495
// SetTaskID sets the sequence ID of the signal transfer task.
2496
func (u *UpsertWorkflowSearchAttributesTask) SetTaskID(id int64) {
9✔
2497
        u.TaskID = id
9✔
2498
}
9✔
2499

2500
// GetVisibilityTimestamp get the visibility timestamp
2501
func (u *UpsertWorkflowSearchAttributesTask) GetVisibilityTimestamp() time.Time {
18✔
2502
        return u.VisibilityTimestamp
18✔
2503
}
18✔
2504

2505
// SetVisibilityTimestamp set the visibility timestamp
2506
func (u *UpsertWorkflowSearchAttributesTask) SetVisibilityTimestamp(timestamp time.Time) {
9✔
2507
        u.VisibilityTimestamp = timestamp
9✔
2508
}
9✔
2509

2510
// GetType returns the type of the start child transfer task
2511
func (u *StartChildExecutionTask) GetType() int {
39✔
2512
        return TransferTaskTypeStartChildExecution
39✔
2513
}
39✔
2514

2515
// GetVersion returns the version of the start child transfer task
2516
func (u *StartChildExecutionTask) GetVersion() int64 {
36✔
2517
        return u.Version
36✔
2518
}
36✔
2519

2520
// SetVersion returns the version of the start child transfer task
2521
func (u *StartChildExecutionTask) SetVersion(version int64) {
×
2522
        u.Version = version
×
2523
}
×
2524

2525
// GetTaskID returns the sequence ID of the start child transfer task
2526
func (u *StartChildExecutionTask) GetTaskID() int64 {
21✔
2527
        return u.TaskID
21✔
2528
}
21✔
2529

2530
// SetTaskID sets the sequence ID of the start child transfer task
2531
func (u *StartChildExecutionTask) SetTaskID(id int64) {
21✔
2532
        u.TaskID = id
21✔
2533
}
21✔
2534

2535
// GetVisibilityTimestamp get the visibility timestamp
2536
func (u *StartChildExecutionTask) GetVisibilityTimestamp() time.Time {
39✔
2537
        return u.VisibilityTimestamp
39✔
2538
}
39✔
2539

2540
// SetVisibilityTimestamp set the visibility timestamp
2541
func (u *StartChildExecutionTask) SetVisibilityTimestamp(timestamp time.Time) {
21✔
2542
        u.VisibilityTimestamp = timestamp
21✔
2543
}
21✔
2544

2545
// GetType returns the type of the record workflow closed task
2546
func (u *RecordWorkflowClosedTask) GetType() int {
×
2547
        return TransferTaskTypeRecordWorkflowClosed
×
2548
}
×
2549

2550
// GetVersion returns the version of the record workflow closed task
2551
func (u *RecordWorkflowClosedTask) GetVersion() int64 {
×
2552
        return u.Version
×
2553
}
×
2554

2555
// SetVersion returns the version of the record workflow closed task
2556
func (u *RecordWorkflowClosedTask) SetVersion(version int64) {
×
2557
        u.Version = version
×
2558
}
×
2559

2560
// GetTaskID returns the sequence ID of the record workflow closed task
2561
func (u *RecordWorkflowClosedTask) GetTaskID() int64 {
×
2562
        return u.TaskID
×
2563
}
×
2564

2565
// SetTaskID sets the sequence ID of the record workflow closed task
2566
func (u *RecordWorkflowClosedTask) SetTaskID(id int64) {
×
2567
        u.TaskID = id
×
2568
}
×
2569

2570
// GetVisibilityTimestamp get the visibility timestamp
2571
func (u *RecordWorkflowClosedTask) GetVisibilityTimestamp() time.Time {
×
2572
        return u.VisibilityTimestamp
×
2573
}
×
2574

2575
// SetVisibilityTimestamp set the visibility timestamp
2576
func (u *RecordWorkflowClosedTask) SetVisibilityTimestamp(timestamp time.Time) {
×
2577
        u.VisibilityTimestamp = timestamp
×
2578
}
×
2579

2580
// GetType returns of type of the cross-cluster start child task
2581
func (c *CrossClusterStartChildExecutionTask) GetType() int {
×
2582
        return CrossClusterTaskTypeStartChildExecution
×
2583
}
×
2584

2585
// GetType returns of type of the cross-cluster cancel task
2586
func (c *CrossClusterCancelExecutionTask) GetType() int {
×
2587
        return CrossClusterTaskTypeCancelExecution
×
2588
}
×
2589

2590
// GetType returns of type of the cross-cluster signal task
2591
func (c *CrossClusterSignalExecutionTask) GetType() int {
×
2592
        return CrossClusterTaskTypeSignalExecution
×
2593
}
×
2594

2595
// GetType returns of type of the cross-cluster record child workflow completion task
2596
func (c *CrossClusterRecordChildExecutionCompletedTask) GetType() int {
×
2597
        return CrossClusterTaskTypeRecordChildExeuctionCompleted
×
2598
}
×
2599

2600
// GetType returns of type of the cross-cluster cancel task
2601
func (c *CrossClusterApplyParentClosePolicyTask) GetType() int {
×
2602
        return CrossClusterTaskTypeApplyParentClosePolicy
×
2603
}
×
2604

2605
// GetType returns the type of the history replication task
2606
func (a *HistoryReplicationTask) GetType() int {
×
2607
        return ReplicationTaskTypeHistory
×
2608
}
×
2609

2610
// GetVersion returns the version of the history replication task
2611
func (a *HistoryReplicationTask) GetVersion() int64 {
×
2612
        return a.Version
×
2613
}
×
2614

2615
// SetVersion returns the version of the history replication task
2616
func (a *HistoryReplicationTask) SetVersion(version int64) {
×
2617
        a.Version = version
×
2618
}
×
2619

2620
// GetTaskID returns the sequence ID of the history replication task
2621
func (a *HistoryReplicationTask) GetTaskID() int64 {
×
2622
        return a.TaskID
×
2623
}
×
2624

2625
// SetTaskID sets the sequence ID of the history replication task
2626
func (a *HistoryReplicationTask) SetTaskID(id int64) {
×
2627
        a.TaskID = id
×
2628
}
×
2629

2630
// GetVisibilityTimestamp get the visibility timestamp
2631
func (a *HistoryReplicationTask) GetVisibilityTimestamp() time.Time {
×
2632
        return a.VisibilityTimestamp
×
2633
}
×
2634

2635
// SetVisibilityTimestamp set the visibility timestamp
2636
func (a *HistoryReplicationTask) SetVisibilityTimestamp(timestamp time.Time) {
×
2637
        a.VisibilityTimestamp = timestamp
×
2638
}
×
2639

2640
// GetType returns the type of the history replication task
2641
func (a *SyncActivityTask) GetType() int {
×
2642
        return ReplicationTaskTypeSyncActivity
×
2643
}
×
2644

2645
// GetVersion returns the version of the history replication task
2646
func (a *SyncActivityTask) GetVersion() int64 {
×
2647
        return a.Version
×
2648
}
×
2649

2650
// SetVersion returns the version of the history replication task
2651
func (a *SyncActivityTask) SetVersion(version int64) {
×
2652
        a.Version = version
×
2653
}
×
2654

2655
// GetTaskID returns the sequence ID of the history replication task
2656
func (a *SyncActivityTask) GetTaskID() int64 {
×
2657
        return a.TaskID
×
2658
}
×
2659

2660
// SetTaskID sets the sequence ID of the history replication task
2661
func (a *SyncActivityTask) SetTaskID(id int64) {
×
2662
        a.TaskID = id
×
2663
}
×
2664

2665
// GetVisibilityTimestamp get the visibility timestamp
2666
func (a *SyncActivityTask) GetVisibilityTimestamp() time.Time {
×
2667
        return a.VisibilityTimestamp
×
2668
}
×
2669

2670
// SetVisibilityTimestamp set the visibility timestamp
2671
func (a *SyncActivityTask) SetVisibilityTimestamp(timestamp time.Time) {
×
2672
        a.VisibilityTimestamp = timestamp
×
2673
}
×
2674

2675
// GetType returns the type of the history replication task
2676
func (a *FailoverMarkerTask) GetType() int {
×
2677
        return ReplicationTaskTypeFailoverMarker
×
2678
}
×
2679

2680
// GetVersion returns the version of the history replication task
2681
func (a *FailoverMarkerTask) GetVersion() int64 {
×
2682
        return a.Version
×
2683
}
×
2684

2685
// SetVersion returns the version of the history replication task
2686
func (a *FailoverMarkerTask) SetVersion(version int64) {
×
2687
        a.Version = version
×
2688
}
×
2689

2690
// GetTaskID returns the sequence ID of the history replication task
2691
func (a *FailoverMarkerTask) GetTaskID() int64 {
×
2692
        return a.TaskID
×
2693
}
×
2694

2695
// SetTaskID sets the sequence ID of the history replication task
2696
func (a *FailoverMarkerTask) SetTaskID(id int64) {
×
2697
        a.TaskID = id
×
2698
}
×
2699

2700
// GetVisibilityTimestamp get the visibility timestamp
2701
func (a *FailoverMarkerTask) GetVisibilityTimestamp() time.Time {
×
2702
        return a.VisibilityTimestamp
×
2703
}
×
2704

2705
// SetVisibilityTimestamp set the visibility timestamp
2706
func (a *FailoverMarkerTask) SetVisibilityTimestamp(timestamp time.Time) {
×
2707
        a.VisibilityTimestamp = timestamp
×
2708
}
×
2709

2710
// GetTaskID returns the task ID for transfer task
2711
func (t *TransferTaskInfo) GetTaskID() int64 {
12,622✔
2712
        return t.TaskID
12,622✔
2713
}
12,622✔
2714

2715
// GetVersion returns the task version for transfer task
2716
func (t *TransferTaskInfo) GetVersion() int64 {
5,686✔
2717
        return t.Version
5,686✔
2718
}
5,686✔
2719

2720
// GetTaskType returns the task type for transfer task
2721
func (t *TransferTaskInfo) GetTaskType() int {
11,369✔
2722
        return t.TaskType
11,369✔
2723
}
11,369✔
2724

2725
// GetVisibilityTimestamp returns the task type for transfer task
2726
func (t *TransferTaskInfo) GetVisibilityTimestamp() time.Time {
8,583✔
2727
        return t.VisibilityTimestamp
8,583✔
2728
}
8,583✔
2729

2730
// GetWorkflowID returns the workflow ID for transfer task
2731
func (t *TransferTaskInfo) GetWorkflowID() string {
8,703✔
2732
        return t.WorkflowID
8,703✔
2733
}
8,703✔
2734

2735
// GetRunID returns the run ID for transfer task
2736
func (t *TransferTaskInfo) GetRunID() string {
8,703✔
2737
        return t.RunID
8,703✔
2738
}
8,703✔
2739

2740
// GetTargetDomainIDs returns the targetDomainIDs for applyParentPolicy
2741
func (t *TransferTaskInfo) GetTargetDomainIDs() map[string]struct{} {
×
2742
        return t.TargetDomainIDs
×
2743
}
×
2744

2745
// GetDomainID returns the domain ID for transfer task
2746
func (t *TransferTaskInfo) GetDomainID() string {
28,418✔
2747
        return t.DomainID
28,418✔
2748
}
28,418✔
2749

2750
// String returns a string representation for transfer task
2751
func (t *TransferTaskInfo) String() string {
8,687✔
2752
        return fmt.Sprintf("%#v", t)
8,687✔
2753
}
8,687✔
2754

2755
// GetTaskID returns the task ID for replication task
2756
func (t *ReplicationTaskInfo) GetTaskID() int64 {
3✔
2757
        return t.TaskID
3✔
2758
}
3✔
2759

2760
// GetVersion returns the task version for replication task
2761
func (t *ReplicationTaskInfo) GetVersion() int64 {
×
2762
        return t.Version
×
2763
}
×
2764

2765
// GetTaskType returns the task type for replication task
2766
func (t *ReplicationTaskInfo) GetTaskType() int {
3✔
2767
        return t.TaskType
3✔
2768
}
3✔
2769

2770
// GetVisibilityTimestamp returns the task type for replication task
2771
func (t *ReplicationTaskInfo) GetVisibilityTimestamp() time.Time {
×
2772
        return time.Time{}
×
2773
}
×
2774

2775
// GetWorkflowID returns the workflow ID for replication task
2776
func (t *ReplicationTaskInfo) GetWorkflowID() string {
3✔
2777
        return t.WorkflowID
3✔
2778
}
3✔
2779

2780
// GetRunID returns the run ID for replication task
2781
func (t *ReplicationTaskInfo) GetRunID() string {
3✔
2782
        return t.RunID
3✔
2783
}
3✔
2784

2785
// GetDomainID returns the domain ID for replication task
2786
func (t *ReplicationTaskInfo) GetDomainID() string {
3✔
2787
        return t.DomainID
3✔
2788
}
3✔
2789

2790
// GetTaskID returns the task ID for timer task
2791
func (t *TimerTaskInfo) GetTaskID() int64 {
4,787✔
2792
        return t.TaskID
4,787✔
2793
}
4,787✔
2794

2795
// GetVersion returns the task version for timer task
2796
func (t *TimerTaskInfo) GetVersion() int64 {
2,398✔
2797
        return t.Version
2,398✔
2798
}
2,398✔
2799

2800
// GetTaskType returns the task type for timer task
2801
func (t *TimerTaskInfo) GetTaskType() int {
4,787✔
2802
        return t.TaskType
4,787✔
2803
}
4,787✔
2804

2805
// GetVisibilityTimestamp returns the task type for timer task
2806
func (t *TimerTaskInfo) GetVisibilityTimestamp() time.Time {
13,436✔
2807
        return t.VisibilityTimestamp
13,436✔
2808
}
13,436✔
2809

2810
// GetWorkflowID returns the workflow ID for timer task
2811
func (t *TimerTaskInfo) GetWorkflowID() string {
4,789✔
2812
        return t.WorkflowID
4,789✔
2813
}
4,789✔
2814

2815
// GetRunID returns the run ID for timer task
2816
func (t *TimerTaskInfo) GetRunID() string {
4,789✔
2817
        return t.RunID
4,789✔
2818
}
4,789✔
2819

2820
// GetDomainID returns the domain ID for timer task
2821
func (t *TimerTaskInfo) GetDomainID() string {
11,965✔
2822
        return t.DomainID
11,965✔
2823
}
11,965✔
2824

2825
// String returns a string representation for timer task
2826
func (t *TimerTaskInfo) String() string {
2,606✔
2827
        return fmt.Sprintf(
2,606✔
2828
                "{DomainID: %v, WorkflowID: %v, RunID: %v, VisibilityTimestamp: %v, TaskID: %v, TaskType: %v, TimeoutType: %v, EventID: %v, ScheduleAttempt: %v, Version: %v.}",
2,606✔
2829
                t.DomainID, t.WorkflowID, t.RunID, t.VisibilityTimestamp, t.TaskID, t.TaskType, t.TimeoutType, t.EventID, t.ScheduleAttempt, t.Version,
2,606✔
2830
        )
2,606✔
2831
}
2,606✔
2832

2833
// Copy returns a shallow copy of shardInfo
2834
func (s *ShardInfo) Copy() *ShardInfo {
155✔
2835
        // TODO: do we really need to deep copy those fields?
155✔
2836
        clusterTransferAckLevel := make(map[string]int64)
155✔
2837
        for k, v := range s.ClusterTransferAckLevel {
288✔
2838
                clusterTransferAckLevel[k] = v
133✔
2839
        }
133✔
2840
        clusterTimerAckLevel := make(map[string]time.Time)
155✔
2841
        for k, v := range s.ClusterTimerAckLevel {
288✔
2842
                clusterTimerAckLevel[k] = v
133✔
2843
        }
133✔
2844
        clusterReplicationLevel := make(map[string]int64)
155✔
2845
        for k, v := range s.ClusterReplicationLevel {
155✔
2846
                clusterReplicationLevel[k] = v
×
2847
        }
×
2848
        replicationDLQAckLevel := make(map[string]int64)
155✔
2849
        for k, v := range s.ReplicationDLQAckLevel {
155✔
2850
                replicationDLQAckLevel[k] = v
×
2851
        }
×
2852
        return &ShardInfo{
155✔
2853
                ShardID:                           s.ShardID,
155✔
2854
                Owner:                             s.Owner,
155✔
2855
                RangeID:                           s.RangeID,
155✔
2856
                StolenSinceRenew:                  s.StolenSinceRenew,
155✔
2857
                ReplicationAckLevel:               s.ReplicationAckLevel,
155✔
2858
                TransferAckLevel:                  s.TransferAckLevel,
155✔
2859
                TimerAckLevel:                     s.TimerAckLevel,
155✔
2860
                ClusterTransferAckLevel:           clusterTransferAckLevel,
155✔
2861
                ClusterTimerAckLevel:              clusterTimerAckLevel,
155✔
2862
                TransferProcessingQueueStates:     s.TransferProcessingQueueStates,
155✔
2863
                CrossClusterProcessingQueueStates: s.CrossClusterProcessingQueueStates,
155✔
2864
                TimerProcessingQueueStates:        s.TimerProcessingQueueStates,
155✔
2865
                DomainNotificationVersion:         s.DomainNotificationVersion,
155✔
2866
                ClusterReplicationLevel:           clusterReplicationLevel,
155✔
2867
                ReplicationDLQAckLevel:            replicationDLQAckLevel,
155✔
2868
                PendingFailoverMarkers:            s.PendingFailoverMarkers,
155✔
2869
                UpdatedAt:                         s.UpdatedAt,
155✔
2870
        }
155✔
2871
}
2872

2873
// SerializeClusterConfigs makes an array of *ClusterReplicationConfig serializable
2874
// by flattening them into map[string]interface{}
2875
func SerializeClusterConfigs(replicationConfigs []*ClusterReplicationConfig) []map[string]interface{} {
21✔
2876
        seriaizedReplicationConfigs := []map[string]interface{}{}
21✔
2877
        for index := range replicationConfigs {
38✔
2878
                seriaizedReplicationConfigs = append(seriaizedReplicationConfigs, replicationConfigs[index].serialize())
17✔
2879
        }
17✔
2880
        return seriaizedReplicationConfigs
21✔
2881
}
2882

2883
// DeserializeClusterConfigs creates an array of ClusterReplicationConfigs from an array of map representations
2884
func DeserializeClusterConfigs(replicationConfigs []map[string]interface{}) []*ClusterReplicationConfig {
1,548✔
2885
        deseriaizedReplicationConfigs := []*ClusterReplicationConfig{}
1,548✔
2886
        for index := range replicationConfigs {
2,781✔
2887
                deseriaizedReplicationConfig := &ClusterReplicationConfig{}
1,233✔
2888
                deseriaizedReplicationConfig.deserialize(replicationConfigs[index])
1,233✔
2889
                deseriaizedReplicationConfigs = append(deseriaizedReplicationConfigs, deseriaizedReplicationConfig)
1,233✔
2890
        }
1,233✔
2891

2892
        return deseriaizedReplicationConfigs
1,548✔
2893
}
2894

2895
func (config *ClusterReplicationConfig) serialize() map[string]interface{} {
17✔
2896
        output := make(map[string]interface{})
17✔
2897
        output["cluster_name"] = config.ClusterName
17✔
2898
        return output
17✔
2899
}
17✔
2900

2901
func (config *ClusterReplicationConfig) deserialize(input map[string]interface{}) {
1,233✔
2902
        config.ClusterName = input["cluster_name"].(string)
1,233✔
2903
}
1,233✔
2904

2905
// GetCopy return a copy of ClusterReplicationConfig
2906
func (config *ClusterReplicationConfig) GetCopy() *ClusterReplicationConfig {
2✔
2907
        res := *config
2✔
2908
        return &res
2✔
2909
}
2✔
2910

2911
// DBTimestampToUnixNano converts Milliseconds timestamp to UnixNano
2912
func DBTimestampToUnixNano(milliseconds int64) int64 {
3,391✔
2913
        return milliseconds * 1000 * 1000 // Milliseconds are 10⁻³, nanoseconds are 10⁻⁹, (-3) - (-9) = 6, so multiply by 10⁶
3,391✔
2914
}
3,391✔
2915

2916
// UnixNanoToDBTimestamp converts UnixNano to Milliseconds timestamp
2917
func UnixNanoToDBTimestamp(timestamp int64) int64 {
8,963✔
2918
        return timestamp / (1000 * 1000) // Milliseconds are 10⁻³, nanoseconds are 10⁻⁹, (-9) - (-3) = -6, so divide by 10⁶
8,963✔
2919
}
8,963✔
2920

2921
var internalThriftEncoder = codec.NewThriftRWEncoder()
2922

2923
// NewHistoryBranchToken return a new branch token
2924
func NewHistoryBranchToken(treeID string) ([]byte, error) {
669✔
2925
        branchID := uuid.New()
669✔
2926
        bi := &workflow.HistoryBranch{
669✔
2927
                TreeID:    &treeID,
669✔
2928
                BranchID:  &branchID,
669✔
2929
                Ancestors: []*workflow.HistoryBranchRange{},
669✔
2930
        }
669✔
2931
        token, err := internalThriftEncoder.Encode(bi)
669✔
2932
        if err != nil {
669✔
2933
                return nil, err
×
2934
        }
×
2935
        return token, nil
669✔
2936
}
2937

2938
// NewHistoryBranchTokenByBranchID return a new branch token with treeID/branchID
2939
func NewHistoryBranchTokenByBranchID(treeID, branchID string) ([]byte, error) {
×
2940
        bi := &workflow.HistoryBranch{
×
2941
                TreeID:    &treeID,
×
2942
                BranchID:  &branchID,
×
2943
                Ancestors: []*workflow.HistoryBranchRange{},
×
2944
        }
×
2945
        token, err := internalThriftEncoder.Encode(bi)
×
2946
        if err != nil {
×
2947
                return nil, err
×
2948
        }
×
2949
        return token, nil
×
2950
}
2951

2952
// NewHistoryBranchTokenFromAnother make up a branchToken
2953
func NewHistoryBranchTokenFromAnother(branchID string, anotherToken []byte) ([]byte, error) {
×
2954
        var branch workflow.HistoryBranch
×
2955
        err := internalThriftEncoder.Decode(anotherToken, &branch)
×
2956
        if err != nil {
×
2957
                return nil, err
×
2958
        }
×
2959

2960
        bi := &workflow.HistoryBranch{
×
2961
                TreeID:    branch.TreeID,
×
2962
                BranchID:  &branchID,
×
2963
                Ancestors: []*workflow.HistoryBranchRange{},
×
2964
        }
×
2965
        token, err := internalThriftEncoder.Encode(bi)
×
2966
        if err != nil {
×
2967
                return nil, err
×
2968
        }
×
2969
        return token, nil
×
2970
}
2971

2972
// BuildHistoryGarbageCleanupInfo combine the workflow identity information into a string
2973
func BuildHistoryGarbageCleanupInfo(domainID, workflowID, runID string) string {
663✔
2974
        return fmt.Sprintf("%v:%v:%v", domainID, workflowID, runID)
663✔
2975
}
663✔
2976

2977
// SplitHistoryGarbageCleanupInfo returns workflow identity information
2978
func SplitHistoryGarbageCleanupInfo(info string) (domainID, workflowID, runID string, err error) {
×
2979
        ss := strings.Split(info, ":")
×
2980
        // workflowID can contain ":" so len(ss) can be greater than 3
×
2981
        if len(ss) < numItemsInGarbageInfo {
×
2982
                return "", "", "", fmt.Errorf("not able to split info for  %s", info)
×
2983
        }
×
2984
        domainID = ss[0]
×
2985
        runID = ss[len(ss)-1]
×
2986
        workflowEnd := len(info) - len(runID) - 1
×
2987
        workflowID = info[len(domainID)+1 : workflowEnd]
×
2988
        return
×
2989
}
2990

2991
// NewGetReplicationTasksFromDLQRequest creates a new GetReplicationTasksFromDLQRequest
2992
func NewGetReplicationTasksFromDLQRequest(
2993
        sourceClusterName string,
2994
        readLevel int64,
2995
        maxReadLevel int64,
2996
        batchSize int,
2997
        nextPageToken []byte,
2998
) *GetReplicationTasksFromDLQRequest {
3✔
2999
        return &GetReplicationTasksFromDLQRequest{
3✔
3000
                SourceClusterName: sourceClusterName,
3✔
3001
                GetReplicationTasksRequest: GetReplicationTasksRequest{
3✔
3002
                        ReadLevel:     readLevel,
3✔
3003
                        MaxReadLevel:  maxReadLevel,
3✔
3004
                        BatchSize:     batchSize,
3✔
3005
                        NextPageToken: nextPageToken,
3✔
3006
                },
3✔
3007
        }
3✔
3008
}
3✔
3009

3010
// IsTransientError checks if the error is a transient persistence error
3011
func IsTransientError(err error) bool {
14,411✔
3012
        switch err.(type) {
14,411✔
3013
        case *types.InternalServiceError, *types.ServiceBusyError, *TimeoutError:
3✔
3014
                return true
3✔
3015
        }
3016

3017
        return false
14,408✔
3018
}
3019

3020
// IsBackgroundTransientError checks if the error is a transient error on background jobs
3021
func IsBackgroundTransientError(err error) bool {
×
3022
        switch err.(type) {
×
3023
        case *types.InternalServiceError, *TimeoutError:
×
3024
                return true
×
3025
        }
3026

3027
        return false
×
3028
}
3029

3030
// HasMoreRowsToDelete checks if there is more data need to be deleted
3031
func HasMoreRowsToDelete(rowsDeleted, batchSize int) bool {
411✔
3032
        if rowsDeleted < batchSize || // all target tasks are deleted
411✔
3033
                rowsDeleted == UnknownNumRowsAffected || // underlying database does not support rows affected, so pageSize is not honored and all target tasks are deleted
411✔
3034
                rowsDeleted > batchSize { // pageSize is not honored and all tasks are deleted
822✔
3035
                return false
411✔
3036
        }
411✔
3037
        return true
×
3038
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc