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

uber / cadence / 0188b6ba-6aaf-4739-8b30-52eaead5800c

13 Jun 2023 09:47PM UTC coverage: 57.204% (-0.01%) from 57.217%
0188b6ba-6aaf-4739-8b30-52eaead5800c

push

buildkite

web-flow
Bugfix/isolation groups domain drains (#5315)

What changed?
Fixes several bugs in the domain isolation-group handling which wasn't tested properly in replication it notably:

Fixes the problem of upserting configuration from the inactive region, which was previously would error
Fixes the problem of replication of configuration, which was entirely not working
Refactors the domain controller by splitting out this functionality into its own, much simpler function rather than continuing to overload the already incomprehensible domain controller.
Why?

How did you test it?

cadence --env docstore-prod11 --proxy_region dca admin isolation-groups get-domain --domain cadence-canary-global
Isolation Groups State
asdf5            Drained
asfd             Drained
-------------------------------------------------------------------------------------------------------------------------------------------------------------
~ » cadence --env an-env --proxy_region dca admin isolation-groups update-domain --domain cadence-canary-global  --remove-all-drains
-------------------------------------------------------------------------------------------------------------------------------------------------------------
~ » cadence --env an-env --proxy_region dca admin isolation-groups get-domain --domain cadence-canary-global
-- No groups found --
-------------------------------------------------------------------------------------------------------------------------------------------------------------
~ » cadence --env an-env --proxy_region phx admin isolation-groups get-domain --domain cadence-canary-global
-- No groups found --
Potential risks

141 of 141 new or added lines in 5 files covered. (100.0%)

86988 of 152065 relevant lines covered (57.2%)

2482.57 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
        GlobalIsolationGroupConfig
226
)
227

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

456
        // TaskInfo describes either activity or decision task
457
        TaskInfo struct {
458
                DomainID               string
459
                WorkflowID             string
460
                RunID                  string
461
                TaskID                 int64
462
                ScheduleID             int64
463
                ScheduleToStartTimeout int32
464
                Expiry                 time.Time
465
                CreatedTime            time.Time
466
                PartitionConfig        map[string]string
467
        }
468

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

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

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

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

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

516
        // ResetWorkflowTask identifites a transfer task to reset workflow
517
        ResetWorkflowTask struct {
518
                VisibilityTimestamp time.Time
519
                TaskID              int64
520
                Version             int64
521
        }
522

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

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

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

547
        // WorkflowTimeoutTask identifies a timeout task.
548
        WorkflowTimeoutTask struct {
549
                VisibilityTimestamp time.Time
550
                TaskID              int64
551
                Version             int64
552
        }
553

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

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

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

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

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

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

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

622
        // CrossClusterStartChildExecutionTask is the cross-cluster version of StartChildExecutionTask
623
        CrossClusterStartChildExecutionTask struct {
624
                StartChildExecutionTask
625

626
                TargetCluster string
627
        }
628

629
        // CrossClusterCancelExecutionTask is the cross-cluster version of CancelExecutionTask
630
        CrossClusterCancelExecutionTask struct {
631
                CancelExecutionTask
632

633
                TargetCluster string
634
        }
635

636
        // CrossClusterSignalExecutionTask is the cross-cluster version of SignalExecutionTask
637
        CrossClusterSignalExecutionTask struct {
638
                SignalExecutionTask
639

640
                TargetCluster string
641
        }
642

643
        // CrossClusterRecordChildExecutionCompletedTask is the cross-cluster version of RecordChildExecutionCompletedTask
644
        CrossClusterRecordChildExecutionCompletedTask struct {
645
                RecordChildExecutionCompletedTask
646

647
                TargetCluster string
648
        }
649

650
        // CrossClusterApplyParentClosePolicyTask is the cross-cluster version of ApplyParentClosePolicyTask
651
        CrossClusterApplyParentClosePolicyTask struct {
652
                ApplyParentClosePolicyTask
653

654
                TargetCluster string
655
        }
656

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

667
        // UserTimerTask identifies a timeout task.
668
        UserTimerTask struct {
669
                VisibilityTimestamp time.Time
670
                TaskID              int64
671
                EventID             int64
672
                Version             int64
673
        }
674

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

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

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

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

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

720
        // ReplicationInfo represents the information stored for last replication event details per cluster
721
        ReplicationInfo struct {
722
                Version     int64
723
                LastEventID int64
724
        }
725

726
        // VersionHistoryItem contains the event id and the associated version
727
        VersionHistoryItem struct {
728
                EventID int64
729
                Version int64
730
        }
731

732
        // VersionHistory provides operations on version history
733
        VersionHistory struct {
734
                BranchToken []byte
735
                Items       []*VersionHistoryItem
736
        }
737

738
        // VersionHistories contains a set of VersionHistory
739
        VersionHistories struct {
740
                CurrentVersionHistoryIndex int
741
                Histories                  []*VersionHistory
742
        }
743

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

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

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

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

826
        // RequestCancelInfo has details for pending external workflow cancellations
827
        RequestCancelInfo struct {
828
                Version               int64
829
                InitiatedEventBatchID int64
830
                InitiatedID           int64
831
                CancelRequestID       string
832
        }
833

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

845
        // CreateShardRequest is used to create a shard in executions table
846
        CreateShardRequest struct {
847
                ShardInfo *ShardInfo
848
        }
849

850
        // GetShardRequest is used to get shard information
851
        GetShardRequest struct {
852
                ShardID int
853
        }
854

855
        // GetShardResponse is the response to GetShard
856
        GetShardResponse struct {
857
                ShardInfo *ShardInfo
858
        }
859

860
        // UpdateShardRequest is used to update shard information
861
        UpdateShardRequest struct {
862
                ShardInfo       *ShardInfo
863
                PreviousRangeID int64
864
        }
865

866
        // CreateWorkflowExecutionRequest is used to write a new workflow execution
867
        CreateWorkflowExecutionRequest struct {
868
                RangeID int64
869

870
                Mode CreateWorkflowMode
871

872
                PreviousRunID            string
873
                PreviousLastWriteVersion int64
874

875
                NewWorkflowSnapshot WorkflowSnapshot
876

877
                DomainName string
878
        }
879

880
        // CreateWorkflowExecutionResponse is the response to CreateWorkflowExecutionRequest
881
        CreateWorkflowExecutionResponse struct {
882
                MutableStateUpdateSessionStats *MutableStateUpdateSessionStats
883
        }
884

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

892
        // GetWorkflowExecutionResponse is the response to GetworkflowExecutionRequest
893
        GetWorkflowExecutionResponse struct {
894
                State             *WorkflowMutableState
895
                MutableStateStats *MutableStateStats
896
        }
897

898
        // GetCurrentExecutionRequest is used to retrieve the current RunId for an execution
899
        GetCurrentExecutionRequest struct {
900
                DomainID   string
901
                WorkflowID string
902
                DomainName string
903
        }
904

905
        // ListCurrentExecutionsRequest is request to ListCurrentExecutions
906
        ListCurrentExecutionsRequest struct {
907
                PageSize  int
908
                PageToken []byte
909
        }
910

911
        // ListCurrentExecutionsResponse is the response to ListCurrentExecutionsRequest
912
        ListCurrentExecutionsResponse struct {
913
                Executions []*CurrentWorkflowExecution
914
                PageToken  []byte
915
        }
916

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

925
        // ListConcreteExecutionsRequest is request to ListConcreteExecutions
926
        ListConcreteExecutionsRequest struct {
927
                PageSize  int
928
                PageToken []byte
929
        }
930

931
        // ListConcreteExecutionsResponse is response to ListConcreteExecutions
932
        ListConcreteExecutionsResponse struct {
933
                Executions []*ListConcreteExecutionsEntity
934
                PageToken  []byte
935
        }
936

937
        // ListConcreteExecutionsEntity is a single entity in ListConcreteExecutionsResponse
938
        ListConcreteExecutionsEntity struct {
939
                ExecutionInfo    *WorkflowExecutionInfo
940
                VersionHistories *VersionHistories
941
        }
942

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

952
        // IsWorkflowExecutionExistsResponse is the response to IsWorkflowExecutionExists
953
        IsWorkflowExecutionExistsResponse struct {
954
                Exists bool
955
        }
956

957
        // UpdateWorkflowExecutionRequest is used to update a workflow execution
958
        UpdateWorkflowExecutionRequest struct {
959
                RangeID int64
960

961
                Mode UpdateWorkflowMode
962

963
                UpdateWorkflowMutation WorkflowMutation
964

965
                NewWorkflowSnapshot *WorkflowSnapshot
966

967
                Encoding common.EncodingType // optional binary encoding type
968

969
                DomainName string
970
        }
971

972
        // ConflictResolveWorkflowExecutionRequest is used to reset workflow execution state for a single run
973
        ConflictResolveWorkflowExecutionRequest struct {
974
                RangeID int64
975

976
                Mode ConflictResolveWorkflowMode
977

978
                // workflow to be resetted
979
                ResetWorkflowSnapshot WorkflowSnapshot
980

981
                // maybe new workflow
982
                NewWorkflowSnapshot *WorkflowSnapshot
983

984
                // current workflow
985
                CurrentWorkflowMutation *WorkflowMutation
986

987
                Encoding common.EncodingType // optional binary encoding type
988

989
                DomainName string
990
        }
991

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

1001
        // WorkflowMutation is used as generic workflow execution state mutation
1002
        WorkflowMutation struct {
1003
                ExecutionInfo    *WorkflowExecutionInfo
1004
                ExecutionStats   *ExecutionStats
1005
                VersionHistories *VersionHistories
1006

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

1022
                TransferTasks     []Task
1023
                CrossClusterTasks []Task
1024
                ReplicationTasks  []Task
1025
                TimerTasks        []Task
1026

1027
                Condition int64
1028
                Checksum  checksum.Checksum
1029
        }
1030

1031
        // WorkflowSnapshot is used as generic workflow execution state snapshot
1032
        WorkflowSnapshot struct {
1033
                ExecutionInfo    *WorkflowExecutionInfo
1034
                ExecutionStats   *ExecutionStats
1035
                VersionHistories *VersionHistories
1036

1037
                ActivityInfos       []*ActivityInfo
1038
                TimerInfos          []*TimerInfo
1039
                ChildExecutionInfos []*ChildExecutionInfo
1040
                RequestCancelInfos  []*RequestCancelInfo
1041
                SignalInfos         []*SignalInfo
1042
                SignalRequestedIDs  []string
1043

1044
                TransferTasks     []Task
1045
                CrossClusterTasks []Task
1046
                ReplicationTasks  []Task
1047
                TimerTasks        []Task
1048

1049
                Condition int64
1050
                Checksum  checksum.Checksum
1051
        }
1052

1053
        // DeleteWorkflowExecutionRequest is used to delete a workflow execution
1054
        DeleteWorkflowExecutionRequest struct {
1055
                DomainID   string
1056
                WorkflowID string
1057
                RunID      string
1058
                DomainName string
1059
        }
1060

1061
        // DeleteCurrentWorkflowExecutionRequest is used to delete the current workflow execution
1062
        DeleteCurrentWorkflowExecutionRequest struct {
1063
                DomainID   string
1064
                WorkflowID string
1065
                RunID      string
1066
                DomainName string
1067
        }
1068

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

1077
        // GetTransferTasksResponse is the response to GetTransferTasksRequest
1078
        GetTransferTasksResponse struct {
1079
                Tasks         []*TransferTaskInfo
1080
                NextPageToken []byte
1081
        }
1082

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

1092
        // GetCrossClusterTasksResponse is the response to GetCrossClusterTasksRequest
1093
        GetCrossClusterTasksResponse struct {
1094
                Tasks         []*CrossClusterTaskInfo
1095
                NextPageToken []byte
1096
        }
1097

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

1106
        // GetReplicationTasksResponse is the response to GetReplicationTask
1107
        GetReplicationTasksResponse struct {
1108
                Tasks         []*ReplicationTaskInfo
1109
                NextPageToken []byte
1110
        }
1111

1112
        // CompleteTransferTaskRequest is used to complete a task in the transfer task queue
1113
        CompleteTransferTaskRequest struct {
1114
                TaskID int64
1115
        }
1116

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

1124
        // RangeCompleteTransferTaskResponse is the response of RangeCompleteTransferTask
1125
        RangeCompleteTransferTaskResponse struct {
1126
                TasksCompleted int
1127
        }
1128

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

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

1143
        // RangeCompleteCrossClusterTaskResponse is the response of RangeCompleteCrossClusterTask
1144
        RangeCompleteCrossClusterTaskResponse struct {
1145
                TasksCompleted int
1146
        }
1147

1148
        // CompleteReplicationTaskRequest is used to complete a task in the replication task queue
1149
        CompleteReplicationTaskRequest struct {
1150
                TaskID int64
1151
        }
1152

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

1159
        // RangeCompleteReplicationTaskResponse is the response of RangeCompleteReplicationTask
1160
        RangeCompleteReplicationTaskResponse struct {
1161
                TasksCompleted int
1162
        }
1163

1164
        // PutReplicationTaskToDLQRequest is used to put a replication task to dlq
1165
        PutReplicationTaskToDLQRequest struct {
1166
                SourceClusterName string
1167
                TaskInfo          *ReplicationTaskInfo
1168
                DomainName        string
1169
        }
1170

1171
        // GetReplicationTasksFromDLQRequest is used to get replication tasks from dlq
1172
        GetReplicationTasksFromDLQRequest struct {
1173
                SourceClusterName string
1174
                GetReplicationTasksRequest
1175
        }
1176

1177
        // GetReplicationDLQSizeRequest is used to get one replication task from dlq
1178
        GetReplicationDLQSizeRequest struct {
1179
                SourceClusterName string
1180
        }
1181

1182
        // DeleteReplicationTaskFromDLQRequest is used to delete replication task from DLQ
1183
        DeleteReplicationTaskFromDLQRequest struct {
1184
                SourceClusterName string
1185
                TaskID            int64
1186
        }
1187

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

1196
        //RangeDeleteReplicationTaskFromDLQResponse is the response of RangeDeleteReplicationTaskFromDLQ
1197
        RangeDeleteReplicationTaskFromDLQResponse struct {
1198
                TasksCompleted int
1199
        }
1200

1201
        // GetReplicationTasksFromDLQResponse is the response for GetReplicationTasksFromDLQ
1202
        GetReplicationTasksFromDLQResponse = GetReplicationTasksResponse
1203

1204
        // GetReplicationDLQSizeResponse is the response for GetReplicationDLQSize
1205
        GetReplicationDLQSizeResponse struct {
1206
                Size int64
1207
        }
1208

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

1216
        // RangeCompleteTimerTaskResponse is the response of RangeCompleteTimerTask
1217
        RangeCompleteTimerTaskResponse struct {
1218
                TasksCompleted int
1219
        }
1220

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

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

1237
        // LeaseTaskListResponse is response to LeaseTaskListRequest
1238
        LeaseTaskListResponse struct {
1239
                TaskListInfo *TaskListInfo
1240
        }
1241

1242
        // UpdateTaskListRequest is used to update task list implementation information
1243
        UpdateTaskListRequest struct {
1244
                TaskListInfo *TaskListInfo
1245
                DomainName   string
1246
        }
1247

1248
        // UpdateTaskListResponse is the response to UpdateTaskList
1249
        UpdateTaskListResponse struct {
1250
        }
1251

1252
        // ListTaskListRequest contains the request params needed to invoke ListTaskList API
1253
        ListTaskListRequest struct {
1254
                PageSize  int
1255
                PageToken []byte
1256
        }
1257

1258
        // ListTaskListResponse is the response from ListTaskList API
1259
        ListTaskListResponse struct {
1260
                Items         []TaskListInfo
1261
                NextPageToken []byte
1262
        }
1263

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

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

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

1287
        // CreateTasksResponse is the response to CreateTasksRequest
1288
        CreateTasksResponse struct {
1289
        }
1290

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

1302
        // GetTasksResponse is the response to GetTasksRequests
1303
        GetTasksResponse struct {
1304
                Tasks []*TaskInfo
1305
        }
1306

1307
        // CompleteTaskRequest is used to complete a task
1308
        CompleteTaskRequest struct {
1309
                TaskList   *TaskListInfo
1310
                TaskID     int64
1311
                DomainName string
1312
        }
1313

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

1324
        // CompleteTasksLessThanResponse is the response of CompleteTasksLessThan
1325
        CompleteTasksLessThanResponse struct {
1326
                TasksCompleted int
1327
        }
1328

1329
        // GetOrphanTasksRequest contains the request params need to invoke the GetOrphanTasks API
1330
        GetOrphanTasksRequest struct {
1331
                Limit int
1332
        }
1333

1334
        // GetOrphanTasksResponse is the response to GetOrphanTasksRequests
1335
        GetOrphanTasksResponse struct {
1336
                Tasks []*TaskKey
1337
        }
1338

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

1348
        // GetTimerIndexTasksResponse is the response for GetTimerIndexTasks
1349
        GetTimerIndexTasksResponse struct {
1350
                Timers        []*TimerTaskInfo
1351
                NextPageToken []byte
1352
        }
1353

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

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

1377
        // DomainReplicationConfig describes the cross DC domain replication configuration
1378
        DomainReplicationConfig struct {
1379
                ActiveClusterName string
1380
                Clusters          []*ClusterReplicationConfig
1381
        }
1382

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

1389
        // CreateDomainRequest is used to create the domain
1390
        CreateDomainRequest struct {
1391
                Info              *DomainInfo
1392
                Config            *DomainConfig
1393
                ReplicationConfig *DomainReplicationConfig
1394
                IsGlobalDomain    bool
1395
                ConfigVersion     int64
1396
                FailoverVersion   int64
1397
                LastUpdatedTime   int64
1398
        }
1399

1400
        // CreateDomainResponse is the response for CreateDomain
1401
        CreateDomainResponse struct {
1402
                ID string
1403
        }
1404

1405
        // GetDomainRequest is used to read domain
1406
        GetDomainRequest struct {
1407
                ID   string
1408
                Name string
1409
        }
1410

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

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

1440
        // DeleteDomainRequest is used to delete domain entry from domains table
1441
        DeleteDomainRequest struct {
1442
                ID string
1443
        }
1444

1445
        // DeleteDomainByNameRequest is used to delete domain entry from domains_by_name table
1446
        DeleteDomainByNameRequest struct {
1447
                Name string
1448
        }
1449

1450
        // ListDomainsRequest is used to list domains
1451
        ListDomainsRequest struct {
1452
                PageSize      int
1453
                NextPageToken []byte
1454
        }
1455

1456
        // ListDomainsResponse is the response for GetDomain
1457
        ListDomainsResponse struct {
1458
                Domains       []*GetDomainResponse
1459
                NextPageToken []byte
1460
        }
1461

1462
        // GetMetadataResponse is the response for GetMetadata
1463
        GetMetadataResponse struct {
1464
                NotificationVersion int64
1465
        }
1466

1467
        // MutableStateStats is the size stats for MutableState
1468
        MutableStateStats struct {
1469
                // Total size of mutable state
1470
                MutableStateSize int
1471

1472
                // Breakdown of size into more granular stats
1473
                ExecutionInfoSize  int
1474
                ActivityInfoSize   int
1475
                TimerInfoSize      int
1476
                ChildInfoSize      int
1477
                SignalInfoSize     int
1478
                BufferedEventsSize int
1479

1480
                // Item count for various information captured within mutable state
1481
                ActivityInfoCount      int
1482
                TimerInfoCount         int
1483
                ChildInfoCount         int
1484
                SignalInfoCount        int
1485
                RequestCancelInfoCount int
1486
                BufferedEventsCount    int
1487
        }
1488

1489
        // MutableStateUpdateSessionStats is size stats for mutableState updating session
1490
        MutableStateUpdateSessionStats struct {
1491
                MutableStateSize int // Total size of mutable state update
1492

1493
                // Breakdown of mutable state size update for more granular stats
1494
                ExecutionInfoSize  int
1495
                ActivityInfoSize   int
1496
                TimerInfoSize      int
1497
                ChildInfoSize      int
1498
                SignalInfoSize     int
1499
                BufferedEventsSize int
1500

1501
                // Item counts in this session update
1502
                ActivityInfoCount      int
1503
                TimerInfoCount         int
1504
                ChildInfoCount         int
1505
                SignalInfoCount        int
1506
                RequestCancelInfoCount int
1507

1508
                // Deleted item counts in this session update
1509
                DeleteActivityInfoCount      int
1510
                DeleteTimerInfoCount         int
1511
                DeleteChildInfoCount         int
1512
                DeleteSignalInfoCount        int
1513
                DeleteRequestCancelInfoCount int
1514

1515
                TransferTasksCount    int
1516
                CrossClusterTaskCount int
1517
                TimerTasksCount       int
1518
                ReplicationTasksCount int
1519
        }
1520

1521
        // UpdateWorkflowExecutionResponse is response for UpdateWorkflowExecutionRequest
1522
        UpdateWorkflowExecutionResponse struct {
1523
                MutableStateUpdateSessionStats *MutableStateUpdateSessionStats
1524
        }
1525

1526
        // ConflictResolveWorkflowExecutionResponse is response for ConflictResolveWorkflowExecutionRequest
1527
        ConflictResolveWorkflowExecutionResponse struct {
1528
                MutableStateUpdateSessionStats *MutableStateUpdateSessionStats
1529
        }
1530

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

1548
                //DomainName to get metrics created with the domain
1549
                DomainName string
1550
        }
1551

1552
        // AppendHistoryNodesResponse is a response to AppendHistoryNodesRequest
1553
        AppendHistoryNodesResponse struct {
1554
                // The data blob that was persisted to database
1555
                DataBlob DataBlob
1556
        }
1557

1558
        // ReadHistoryBranchRequest is used to read a history branch
1559
        ReadHistoryBranchRequest struct {
1560
                // The branch to be read
1561
                BranchToken []byte
1562
                // Get the history nodes from MinEventID. Inclusive.
1563
                MinEventID int64
1564
                // Get the history nodes upto MaxEventID.  Exclusive.
1565
                MaxEventID int64
1566
                // 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.
1567
                // However for a single page, it is also possible that the returned events is less than PageSize (event zero events) due to stale events.
1568
                PageSize int
1569
                // Token to continue reading next page of history append transactions.  Pass in empty slice for first page
1570
                NextPageToken []byte
1571
                // The shard to get history branch data
1572
                ShardID *int
1573

1574
                DomainName string
1575
        }
1576

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

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

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

1617
        // ForkHistoryBranchRequest is used to fork a history branch
1618
        ForkHistoryBranchRequest struct {
1619
                // The base branch to fork from
1620
                ForkBranchToken []byte
1621
                // The nodeID to fork from, the new branch will start from ( inclusive ), the base branch will stop at(exclusive)
1622
                // 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.
1623
                // And ForkNodeID > 1 because forking from 1 doesn't make any sense.
1624
                ForkNodeID int64
1625
                // the info for clean up data in background
1626
                Info string
1627
                // The shard to get history branch data
1628
                ShardID *int
1629
                //DomainName to create metrics for Domain Cost Attribution
1630
                DomainName string
1631
        }
1632

1633
        // ForkHistoryBranchResponse is the response to ForkHistoryBranchRequest
1634
        ForkHistoryBranchResponse struct {
1635
                // branchToken to represent the new branch
1636
                NewBranchToken []byte
1637
        }
1638

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

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

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

1671
        // HistoryBranchDetail contains detailed information of a branch
1672
        HistoryBranchDetail struct {
1673
                TreeID   string
1674
                BranchID string
1675
                ForkTime time.Time
1676
                Info     string
1677
        }
1678

1679
        // GetHistoryTreeResponse is a response to GetHistoryTreeRequest
1680
        GetHistoryTreeResponse struct {
1681
                // all branches of a tree
1682
                Branches []*workflow.HistoryBranch
1683
        }
1684

1685
        // GetAllHistoryTreeBranchesRequest is a request of GetAllHistoryTreeBranches
1686
        GetAllHistoryTreeBranchesRequest struct {
1687
                // pagination token
1688
                NextPageToken []byte
1689
                // maximum number of branches returned per page
1690
                PageSize int
1691
        }
1692

1693
        // GetAllHistoryTreeBranchesResponse is a response to GetAllHistoryTreeBranches
1694
        GetAllHistoryTreeBranchesResponse struct {
1695
                // pagination token
1696
                NextPageToken []byte
1697
                // all branches of all trees
1698
                Branches []HistoryBranchDetail
1699
        }
1700

1701
        // CreateFailoverMarkersRequest is request to create failover markers
1702
        CreateFailoverMarkersRequest struct {
1703
                RangeID int64
1704
                Markers []*FailoverMarkerTask
1705
        }
1706

1707
        // FetchDynamicConfigResponse is a response to FetchDynamicConfigResponse
1708
        FetchDynamicConfigResponse struct {
1709
                Snapshot *DynamicConfigSnapshot
1710
        }
1711

1712
        // UpdateDynamicConfigRequest is a request to update dynamic config with snapshot
1713
        UpdateDynamicConfigRequest struct {
1714
                Snapshot *DynamicConfigSnapshot
1715
        }
1716

1717
        DynamicConfigSnapshot struct {
1718
                Version int64
1719
                Values  *types.DynamicConfigBlob
1720
        }
1721

1722
        // Closeable is an interface for any entity that supports a close operation to release resources
1723
        Closeable interface {
1724
                Close()
1725
        }
1726

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

1736
        // ExecutionManager is used to manage workflow executions
1737
        ExecutionManager interface {
1738
                Closeable
1739
                GetName() string
1740
                GetShardID() int
1741

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

1751
                // Transfer task related methods
1752
                GetTransferTasks(ctx context.Context, request *GetTransferTasksRequest) (*GetTransferTasksResponse, error)
1753
                CompleteTransferTask(ctx context.Context, request *CompleteTransferTaskRequest) error
1754
                RangeCompleteTransferTask(ctx context.Context, request *RangeCompleteTransferTaskRequest) (*RangeCompleteTransferTaskResponse, error)
1755

1756
                // Cross-cluster related methods
1757
                GetCrossClusterTasks(ctx context.Context, request *GetCrossClusterTasksRequest) (*GetCrossClusterTasksResponse, error)
1758
                CompleteCrossClusterTask(ctx context.Context, request *CompleteCrossClusterTaskRequest) error
1759
                RangeCompleteCrossClusterTask(ctx context.Context, request *RangeCompleteCrossClusterTaskRequest) (*RangeCompleteCrossClusterTaskResponse, error)
1760

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

1772
                // Timer related methods.
1773
                GetTimerIndexTasks(ctx context.Context, request *GetTimerIndexTasksRequest) (*GetTimerIndexTasksResponse, error)
1774
                CompleteTimerTask(ctx context.Context, request *CompleteTimerTaskRequest) error
1775
                RangeCompleteTimerTask(ctx context.Context, request *RangeCompleteTimerTaskRequest) (*RangeCompleteTimerTaskResponse, error)
1776

1777
                // Scan operations
1778
                ListConcreteExecutions(ctx context.Context, request *ListConcreteExecutionsRequest) (*ListConcreteExecutionsResponse, error)
1779
                ListCurrentExecutions(ctx context.Context, request *ListCurrentExecutionsRequest) (*ListCurrentExecutionsResponse, error)
1780
        }
1781

1782
        // ExecutionManagerFactory creates an instance of ExecutionManager for a given shard
1783
        ExecutionManagerFactory interface {
1784
                Closeable
1785
                NewExecutionManager(shardID int) (ExecutionManager, error)
1786
        }
1787

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

1803
        // HistoryManager is used to manager workflow history events
1804
        HistoryManager interface {
1805
                Closeable
1806
                GetName() string
1807

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

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

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

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

1862
        // QueueMessage is the message that stores in the queue
1863
        QueueMessage struct {
1864
                ID        int64     `json:"message_id"`
1865
                QueueType QueueType `json:"queue_type"`
1866
                Payload   []byte    `json:"message_payload"`
1867
        }
1868

1869
        ConfigStoreManager interface {
1870
                Closeable
1871
                FetchDynamicConfig(ctx context.Context, cfgType ConfigType) (*FetchDynamicConfigResponse, error)
1872
                UpdateDynamicConfig(ctx context.Context, request *UpdateDynamicConfigRequest, cfgType ConfigType) error
1873
                //can add functions for config types other than dynamic config
1874
        }
1875
)
1876

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

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

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

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

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

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

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

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

1909
func (e *TransactionSizeLimitError) Error() string {
×
1910
        return e.Msg
×
1911
}
×
1912

1913
// IsTimeoutError check whether error is TimeoutError
1914
func IsTimeoutError(err error) bool {
×
1915
        _, ok := err.(*TimeoutError)
×
1916
        return ok
×
1917
}
×
1918

1919
// GetType returns the type of the activity task
1920
func (a *ActivityTask) GetType() int {
801✔
1921
        return TransferTaskTypeActivityTask
801✔
1922
}
801✔
1923

1924
// GetVersion returns the version of the activity task
1925
func (a *ActivityTask) GetVersion() int64 {
738✔
1926
        return a.Version
738✔
1927
}
738✔
1928

1929
// SetVersion returns the version of the activity task
1930
func (a *ActivityTask) SetVersion(version int64) {
×
1931
        a.Version = version
×
1932
}
×
1933

1934
// GetTaskID returns the sequence ID of the activity task
1935
func (a *ActivityTask) GetTaskID() int64 {
402✔
1936
        return a.TaskID
402✔
1937
}
402✔
1938

1939
// SetTaskID sets the sequence ID of the activity task
1940
func (a *ActivityTask) SetTaskID(id int64) {
402✔
1941
        a.TaskID = id
402✔
1942
}
402✔
1943

1944
// GetVisibilityTimestamp get the visibility timestamp
1945
func (a *ActivityTask) GetVisibilityTimestamp() time.Time {
801✔
1946
        return a.VisibilityTimestamp
801✔
1947
}
801✔
1948

1949
// SetVisibilityTimestamp set the visibility timestamp
1950
func (a *ActivityTask) SetVisibilityTimestamp(timestamp time.Time) {
402✔
1951
        a.VisibilityTimestamp = timestamp
402✔
1952
}
402✔
1953

1954
// GetType returns the type of the decision task
1955
func (d *DecisionTask) GetType() int {
2,685✔
1956
        return TransferTaskTypeDecisionTask
2,685✔
1957
}
2,685✔
1958

1959
// GetVersion returns the version of the decision task
1960
func (d *DecisionTask) GetVersion() int64 {
2,113✔
1961
        return d.Version
2,113✔
1962
}
2,113✔
1963

1964
// SetVersion returns the version of the decision task
1965
func (d *DecisionTask) SetVersion(version int64) {
×
1966
        d.Version = version
×
1967
}
×
1968

1969
// GetTaskID returns the sequence ID of the decision task.
1970
func (d *DecisionTask) GetTaskID() int64 {
1,344✔
1971
        return d.TaskID
1,344✔
1972
}
1,344✔
1973

1974
// SetTaskID sets the sequence ID of the decision task
1975
func (d *DecisionTask) SetTaskID(id int64) {
1,372✔
1976
        d.TaskID = id
1,372✔
1977
}
1,372✔
1978

1979
// GetVisibilityTimestamp get the visibility timestamp
1980
func (d *DecisionTask) GetVisibilityTimestamp() time.Time {
2,713✔
1981
        return d.VisibilityTimestamp
2,713✔
1982
}
2,713✔
1983

1984
// SetVisibilityTimestamp set the visibility timestamp
1985
func (d *DecisionTask) SetVisibilityTimestamp(timestamp time.Time) {
1,357✔
1986
        d.VisibilityTimestamp = timestamp
1,357✔
1987
}
1,357✔
1988

1989
// GetType returns the type of the record workflow started task
1990
func (a *RecordWorkflowStartedTask) GetType() int {
1,297✔
1991
        return TransferTaskTypeRecordWorkflowStarted
1,297✔
1992
}
1,297✔
1993

1994
// GetVersion returns the version of the record workflow started task
1995
func (a *RecordWorkflowStartedTask) GetVersion() int64 {
1,283✔
1996
        return a.Version
1,283✔
1997
}
1,283✔
1998

1999
// SetVersion returns the version of the record workflow started task
2000
func (a *RecordWorkflowStartedTask) SetVersion(version int64) {
×
2001
        a.Version = version
×
2002
}
×
2003

2004
// GetTaskID returns the sequence ID of the record workflow started task
2005
func (a *RecordWorkflowStartedTask) GetTaskID() int64 {
650✔
2006
        return a.TaskID
650✔
2007
}
650✔
2008

2009
// SetTaskID sets the sequence ID of the record workflow started task
2010
func (a *RecordWorkflowStartedTask) SetTaskID(id int64) {
678✔
2011
        a.TaskID = id
678✔
2012
}
678✔
2013

2014
// GetVisibilityTimestamp get the visibility timestamp
2015
func (a *RecordWorkflowStartedTask) GetVisibilityTimestamp() time.Time {
1,325✔
2016
        return a.VisibilityTimestamp
1,325✔
2017
}
1,325✔
2018

2019
// SetVisibilityTimestamp set the visibility timestamp
2020
func (a *RecordWorkflowStartedTask) SetVisibilityTimestamp(timestamp time.Time) {
663✔
2021
        a.VisibilityTimestamp = timestamp
663✔
2022
}
663✔
2023

2024
// GetType returns the type of the ResetWorkflowTask
2025
func (a *ResetWorkflowTask) GetType() int {
×
2026
        return TransferTaskTypeResetWorkflow
×
2027
}
×
2028

2029
// GetVersion returns the version of the ResetWorkflowTask
2030
func (a *ResetWorkflowTask) GetVersion() int64 {
×
2031
        return a.Version
×
2032
}
×
2033

2034
// SetVersion returns the version of the ResetWorkflowTask
2035
func (a *ResetWorkflowTask) SetVersion(version int64) {
×
2036
        a.Version = version
×
2037
}
×
2038

2039
// GetTaskID returns the sequence ID of the ResetWorkflowTask
2040
func (a *ResetWorkflowTask) GetTaskID() int64 {
×
2041
        return a.TaskID
×
2042
}
×
2043

2044
// SetTaskID sets the sequence ID of the ResetWorkflowTask
2045
func (a *ResetWorkflowTask) SetTaskID(id int64) {
×
2046
        a.TaskID = id
×
2047
}
×
2048

2049
// GetVisibilityTimestamp get the visibility timestamp
2050
func (a *ResetWorkflowTask) GetVisibilityTimestamp() time.Time {
×
2051
        return a.VisibilityTimestamp
×
2052
}
×
2053

2054
// SetVisibilityTimestamp set the visibility timestamp
2055
func (a *ResetWorkflowTask) SetVisibilityTimestamp(timestamp time.Time) {
×
2056
        a.VisibilityTimestamp = timestamp
×
2057
}
×
2058

2059
// GetType returns the type of the close execution task
2060
func (a *CloseExecutionTask) GetType() int {
1,001✔
2061
        return TransferTaskTypeCloseExecution
1,001✔
2062
}
1,001✔
2063

2064
// GetVersion returns the version of the close execution task
2065
func (a *CloseExecutionTask) GetVersion() int64 {
1,001✔
2066
        return a.Version
1,001✔
2067
}
1,001✔
2068

2069
// SetVersion returns the version of the close execution task
2070
func (a *CloseExecutionTask) SetVersion(version int64) {
×
2071
        a.Version = version
×
2072
}
×
2073

2074
// GetTaskID returns the sequence ID of the close execution task
2075
func (a *CloseExecutionTask) GetTaskID() int64 {
502✔
2076
        return a.TaskID
502✔
2077
}
502✔
2078

2079
// SetTaskID sets the sequence ID of the close execution task
2080
func (a *CloseExecutionTask) SetTaskID(id int64) {
502✔
2081
        a.TaskID = id
502✔
2082
}
502✔
2083

2084
// GetVisibilityTimestamp get the visibility timestamp
2085
func (a *CloseExecutionTask) GetVisibilityTimestamp() time.Time {
1,001✔
2086
        return a.VisibilityTimestamp
1,001✔
2087
}
1,001✔
2088

2089
// SetVisibilityTimestamp set the visibility timestamp
2090
func (a *CloseExecutionTask) SetVisibilityTimestamp(timestamp time.Time) {
502✔
2091
        a.VisibilityTimestamp = timestamp
502✔
2092
}
502✔
2093

2094
// GetType returns the type of the delete execution task
2095
func (a *DeleteHistoryEventTask) GetType() int {
1,001✔
2096
        return TaskTypeDeleteHistoryEvent
1,001✔
2097
}
1,001✔
2098

2099
// GetVersion returns the version of the delete execution task
2100
func (a *DeleteHistoryEventTask) GetVersion() int64 {
1,500✔
2101
        return a.Version
1,500✔
2102
}
1,500✔
2103

2104
// SetVersion returns the version of the delete execution task
2105
func (a *DeleteHistoryEventTask) SetVersion(version int64) {
×
2106
        a.Version = version
×
2107
}
×
2108

2109
// GetTaskID returns the sequence ID of the delete execution task
2110
func (a *DeleteHistoryEventTask) GetTaskID() int64 {
1,001✔
2111
        return a.TaskID
1,001✔
2112
}
1,001✔
2113

2114
// SetTaskID sets the sequence ID of the delete execution task
2115
func (a *DeleteHistoryEventTask) SetTaskID(id int64) {
502✔
2116
        a.TaskID = id
502✔
2117
}
502✔
2118

2119
// GetVisibilityTimestamp get the visibility timestamp
2120
func (a *DeleteHistoryEventTask) GetVisibilityTimestamp() time.Time {
2,498✔
2121
        return a.VisibilityTimestamp
2,498✔
2122
}
2,498✔
2123

2124
// SetVisibilityTimestamp set the visibility timestamp
2125
func (a *DeleteHistoryEventTask) SetVisibilityTimestamp(timestamp time.Time) {
51✔
2126
        a.VisibilityTimestamp = timestamp
51✔
2127
}
51✔
2128

2129
// GetType returns the type of the timer task
2130
func (d *DecisionTimeoutTask) GetType() int {
2,405✔
2131
        return TaskTypeDecisionTimeout
2,405✔
2132
}
2,405✔
2133

2134
// GetVersion returns the version of the timer task
2135
func (d *DecisionTimeoutTask) GetVersion() int64 {
3,597✔
2136
        return d.Version
3,597✔
2137
}
3,597✔
2138

2139
// SetVersion returns the version of the timer task
2140
func (d *DecisionTimeoutTask) SetVersion(version int64) {
×
2141
        d.Version = version
×
2142
}
×
2143

2144
// GetTaskID returns the sequence ID.
2145
func (d *DecisionTimeoutTask) GetTaskID() int64 {
2,405✔
2146
        return d.TaskID
2,405✔
2147
}
2,405✔
2148

2149
// SetTaskID sets the sequence ID.
2150
func (d *DecisionTimeoutTask) SetTaskID(id int64) {
1,204✔
2151
        d.TaskID = id
1,204✔
2152
}
1,204✔
2153

2154
// GetVisibilityTimestamp gets the visibility time stamp
2155
func (d *DecisionTimeoutTask) GetVisibilityTimestamp() time.Time {
5,999✔
2156
        return d.VisibilityTimestamp
5,999✔
2157
}
5,999✔
2158

2159
// SetVisibilityTimestamp gets the visibility time stamp
2160
func (d *DecisionTimeoutTask) SetVisibilityTimestamp(t time.Time) {
18✔
2161
        d.VisibilityTimestamp = t
18✔
2162
}
18✔
2163

2164
// GetType returns the type of the timer task
2165
func (a *ActivityTimeoutTask) GetType() int {
1,459✔
2166
        return TaskTypeActivityTimeout
1,459✔
2167
}
1,459✔
2168

2169
// GetVersion returns the version of the timer task
2170
func (a *ActivityTimeoutTask) GetVersion() int64 {
2,169✔
2171
        return a.Version
2,169✔
2172
}
2,169✔
2173

2174
// SetVersion returns the version of the timer task
2175
func (a *ActivityTimeoutTask) SetVersion(version int64) {
×
2176
        a.Version = version
×
2177
}
×
2178

2179
// GetTaskID returns the sequence ID.
2180
func (a *ActivityTimeoutTask) GetTaskID() int64 {
1,459✔
2181
        return a.TaskID
1,459✔
2182
}
1,459✔
2183

2184
// SetTaskID sets the sequence ID.
2185
func (a *ActivityTimeoutTask) SetTaskID(id int64) {
731✔
2186
        a.TaskID = id
731✔
2187
}
731✔
2188

2189
// GetVisibilityTimestamp gets the visibility time stamp
2190
func (a *ActivityTimeoutTask) GetVisibilityTimestamp() time.Time {
3,625✔
2191
        return a.VisibilityTimestamp
3,625✔
2192
}
3,625✔
2193

2194
// SetVisibilityTimestamp gets the visibility time stamp
2195
func (a *ActivityTimeoutTask) SetVisibilityTimestamp(t time.Time) {
8✔
2196
        a.VisibilityTimestamp = t
8✔
2197
}
8✔
2198

2199
// GetType returns the type of the timer task
2200
func (u *UserTimerTask) GetType() int {
63✔
2201
        return TaskTypeUserTimer
63✔
2202
}
63✔
2203

2204
// GetVersion returns the version of the timer task
2205
func (u *UserTimerTask) GetVersion() int64 {
90✔
2206
        return u.Version
90✔
2207
}
90✔
2208

2209
// SetVersion returns the version of the timer task
2210
func (u *UserTimerTask) SetVersion(version int64) {
×
2211
        u.Version = version
×
2212
}
×
2213

2214
// GetTaskID returns the sequence ID of the timer task.
2215
func (u *UserTimerTask) GetTaskID() int64 {
63✔
2216
        return u.TaskID
63✔
2217
}
63✔
2218

2219
// SetTaskID sets the sequence ID of the timer task.
2220
func (u *UserTimerTask) SetTaskID(id int64) {
33✔
2221
        u.TaskID = id
33✔
2222
}
33✔
2223

2224
// GetVisibilityTimestamp gets the visibility time stamp
2225
func (u *UserTimerTask) GetVisibilityTimestamp() time.Time {
150✔
2226
        return u.VisibilityTimestamp
150✔
2227
}
150✔
2228

2229
// SetVisibilityTimestamp gets the visibility time stamp
2230
func (u *UserTimerTask) SetVisibilityTimestamp(t time.Time) {
×
2231
        u.VisibilityTimestamp = t
×
2232
}
×
2233

2234
// GetType returns the type of the retry timer task
2235
func (r *ActivityRetryTimerTask) GetType() int {
18✔
2236
        return TaskTypeActivityRetryTimer
18✔
2237
}
18✔
2238

2239
// GetVersion returns the version of the retry timer task
2240
func (r *ActivityRetryTimerTask) GetVersion() int64 {
27✔
2241
        return r.Version
27✔
2242
}
27✔
2243

2244
// SetVersion returns the version of the retry timer task
2245
func (r *ActivityRetryTimerTask) SetVersion(version int64) {
×
2246
        r.Version = version
×
2247
}
×
2248

2249
// GetTaskID returns the sequence ID.
2250
func (r *ActivityRetryTimerTask) GetTaskID() int64 {
18✔
2251
        return r.TaskID
18✔
2252
}
18✔
2253

2254
// SetTaskID sets the sequence ID.
2255
func (r *ActivityRetryTimerTask) SetTaskID(id int64) {
9✔
2256
        r.TaskID = id
9✔
2257
}
9✔
2258

2259
// GetVisibilityTimestamp gets the visibility time stamp
2260
func (r *ActivityRetryTimerTask) GetVisibilityTimestamp() time.Time {
45✔
2261
        return r.VisibilityTimestamp
45✔
2262
}
45✔
2263

2264
// SetVisibilityTimestamp gets the visibility time stamp
2265
func (r *ActivityRetryTimerTask) SetVisibilityTimestamp(t time.Time) {
×
2266
        r.VisibilityTimestamp = t
×
2267
}
×
2268

2269
// GetType returns the type of the retry timer task
2270
func (r *WorkflowBackoffTimerTask) GetType() int {
141✔
2271
        return TaskTypeWorkflowBackoffTimer
141✔
2272
}
141✔
2273

2274
// GetVersion returns the version of the retry timer task
2275
func (r *WorkflowBackoffTimerTask) GetVersion() int64 {
144✔
2276
        return r.Version
144✔
2277
}
144✔
2278

2279
// SetVersion returns the version of the retry timer task
2280
func (r *WorkflowBackoffTimerTask) SetVersion(version int64) {
×
2281
        r.Version = version
×
2282
}
×
2283

2284
// GetTaskID returns the sequence ID.
2285
func (r *WorkflowBackoffTimerTask) GetTaskID() int64 {
141✔
2286
        return r.TaskID
141✔
2287
}
141✔
2288

2289
// SetTaskID sets the sequence ID.
2290
func (r *WorkflowBackoffTimerTask) SetTaskID(id int64) {
72✔
2291
        r.TaskID = id
72✔
2292
}
72✔
2293

2294
// GetVisibilityTimestamp gets the visibility time stamp
2295
func (r *WorkflowBackoffTimerTask) GetVisibilityTimestamp() time.Time {
282✔
2296
        return r.VisibilityTimestamp
282✔
2297
}
282✔
2298

2299
// SetVisibilityTimestamp gets the visibility time stamp
2300
func (r *WorkflowBackoffTimerTask) SetVisibilityTimestamp(t time.Time) {
3✔
2301
        r.VisibilityTimestamp = t
3✔
2302
}
3✔
2303

2304
// GetType returns the type of the timeout task.
2305
func (u *WorkflowTimeoutTask) GetType() int {
1,283✔
2306
        return TaskTypeWorkflowTimeout
1,283✔
2307
}
1,283✔
2308

2309
// GetVersion returns the version of the timeout task
2310
func (u *WorkflowTimeoutTask) GetVersion() int64 {
1,958✔
2311
        return u.Version
1,958✔
2312
}
1,958✔
2313

2314
// SetVersion returns the version of the timeout task
2315
func (u *WorkflowTimeoutTask) SetVersion(version int64) {
×
2316
        u.Version = version
×
2317
}
×
2318

2319
// GetTaskID returns the sequence ID of the cancel transfer task.
2320
func (u *WorkflowTimeoutTask) GetTaskID() int64 {
1,325✔
2321
        return u.TaskID
1,325✔
2322
}
1,325✔
2323

2324
// SetTaskID sets the sequence ID of the cancel transfer task.
2325
func (u *WorkflowTimeoutTask) SetTaskID(id int64) {
678✔
2326
        u.TaskID = id
678✔
2327
}
678✔
2328

2329
// GetVisibilityTimestamp gets the visibility time stamp
2330
func (u *WorkflowTimeoutTask) GetVisibilityTimestamp() time.Time {
3,266✔
2331
        return u.VisibilityTimestamp
3,266✔
2332
}
3,266✔
2333

2334
// SetVisibilityTimestamp gets the visibility time stamp
2335
func (u *WorkflowTimeoutTask) SetVisibilityTimestamp(t time.Time) {
3✔
2336
        u.VisibilityTimestamp = t
3✔
2337
}
3✔
2338

2339
// GetType returns the type of the cancel transfer task
2340
func (u *CancelExecutionTask) GetType() int {
15✔
2341
        return TransferTaskTypeCancelExecution
15✔
2342
}
15✔
2343

2344
// GetVersion returns the version of the cancel transfer task
2345
func (u *CancelExecutionTask) GetVersion() int64 {
15✔
2346
        return u.Version
15✔
2347
}
15✔
2348

2349
// SetVersion returns the version of the cancel transfer task
2350
func (u *CancelExecutionTask) SetVersion(version int64) {
×
2351
        u.Version = version
×
2352
}
×
2353

2354
// GetTaskID returns the sequence ID of the cancel transfer task.
2355
func (u *CancelExecutionTask) GetTaskID() int64 {
9✔
2356
        return u.TaskID
9✔
2357
}
9✔
2358

2359
// SetTaskID sets the sequence ID of the cancel transfer task.
2360
func (u *CancelExecutionTask) SetTaskID(id int64) {
9✔
2361
        u.TaskID = id
9✔
2362
}
9✔
2363

2364
// GetVisibilityTimestamp get the visibility timestamp
2365
func (u *CancelExecutionTask) GetVisibilityTimestamp() time.Time {
15✔
2366
        return u.VisibilityTimestamp
15✔
2367
}
15✔
2368

2369
// SetVisibilityTimestamp set the visibility timestamp
2370
func (u *CancelExecutionTask) SetVisibilityTimestamp(timestamp time.Time) {
9✔
2371
        u.VisibilityTimestamp = timestamp
9✔
2372
}
9✔
2373

2374
// GetType returns the type of the signal transfer task
2375
func (u *SignalExecutionTask) GetType() int {
27✔
2376
        return TransferTaskTypeSignalExecution
27✔
2377
}
27✔
2378

2379
// GetVersion returns the version of the signal transfer task
2380
func (u *SignalExecutionTask) GetVersion() int64 {
27✔
2381
        return u.Version
27✔
2382
}
27✔
2383

2384
// SetVersion returns the version of the signal transfer task
2385
func (u *SignalExecutionTask) SetVersion(version int64) {
×
2386
        u.Version = version
×
2387
}
×
2388

2389
// GetTaskID returns the sequence ID of the signal transfer task.
2390
func (u *SignalExecutionTask) GetTaskID() int64 {
15✔
2391
        return u.TaskID
15✔
2392
}
15✔
2393

2394
// SetTaskID sets the sequence ID of the signal transfer task.
2395
func (u *SignalExecutionTask) SetTaskID(id int64) {
15✔
2396
        u.TaskID = id
15✔
2397
}
15✔
2398

2399
// GetVisibilityTimestamp get the visibility timestamp
2400
func (u *SignalExecutionTask) GetVisibilityTimestamp() time.Time {
27✔
2401
        return u.VisibilityTimestamp
27✔
2402
}
27✔
2403

2404
// SetVisibilityTimestamp set the visibility timestamp
2405
func (u *SignalExecutionTask) SetVisibilityTimestamp(timestamp time.Time) {
15✔
2406
        u.VisibilityTimestamp = timestamp
15✔
2407
}
15✔
2408

2409
// GetType returns the type of the record child execution completed task
2410
func (u *RecordChildExecutionCompletedTask) GetType() int {
×
2411
        return TransferTaskTypeRecordChildExecutionCompleted
×
2412
}
×
2413

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

2419
// SetVersion returns the version of the signal transfer task
2420
func (u *RecordChildExecutionCompletedTask) SetVersion(version int64) {
×
2421
        u.Version = version
×
2422
}
×
2423

2424
// GetTaskID returns the sequence ID of the signal transfer task.
2425
func (u *RecordChildExecutionCompletedTask) GetTaskID() int64 {
×
2426
        return u.TaskID
×
2427
}
×
2428

2429
// SetTaskID sets the sequence ID of the signal transfer task.
2430
func (u *RecordChildExecutionCompletedTask) SetTaskID(id int64) {
×
2431
        u.TaskID = id
×
2432
}
×
2433

2434
// GetVisibilityTimestamp get the visibility timestamp
2435
func (u *RecordChildExecutionCompletedTask) GetVisibilityTimestamp() time.Time {
×
2436
        return u.VisibilityTimestamp
×
2437
}
×
2438

2439
// SetVisibilityTimestamp set the visibility timestamp
2440
func (u *RecordChildExecutionCompletedTask) SetVisibilityTimestamp(timestamp time.Time) {
×
2441
        u.VisibilityTimestamp = timestamp
×
2442
}
×
2443

2444
// GetType returns the type of the apply parent close policy task
2445
func (u *ApplyParentClosePolicyTask) GetType() int {
×
2446
        return TransferTaskTypeApplyParentClosePolicy
×
2447
}
×
2448

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

2454
// SetVersion returns the version of the cancel transfer task
2455
func (u *ApplyParentClosePolicyTask) SetVersion(version int64) {
×
2456
        u.Version = version
×
2457
}
×
2458

2459
// GetTaskID returns the sequence ID of the cancel transfer task.
2460
func (u *ApplyParentClosePolicyTask) GetTaskID() int64 {
×
2461
        return u.TaskID
×
2462
}
×
2463

2464
// SetTaskID sets the sequence ID of the cancel transfer task.
2465
func (u *ApplyParentClosePolicyTask) SetTaskID(id int64) {
×
2466
        u.TaskID = id
×
2467
}
×
2468

2469
// GetVisibilityTimestamp get the visibility timestamp
2470
func (u *ApplyParentClosePolicyTask) GetVisibilityTimestamp() time.Time {
×
2471
        return u.VisibilityTimestamp
×
2472
}
×
2473

2474
// SetVisibilityTimestamp set the visibility timestamp
2475
func (u *ApplyParentClosePolicyTask) SetVisibilityTimestamp(timestamp time.Time) {
×
2476
        u.VisibilityTimestamp = timestamp
×
2477
}
×
2478

2479
// GetType returns the type of the upsert search attributes transfer task
2480
func (u *UpsertWorkflowSearchAttributesTask) GetType() int {
18✔
2481
        return TransferTaskTypeUpsertWorkflowSearchAttributes
18✔
2482
}
18✔
2483

2484
// GetVersion returns the version of the upsert search attributes transfer task
2485
func (u *UpsertWorkflowSearchAttributesTask) GetVersion() int64 {
18✔
2486
        return u.Version
18✔
2487
}
18✔
2488

2489
// SetVersion returns the version of the upsert search attributes transfer task
2490
func (u *UpsertWorkflowSearchAttributesTask) SetVersion(version int64) {
×
2491
        u.Version = version
×
2492
}
×
2493

2494
// GetTaskID returns the sequence ID of the signal transfer task.
2495
func (u *UpsertWorkflowSearchAttributesTask) GetTaskID() int64 {
9✔
2496
        return u.TaskID
9✔
2497
}
9✔
2498

2499
// SetTaskID sets the sequence ID of the signal transfer task.
2500
func (u *UpsertWorkflowSearchAttributesTask) SetTaskID(id int64) {
9✔
2501
        u.TaskID = id
9✔
2502
}
9✔
2503

2504
// GetVisibilityTimestamp get the visibility timestamp
2505
func (u *UpsertWorkflowSearchAttributesTask) GetVisibilityTimestamp() time.Time {
18✔
2506
        return u.VisibilityTimestamp
18✔
2507
}
18✔
2508

2509
// SetVisibilityTimestamp set the visibility timestamp
2510
func (u *UpsertWorkflowSearchAttributesTask) SetVisibilityTimestamp(timestamp time.Time) {
9✔
2511
        u.VisibilityTimestamp = timestamp
9✔
2512
}
9✔
2513

2514
// GetType returns the type of the start child transfer task
2515
func (u *StartChildExecutionTask) GetType() int {
39✔
2516
        return TransferTaskTypeStartChildExecution
39✔
2517
}
39✔
2518

2519
// GetVersion returns the version of the start child transfer task
2520
func (u *StartChildExecutionTask) GetVersion() int64 {
36✔
2521
        return u.Version
36✔
2522
}
36✔
2523

2524
// SetVersion returns the version of the start child transfer task
2525
func (u *StartChildExecutionTask) SetVersion(version int64) {
×
2526
        u.Version = version
×
2527
}
×
2528

2529
// GetTaskID returns the sequence ID of the start child transfer task
2530
func (u *StartChildExecutionTask) GetTaskID() int64 {
21✔
2531
        return u.TaskID
21✔
2532
}
21✔
2533

2534
// SetTaskID sets the sequence ID of the start child transfer task
2535
func (u *StartChildExecutionTask) SetTaskID(id int64) {
21✔
2536
        u.TaskID = id
21✔
2537
}
21✔
2538

2539
// GetVisibilityTimestamp get the visibility timestamp
2540
func (u *StartChildExecutionTask) GetVisibilityTimestamp() time.Time {
39✔
2541
        return u.VisibilityTimestamp
39✔
2542
}
39✔
2543

2544
// SetVisibilityTimestamp set the visibility timestamp
2545
func (u *StartChildExecutionTask) SetVisibilityTimestamp(timestamp time.Time) {
21✔
2546
        u.VisibilityTimestamp = timestamp
21✔
2547
}
21✔
2548

2549
// GetType returns the type of the record workflow closed task
2550
func (u *RecordWorkflowClosedTask) GetType() int {
×
2551
        return TransferTaskTypeRecordWorkflowClosed
×
2552
}
×
2553

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

2559
// SetVersion returns the version of the record workflow closed task
2560
func (u *RecordWorkflowClosedTask) SetVersion(version int64) {
×
2561
        u.Version = version
×
2562
}
×
2563

2564
// GetTaskID returns the sequence ID of the record workflow closed task
2565
func (u *RecordWorkflowClosedTask) GetTaskID() int64 {
×
2566
        return u.TaskID
×
2567
}
×
2568

2569
// SetTaskID sets the sequence ID of the record workflow closed task
2570
func (u *RecordWorkflowClosedTask) SetTaskID(id int64) {
×
2571
        u.TaskID = id
×
2572
}
×
2573

2574
// GetVisibilityTimestamp get the visibility timestamp
2575
func (u *RecordWorkflowClosedTask) GetVisibilityTimestamp() time.Time {
×
2576
        return u.VisibilityTimestamp
×
2577
}
×
2578

2579
// SetVisibilityTimestamp set the visibility timestamp
2580
func (u *RecordWorkflowClosedTask) SetVisibilityTimestamp(timestamp time.Time) {
×
2581
        u.VisibilityTimestamp = timestamp
×
2582
}
×
2583

2584
// GetType returns of type of the cross-cluster start child task
2585
func (c *CrossClusterStartChildExecutionTask) GetType() int {
×
2586
        return CrossClusterTaskTypeStartChildExecution
×
2587
}
×
2588

2589
// GetType returns of type of the cross-cluster cancel task
2590
func (c *CrossClusterCancelExecutionTask) GetType() int {
×
2591
        return CrossClusterTaskTypeCancelExecution
×
2592
}
×
2593

2594
// GetType returns of type of the cross-cluster signal task
2595
func (c *CrossClusterSignalExecutionTask) GetType() int {
×
2596
        return CrossClusterTaskTypeSignalExecution
×
2597
}
×
2598

2599
// GetType returns of type of the cross-cluster record child workflow completion task
2600
func (c *CrossClusterRecordChildExecutionCompletedTask) GetType() int {
×
2601
        return CrossClusterTaskTypeRecordChildExeuctionCompleted
×
2602
}
×
2603

2604
// GetType returns of type of the cross-cluster cancel task
2605
func (c *CrossClusterApplyParentClosePolicyTask) GetType() int {
×
2606
        return CrossClusterTaskTypeApplyParentClosePolicy
×
2607
}
×
2608

2609
// GetType returns the type of the history replication task
2610
func (a *HistoryReplicationTask) GetType() int {
×
2611
        return ReplicationTaskTypeHistory
×
2612
}
×
2613

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

2619
// SetVersion returns the version of the history replication task
2620
func (a *HistoryReplicationTask) SetVersion(version int64) {
×
2621
        a.Version = version
×
2622
}
×
2623

2624
// GetTaskID returns the sequence ID of the history replication task
2625
func (a *HistoryReplicationTask) GetTaskID() int64 {
×
2626
        return a.TaskID
×
2627
}
×
2628

2629
// SetTaskID sets the sequence ID of the history replication task
2630
func (a *HistoryReplicationTask) SetTaskID(id int64) {
×
2631
        a.TaskID = id
×
2632
}
×
2633

2634
// GetVisibilityTimestamp get the visibility timestamp
2635
func (a *HistoryReplicationTask) GetVisibilityTimestamp() time.Time {
×
2636
        return a.VisibilityTimestamp
×
2637
}
×
2638

2639
// SetVisibilityTimestamp set the visibility timestamp
2640
func (a *HistoryReplicationTask) SetVisibilityTimestamp(timestamp time.Time) {
×
2641
        a.VisibilityTimestamp = timestamp
×
2642
}
×
2643

2644
// GetType returns the type of the history replication task
2645
func (a *SyncActivityTask) GetType() int {
×
2646
        return ReplicationTaskTypeSyncActivity
×
2647
}
×
2648

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

2654
// SetVersion returns the version of the history replication task
2655
func (a *SyncActivityTask) SetVersion(version int64) {
×
2656
        a.Version = version
×
2657
}
×
2658

2659
// GetTaskID returns the sequence ID of the history replication task
2660
func (a *SyncActivityTask) GetTaskID() int64 {
×
2661
        return a.TaskID
×
2662
}
×
2663

2664
// SetTaskID sets the sequence ID of the history replication task
2665
func (a *SyncActivityTask) SetTaskID(id int64) {
×
2666
        a.TaskID = id
×
2667
}
×
2668

2669
// GetVisibilityTimestamp get the visibility timestamp
2670
func (a *SyncActivityTask) GetVisibilityTimestamp() time.Time {
×
2671
        return a.VisibilityTimestamp
×
2672
}
×
2673

2674
// SetVisibilityTimestamp set the visibility timestamp
2675
func (a *SyncActivityTask) SetVisibilityTimestamp(timestamp time.Time) {
×
2676
        a.VisibilityTimestamp = timestamp
×
2677
}
×
2678

2679
// GetType returns the type of the history replication task
2680
func (a *FailoverMarkerTask) GetType() int {
×
2681
        return ReplicationTaskTypeFailoverMarker
×
2682
}
×
2683

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

2689
// SetVersion returns the version of the history replication task
2690
func (a *FailoverMarkerTask) SetVersion(version int64) {
×
2691
        a.Version = version
×
2692
}
×
2693

2694
// GetTaskID returns the sequence ID of the history replication task
2695
func (a *FailoverMarkerTask) GetTaskID() int64 {
×
2696
        return a.TaskID
×
2697
}
×
2698

2699
// SetTaskID sets the sequence ID of the history replication task
2700
func (a *FailoverMarkerTask) SetTaskID(id int64) {
×
2701
        a.TaskID = id
×
2702
}
×
2703

2704
// GetVisibilityTimestamp get the visibility timestamp
2705
func (a *FailoverMarkerTask) GetVisibilityTimestamp() time.Time {
×
2706
        return a.VisibilityTimestamp
×
2707
}
×
2708

2709
// SetVisibilityTimestamp set the visibility timestamp
2710
func (a *FailoverMarkerTask) SetVisibilityTimestamp(timestamp time.Time) {
×
2711
        a.VisibilityTimestamp = timestamp
×
2712
}
×
2713

2714
// GetTaskID returns the task ID for transfer task
2715
func (t *TransferTaskInfo) GetTaskID() int64 {
12,604✔
2716
        return t.TaskID
12,604✔
2717
}
12,604✔
2718

2719
// GetVersion returns the task version for transfer task
2720
func (t *TransferTaskInfo) GetVersion() int64 {
5,676✔
2721
        return t.Version
5,676✔
2722
}
5,676✔
2723

2724
// GetTaskType returns the task type for transfer task
2725
func (t *TransferTaskInfo) GetTaskType() int {
11,349✔
2726
        return t.TaskType
11,349✔
2727
}
11,349✔
2728

2729
// GetVisibilityTimestamp returns the task type for transfer task
2730
func (t *TransferTaskInfo) GetVisibilityTimestamp() time.Time {
8,570✔
2731
        return t.VisibilityTimestamp
8,570✔
2732
}
8,570✔
2733

2734
// GetWorkflowID returns the workflow ID for transfer task
2735
func (t *TransferTaskInfo) GetWorkflowID() string {
8,690✔
2736
        return t.WorkflowID
8,690✔
2737
}
8,690✔
2738

2739
// GetRunID returns the run ID for transfer task
2740
func (t *TransferTaskInfo) GetRunID() string {
8,690✔
2741
        return t.RunID
8,690✔
2742
}
8,690✔
2743

2744
// GetTargetDomainIDs returns the targetDomainIDs for applyParentPolicy
2745
func (t *TransferTaskInfo) GetTargetDomainIDs() map[string]struct{} {
×
2746
        return t.TargetDomainIDs
×
2747
}
×
2748

2749
// GetDomainID returns the domain ID for transfer task
2750
func (t *TransferTaskInfo) GetDomainID() string {
28,368✔
2751
        return t.DomainID
28,368✔
2752
}
28,368✔
2753

2754
// String returns a string representation for transfer task
2755
func (t *TransferTaskInfo) String() string {
8,675✔
2756
        return fmt.Sprintf("%#v", t)
8,675✔
2757
}
8,675✔
2758

2759
// GetTaskID returns the task ID for replication task
2760
func (t *ReplicationTaskInfo) GetTaskID() int64 {
3✔
2761
        return t.TaskID
3✔
2762
}
3✔
2763

2764
// GetVersion returns the task version for replication task
2765
func (t *ReplicationTaskInfo) GetVersion() int64 {
×
2766
        return t.Version
×
2767
}
×
2768

2769
// GetTaskType returns the task type for replication task
2770
func (t *ReplicationTaskInfo) GetTaskType() int {
3✔
2771
        return t.TaskType
3✔
2772
}
3✔
2773

2774
// GetVisibilityTimestamp returns the task type for replication task
2775
func (t *ReplicationTaskInfo) GetVisibilityTimestamp() time.Time {
×
2776
        return time.Time{}
×
2777
}
×
2778

2779
// GetWorkflowID returns the workflow ID for replication task
2780
func (t *ReplicationTaskInfo) GetWorkflowID() string {
3✔
2781
        return t.WorkflowID
3✔
2782
}
3✔
2783

2784
// GetRunID returns the run ID for replication task
2785
func (t *ReplicationTaskInfo) GetRunID() string {
3✔
2786
        return t.RunID
3✔
2787
}
3✔
2788

2789
// GetDomainID returns the domain ID for replication task
2790
func (t *ReplicationTaskInfo) GetDomainID() string {
3✔
2791
        return t.DomainID
3✔
2792
}
3✔
2793

2794
// GetTaskID returns the task ID for timer task
2795
func (t *TimerTaskInfo) GetTaskID() int64 {
4,773✔
2796
        return t.TaskID
4,773✔
2797
}
4,773✔
2798

2799
// GetVersion returns the task version for timer task
2800
func (t *TimerTaskInfo) GetVersion() int64 {
2,391✔
2801
        return t.Version
2,391✔
2802
}
2,391✔
2803

2804
// GetTaskType returns the task type for timer task
2805
func (t *TimerTaskInfo) GetTaskType() int {
4,773✔
2806
        return t.TaskType
4,773✔
2807
}
4,773✔
2808

2809
// GetVisibilityTimestamp returns the task type for timer task
2810
func (t *TimerTaskInfo) GetVisibilityTimestamp() time.Time {
13,398✔
2811
        return t.VisibilityTimestamp
13,398✔
2812
}
13,398✔
2813

2814
// GetWorkflowID returns the workflow ID for timer task
2815
func (t *TimerTaskInfo) GetWorkflowID() string {
4,774✔
2816
        return t.WorkflowID
4,774✔
2817
}
4,774✔
2818

2819
// GetRunID returns the run ID for timer task
2820
func (t *TimerTaskInfo) GetRunID() string {
4,774✔
2821
        return t.RunID
4,774✔
2822
}
4,774✔
2823

2824
// GetDomainID returns the domain ID for timer task
2825
func (t *TimerTaskInfo) GetDomainID() string {
11,929✔
2826
        return t.DomainID
11,929✔
2827
}
11,929✔
2828

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

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

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

2887
// DeserializeClusterConfigs creates an array of ClusterReplicationConfigs from an array of map representations
2888
func DeserializeClusterConfigs(replicationConfigs []map[string]interface{}) []*ClusterReplicationConfig {
1,573✔
2889
        deseriaizedReplicationConfigs := []*ClusterReplicationConfig{}
1,573✔
2890
        for index := range replicationConfigs {
2,826✔
2891
                deseriaizedReplicationConfig := &ClusterReplicationConfig{}
1,253✔
2892
                deseriaizedReplicationConfig.deserialize(replicationConfigs[index])
1,253✔
2893
                deseriaizedReplicationConfigs = append(deseriaizedReplicationConfigs, deseriaizedReplicationConfig)
1,253✔
2894
        }
1,253✔
2895

2896
        return deseriaizedReplicationConfigs
1,573✔
2897
}
2898

2899
func (config *ClusterReplicationConfig) serialize() map[string]interface{} {
17✔
2900
        output := make(map[string]interface{})
17✔
2901
        output["cluster_name"] = config.ClusterName
17✔
2902
        return output
17✔
2903
}
17✔
2904

2905
func (config *ClusterReplicationConfig) deserialize(input map[string]interface{}) {
1,253✔
2906
        config.ClusterName = input["cluster_name"].(string)
1,253✔
2907
}
1,253✔
2908

2909
// GetCopy return a copy of ClusterReplicationConfig
2910
func (config *ClusterReplicationConfig) GetCopy() *ClusterReplicationConfig {
2✔
2911
        res := *config
2✔
2912
        return &res
2✔
2913
}
2✔
2914

2915
// DBTimestampToUnixNano converts Milliseconds timestamp to UnixNano
2916
func DBTimestampToUnixNano(milliseconds int64) int64 {
3,389✔
2917
        return milliseconds * 1000 * 1000 // Milliseconds are 10⁻³, nanoseconds are 10⁻⁹, (-3) - (-9) = 6, so multiply by 10⁶
3,389✔
2918
}
3,389✔
2919

2920
// UnixNanoToDBTimestamp converts UnixNano to Milliseconds timestamp
2921
func UnixNanoToDBTimestamp(timestamp int64) int64 {
8,970✔
2922
        return timestamp / (1000 * 1000) // Milliseconds are 10⁻³, nanoseconds are 10⁻⁹, (-9) - (-3) = -6, so divide by 10⁶
8,970✔
2923
}
8,970✔
2924

2925
var internalThriftEncoder = codec.NewThriftRWEncoder()
2926

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

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

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

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

2976
// BuildHistoryGarbageCleanupInfo combine the workflow identity information into a string
2977
func BuildHistoryGarbageCleanupInfo(domainID, workflowID, runID string) string {
663✔
2978
        return fmt.Sprintf("%v:%v:%v", domainID, workflowID, runID)
663✔
2979
}
663✔
2980

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

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

3014
// IsTransientError checks if the error is a transient persistence error
3015
func IsTransientError(err error) bool {
15,326✔
3016
        switch err.(type) {
15,326✔
3017
        case *types.InternalServiceError, *types.ServiceBusyError, *TimeoutError:
3✔
3018
                return true
3✔
3019
        }
3020

3021
        return false
15,323✔
3022
}
3023

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

3031
        return false
×
3032
}
3033

3034
// HasMoreRowsToDelete checks if there is more data need to be deleted
3035
func HasMoreRowsToDelete(rowsDeleted, batchSize int) bool {
408✔
3036
        if rowsDeleted < batchSize || // all target tasks are deleted
408✔
3037
                rowsDeleted == UnknownNumRowsAffected || // underlying database does not support rows affected, so pageSize is not honored and all target tasks are deleted
408✔
3038
                rowsDeleted > batchSize { // pageSize is not honored and all tasks are deleted
816✔
3039
                return false
408✔
3040
        }
408✔
3041
        return true
×
3042
}
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