/
dataInterfaces.go
958 lines (823 loc) · 26.6 KB
/
dataInterfaces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
// Copyright (c) 2017 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package persistence
import (
"fmt"
"time"
workflow "github.com/uber/cadence/.gen/go/shared"
"github.com/uber/cadence/common"
)
// Domain status
const (
DomainStatusRegistered = iota
DomainStatusDeprecated
DomainStatusDeleted
)
// Workflow execution states
const (
WorkflowStateCreated = iota
WorkflowStateRunning
WorkflowStateCompleted
)
// Workflow execution close status
const (
WorkflowCloseStatusNone = iota
WorkflowCloseStatusCompleted
WorkflowCloseStatusFailed
WorkflowCloseStatusCanceled
WorkflowCloseStatusTerminated
WorkflowCloseStatusContinuedAsNew
WorkflowCloseStatusTimedOut
)
// Types of task lists
const (
TaskListTypeDecision = iota
TaskListTypeActivity
)
// Transfer task types
const (
TransferTaskTypeDecisionTask = iota
TransferTaskTypeActivityTask
TransferTaskTypeCloseExecution
TransferTaskTypeCancelExecution
TransferTaskTypeStartChildExecution
)
// Types of timers
const (
TaskTypeDecisionTimeout = iota
TaskTypeActivityTimeout
TaskTypeUserTimer
TaskTypeWorkflowTimeout
TaskTypeDeleteHistoryEvent
)
type (
// ConditionFailedError represents a failed conditional put
ConditionFailedError struct {
Msg string
}
// ShardAlreadyExistError is returned when conditionally creating a shard fails
ShardAlreadyExistError struct {
Msg string
}
// ShardOwnershipLostError is returned when conditional update fails due to RangeID for the shard
ShardOwnershipLostError struct {
ShardID int
Msg string
}
// WorkflowExecutionAlreadyStartedError is returned when creating a new workflow failed.
WorkflowExecutionAlreadyStartedError struct {
Msg string
StartRequestID string
RunID string
State int
CloseStatus int
}
// TimeoutError is returned when a write operation fails due to a timeout
TimeoutError struct {
Msg string
}
// ShardInfo describes a shard
ShardInfo struct {
ShardID int
Owner string
RangeID int64
StolenSinceRenew int
UpdatedAt time.Time
TransferAckLevel int64
TimerAckLevel time.Time
}
// WorkflowExecutionInfo describes a workflow execution
WorkflowExecutionInfo struct {
DomainID string
WorkflowID string
RunID string
ParentDomainID string
ParentWorkflowID string
ParentRunID string
InitiatedID int64
CompletionEvent []byte
TaskList string
WorkflowTypeName string
WorkflowTimeout int32
DecisionTimeoutValue int32
ExecutionContext []byte
State int
CloseStatus int
LastFirstEventID int64
NextEventID int64
LastProcessedEvent int64
StartTimestamp time.Time
LastUpdatedTimestamp time.Time
CreateRequestID string
DecisionScheduleID int64
DecisionStartedID int64
DecisionRequestID string
DecisionTimeout int32
DecisionAttempt int64
DecisionTimestamp int64
CancelRequested bool
CancelRequestID string
StickyTaskList string
StickyScheduleToStartTimeout int32
ClientLibraryVersion string
ClientFeatureVersion string
ClientImpl string
}
// TransferTaskInfo describes a transfer task
TransferTaskInfo struct {
DomainID string
WorkflowID string
RunID string
TaskID int64
TargetDomainID string
TargetWorkflowID string
TargetRunID string
TaskList string
TaskType int
ScheduleID int64
}
// TimerTaskInfo describes a timer task.
TimerTaskInfo struct {
DomainID string
WorkflowID string
RunID string
VisibilityTimestamp time.Time
TaskID int64
TaskType int
TimeoutType int
EventID int64
ScheduleAttempt int64
}
// TaskListInfo describes a state of a task list implementation.
TaskListInfo struct {
DomainID string
Name string
TaskType int
RangeID int64
AckLevel int64
}
// TaskInfo describes either activity or decision task
TaskInfo struct {
DomainID string
WorkflowID string
RunID string
TaskID int64
ScheduleID int64
ScheduleToStartTimeout int32
}
// Task is the generic interface for workflow tasks
Task interface {
GetType() int
GetTaskID() int64
SetTaskID(id int64)
}
// ActivityTask identifies a transfer task for activity
ActivityTask struct {
TaskID int64
DomainID string
TaskList string
ScheduleID int64
}
// DecisionTask identifies a transfer task for decision
DecisionTask struct {
TaskID int64
DomainID string
TaskList string
ScheduleID int64
}
// CloseExecutionTask identifies a transfer task for deletion of execution
CloseExecutionTask struct {
TaskID int64
}
// DeleteHistoryEventTask identifies a timer task for deletion of history events of completed execution.
DeleteHistoryEventTask struct {
VisibilityTimestamp time.Time
TaskID int64
}
// DecisionTimeoutTask identifies a timeout task.
DecisionTimeoutTask struct {
VisibilityTimestamp time.Time
TaskID int64
EventID int64
ScheduleAttempt int64
TimeoutType int
}
// WorkflowTimeoutTask identifies a timeout task.
WorkflowTimeoutTask struct {
VisibilityTimestamp time.Time
TaskID int64
}
// CancelExecutionTask identifies a transfer task for cancel of execution
CancelExecutionTask struct {
TaskID int64
TargetDomainID string
TargetWorkflowID string
TargetRunID string
ScheduleID int64
}
// StartChildExecutionTask identifies a transfer task for starting child execution
StartChildExecutionTask struct {
TaskID int64
TargetDomainID string
TargetWorkflowID string
InitiatedID int64
}
// ActivityTimeoutTask identifies a timeout task.
ActivityTimeoutTask struct {
VisibilityTimestamp time.Time
TaskID int64
TimeoutType int
EventID int64
}
// UserTimerTask identifies a timeout task.
UserTimerTask struct {
VisibilityTimestamp time.Time
TaskID int64
EventID int64
}
// WorkflowMutableState indicates workflow related state
WorkflowMutableState struct {
ActivitInfos map[int64]*ActivityInfo
TimerInfos map[string]*TimerInfo
ChildExecutionInfos map[int64]*ChildExecutionInfo
RequestCancelInfos map[int64]*RequestCancelInfo
ExecutionInfo *WorkflowExecutionInfo
BufferedEvents []*SerializedHistoryEventBatch
}
// ActivityInfo details.
ActivityInfo struct {
ScheduleID int64
ScheduledEvent []byte
ScheduledTime time.Time
StartedID int64
StartedEvent []byte
StartedTime time.Time
ActivityID string
RequestID string
Details []byte
ScheduleToStartTimeout int32
ScheduleToCloseTimeout int32
StartToCloseTimeout int32
HeartbeatTimeout int32
CancelRequested bool
CancelRequestID int64
LastHeartBeatUpdatedTime time.Time
TimerTaskStatus int32
}
// TimerInfo details - metadata about user timer info.
TimerInfo struct {
TimerID string
StartedID int64
ExpiryTime time.Time
TaskID int64
}
// ChildExecutionInfo has details for pending child executions.
ChildExecutionInfo struct {
InitiatedID int64
InitiatedEvent []byte
StartedID int64
StartedEvent []byte
CreateRequestID string
}
// RequestCancelInfo has details for pending external workflow cancellations
RequestCancelInfo struct {
InitiatedID int64
CancelRequestID string
}
// CreateShardRequest is used to create a shard in executions table
CreateShardRequest struct {
ShardInfo *ShardInfo
}
// GetShardRequest is used to get shard information
GetShardRequest struct {
ShardID int
}
// GetShardResponse is the response to GetShard
GetShardResponse struct {
ShardInfo *ShardInfo
}
// UpdateShardRequest is used to update shard information
UpdateShardRequest struct {
ShardInfo *ShardInfo
PreviousRangeID int64
}
// CreateWorkflowExecutionRequest is used to write a new workflow execution
CreateWorkflowExecutionRequest struct {
RequestID string
DomainID string
Execution workflow.WorkflowExecution
ParentDomainID string
ParentExecution *workflow.WorkflowExecution
InitiatedID int64
TaskList string
WorkflowTypeName string
WorkflowTimeout int32
DecisionTimeoutValue int32
ExecutionContext []byte
NextEventID int64
LastProcessedEvent int64
TransferTasks []Task
TimerTasks []Task
RangeID int64
DecisionScheduleID int64
DecisionStartedID int64
DecisionStartToCloseTimeout int32
ContinueAsNew bool
PreviousRunID string
ExecutionInfo *WorkflowExecutionInfo
}
// CreateWorkflowExecutionResponse is the response to CreateWorkflowExecutionRequest
CreateWorkflowExecutionResponse struct {
TaskID string
}
// GetWorkflowExecutionRequest is used to retrieve the info of a workflow execution
GetWorkflowExecutionRequest struct {
DomainID string
Execution workflow.WorkflowExecution
}
// GetWorkflowExecutionResponse is the response to GetworkflowExecutionRequest
GetWorkflowExecutionResponse struct {
State *WorkflowMutableState
}
// GetCurrentExecutionRequest is used to retrieve the current RunId for an execution
GetCurrentExecutionRequest struct {
DomainID string
WorkflowID string
}
// GetCurrentExecutionResponse is the response to GetCurrentExecution
GetCurrentExecutionResponse struct {
StartRequestID string
RunID string
State int
CloseStatus int
}
// UpdateWorkflowExecutionRequest is used to update a workflow execution
UpdateWorkflowExecutionRequest struct {
ExecutionInfo *WorkflowExecutionInfo
TransferTasks []Task
TimerTasks []Task
DeleteTimerTask Task
Condition int64
RangeID int64
ContinueAsNew *CreateWorkflowExecutionRequest
FinishExecution bool
FinishedExecutionTTL int32
// Mutable state
UpsertActivityInfos []*ActivityInfo
DeleteActivityInfo *int64
UpserTimerInfos []*TimerInfo
DeleteTimerInfos []string
UpsertChildExecutionInfos []*ChildExecutionInfo
DeleteChildExecutionInfo *int64
UpsertRequestCancelInfos []*RequestCancelInfo
DeleteRequestCancelInfo *int64
NewBufferedEvents *SerializedHistoryEventBatch
ClearBufferedEvents bool
}
// DeleteWorkflowExecutionRequest is used to delete a workflow execution
DeleteWorkflowExecutionRequest struct {
DomainID string
WorkflowID string
RunID string
}
// GetTransferTasksRequest is used to read tasks from the transfer task queue
GetTransferTasksRequest struct {
ReadLevel int64
MaxReadLevel int64
BatchSize int
}
// GetTransferTasksResponse is the response to GetTransferTasksRequest
GetTransferTasksResponse struct {
Tasks []*TransferTaskInfo
}
// CompleteTransferTaskRequest is used to complete a task in the transfer task queue
CompleteTransferTaskRequest struct {
TaskID int64
}
// CompleteTimerTaskRequest is used to complete a task in the timer task queue
CompleteTimerTaskRequest struct {
VisibilityTimestamp time.Time
TaskID int64
}
// LeaseTaskListRequest is used to request lease of a task list
LeaseTaskListRequest struct {
DomainID string
TaskList string
TaskType int
}
// LeaseTaskListResponse is response to LeaseTaskListRequest
LeaseTaskListResponse struct {
TaskListInfo *TaskListInfo
}
// UpdateTaskListRequest is used to update task list implementation information
UpdateTaskListRequest struct {
TaskListInfo *TaskListInfo
}
// UpdateTaskListResponse is the response to UpdateTaskList
UpdateTaskListResponse struct {
}
// CreateTasksRequest is used to create a new task for a workflow exectution
CreateTasksRequest struct {
TaskListInfo *TaskListInfo
Tasks []*CreateTaskInfo
}
// CreateTaskInfo describes a task to be created in CreateTasksRequest
CreateTaskInfo struct {
Execution workflow.WorkflowExecution
Data *TaskInfo
TaskID int64
}
// CreateTasksResponse is the response to CreateTasksRequest
CreateTasksResponse struct {
}
// GetTasksRequest is used to retrieve tasks of a task list
GetTasksRequest struct {
DomainID string
TaskList string
TaskType int
ReadLevel int64
MaxReadLevel int64 // inclusive
BatchSize int
RangeID int64
}
// GetTasksResponse is the response to GetTasksRequests
GetTasksResponse struct {
Tasks []*TaskInfo
}
// CompleteTaskRequest is used to complete a task
CompleteTaskRequest struct {
TaskList *TaskListInfo
TaskID int64
}
// GetTimerIndexTasksRequest is the request for GetTimerIndexTasks
// TODO: replace this with an iterator that can configure min and max index.
GetTimerIndexTasksRequest struct {
MinTimestamp time.Time
MaxTimestamp time.Time
BatchSize int
}
// GetTimerIndexTasksResponse is the response for GetTimerIndexTasks
GetTimerIndexTasksResponse struct {
Timers []*TimerTaskInfo
}
// SerializedHistoryEventBatch represents a serialized batch of history events
SerializedHistoryEventBatch struct {
EncodingType common.EncodingType
Version int
Data []byte
}
// HistoryEventBatch represents a batch of history events
HistoryEventBatch struct {
Version int
Events []*workflow.HistoryEvent
}
// AppendHistoryEventsRequest is used to append new events to workflow execution history
AppendHistoryEventsRequest struct {
DomainID string
Execution workflow.WorkflowExecution
FirstEventID int64
RangeID int64
TransactionID int64
Events *SerializedHistoryEventBatch
Overwrite bool
}
// GetWorkflowExecutionHistoryRequest is used to retrieve history of a workflow execution
GetWorkflowExecutionHistoryRequest struct {
DomainID string
Execution workflow.WorkflowExecution
// Get the history events from FirstEventID. Inclusive.
FirstEventID int64
// Get the history events upto NextEventID. Not Inclusive.
NextEventID int64
// Maximum number of history append transactions per page
PageSize int
// Token to continue reading next page of history append transactions. Pass in empty slice for first page
NextPageToken []byte
}
// GetWorkflowExecutionHistoryResponse is the response to GetWorkflowExecutionHistoryRequest
GetWorkflowExecutionHistoryResponse struct {
// Slice of history append transaction batches
Events []SerializedHistoryEventBatch
// Token to read next page if there are more events beyond page size.
// Use this to set NextPageToken on GetworkflowExecutionHistoryRequest to read the next page.
NextPageToken []byte
}
// DeleteWorkflowExecutionHistoryRequest is used to delete workflow execution history
DeleteWorkflowExecutionHistoryRequest struct {
DomainID string
Execution workflow.WorkflowExecution
}
// DomainInfo describes the domain entity
DomainInfo struct {
ID string
Name string
Status int
Description string
OwnerEmail string
}
// DomainConfig describes the domain configuration
DomainConfig struct {
// NOTE: this retention is in days, not in seconds
Retention int32
EmitMetric bool
}
// CreateDomainRequest is used to create the domain
CreateDomainRequest struct {
Name string
Status int
Description string
OwnerEmail string
Retention int32
EmitMetric bool
}
// CreateDomainResponse is the response for CreateDomain
CreateDomainResponse struct {
ID string
}
// GetDomainRequest is used to read domain
GetDomainRequest struct {
ID string
Name string
}
// GetDomainResponse is the response for GetDomain
GetDomainResponse struct {
Info *DomainInfo
Config *DomainConfig
}
// UpdateDomainRequest is used to update domain
UpdateDomainRequest struct {
Info *DomainInfo
Config *DomainConfig
}
// DeleteDomainRequest is used to delete domain entry from domains table
DeleteDomainRequest struct {
ID string
}
// DeleteDomainByNameRequest is used to delete domain entry from domains_by_name table
DeleteDomainByNameRequest struct {
Name string
}
// Closeable is an interface for any entity that supports a close operation to release resources
Closeable interface {
Close()
}
// ShardManager is used to manage all shards
ShardManager interface {
Closeable
CreateShard(request *CreateShardRequest) error
GetShard(request *GetShardRequest) (*GetShardResponse, error)
UpdateShard(request *UpdateShardRequest) error
}
// ExecutionManager is used to manage workflow executions
ExecutionManager interface {
Closeable
CreateWorkflowExecution(request *CreateWorkflowExecutionRequest) (*CreateWorkflowExecutionResponse, error)
GetWorkflowExecution(request *GetWorkflowExecutionRequest) (*GetWorkflowExecutionResponse, error)
UpdateWorkflowExecution(request *UpdateWorkflowExecutionRequest) error
DeleteWorkflowExecution(request *DeleteWorkflowExecutionRequest) error
GetCurrentExecution(request *GetCurrentExecutionRequest) (*GetCurrentExecutionResponse, error)
GetTransferTasks(request *GetTransferTasksRequest) (*GetTransferTasksResponse, error)
CompleteTransferTask(request *CompleteTransferTaskRequest) error
// Timer related methods.
GetTimerIndexTasks(request *GetTimerIndexTasksRequest) (*GetTimerIndexTasksResponse, error)
CompleteTimerTask(request *CompleteTimerTaskRequest) error
}
// ExecutionManagerFactory creates an instance of ExecutionManager for a given shard
ExecutionManagerFactory interface {
Closeable
CreateExecutionManager(shardID int) (ExecutionManager, error)
}
// TaskManager is used to manage tasks
TaskManager interface {
Closeable
LeaseTaskList(request *LeaseTaskListRequest) (*LeaseTaskListResponse, error)
UpdateTaskList(request *UpdateTaskListRequest) (*UpdateTaskListResponse, error)
CreateTasks(request *CreateTasksRequest) (*CreateTasksResponse, error)
GetTasks(request *GetTasksRequest) (*GetTasksResponse, error)
CompleteTask(request *CompleteTaskRequest) error
}
// HistoryManager is used to manage Workflow Execution HistoryEventBatch
HistoryManager interface {
Closeable
AppendHistoryEvents(request *AppendHistoryEventsRequest) error
// GetWorkflowExecutionHistory retrieves the paginated list of history events for given execution
GetWorkflowExecutionHistory(request *GetWorkflowExecutionHistoryRequest) (*GetWorkflowExecutionHistoryResponse,
error)
DeleteWorkflowExecutionHistory(request *DeleteWorkflowExecutionHistoryRequest) error
}
// MetadataManager is used to manage metadata CRUD for various entities
MetadataManager interface {
Closeable
CreateDomain(request *CreateDomainRequest) (*CreateDomainResponse, error)
GetDomain(request *GetDomainRequest) (*GetDomainResponse, error)
UpdateDomain(request *UpdateDomainRequest) error
DeleteDomain(request *DeleteDomainRequest) error
DeleteDomainByName(request *DeleteDomainByNameRequest) error
}
)
func (e *ConditionFailedError) Error() string {
return e.Msg
}
func (e *ShardAlreadyExistError) Error() string {
return e.Msg
}
func (e *ShardOwnershipLostError) Error() string {
return e.Msg
}
func (e *WorkflowExecutionAlreadyStartedError) Error() string {
return e.Msg
}
func (e *TimeoutError) Error() string {
return e.Msg
}
// GetType returns the type of the activity task
func (a *ActivityTask) GetType() int {
return TransferTaskTypeActivityTask
}
// GetTaskID returns the sequence ID of the activity task
func (a *ActivityTask) GetTaskID() int64 {
return a.TaskID
}
// SetTaskID sets the sequence ID of the activity task
func (a *ActivityTask) SetTaskID(id int64) {
a.TaskID = id
}
// GetType returns the type of the decision task
func (d *DecisionTask) GetType() int {
return TransferTaskTypeDecisionTask
}
// GetTaskID returns the sequence ID of the decision task.
func (d *DecisionTask) GetTaskID() int64 {
return d.TaskID
}
// SetTaskID sets the sequence ID of the decision task
func (d *DecisionTask) SetTaskID(id int64) {
d.TaskID = id
}
// GetType returns the type of the close execution task
func (a *CloseExecutionTask) GetType() int {
return TransferTaskTypeCloseExecution
}
// GetTaskID returns the sequence ID of the close execution task
func (a *CloseExecutionTask) GetTaskID() int64 {
return a.TaskID
}
// SetTaskID sets the sequence ID of the close execution task
func (a *CloseExecutionTask) SetTaskID(id int64) {
a.TaskID = id
}
// GetType returns the type of the delete execution task
func (a *DeleteHistoryEventTask) GetType() int {
return TaskTypeDeleteHistoryEvent
}
// GetTaskID returns the sequence ID of the delete execution task
func (a *DeleteHistoryEventTask) GetTaskID() int64 {
return a.TaskID
}
// SetTaskID sets the sequence ID of the delete execution task
func (a *DeleteHistoryEventTask) SetTaskID(id int64) {
a.TaskID = id
}
// GetType returns the type of the timer task
func (d *DecisionTimeoutTask) GetType() int {
return TaskTypeDecisionTimeout
}
// GetTaskID returns the sequence ID.
func (d *DecisionTimeoutTask) GetTaskID() int64 {
return d.TaskID
}
// SetTaskID sets the sequence ID.
func (d *DecisionTimeoutTask) SetTaskID(id int64) {
d.TaskID = id
}
// GetVisibilityTimestamp gets the visibility time stamp
func (d *DecisionTimeoutTask) GetVisibilityTimestamp() time.Time {
return d.VisibilityTimestamp
}
// SetVisibilityTimestamp gets the visibility time stamp
func (d *DecisionTimeoutTask) SetVisibilityTimestamp(t time.Time) {
d.VisibilityTimestamp = t
}
// GetType returns the type of the timer task
func (a *ActivityTimeoutTask) GetType() int {
return TaskTypeActivityTimeout
}
// GetTaskID returns the sequence ID.
func (a *ActivityTimeoutTask) GetTaskID() int64 {
return a.TaskID
}
// SetTaskID sets the sequence ID.
func (a *ActivityTimeoutTask) SetTaskID(id int64) {
a.TaskID = id
}
// GetVisibilityTimestamp gets the visibility time stamp
func (a *ActivityTimeoutTask) GetVisibilityTimestamp() time.Time {
return a.VisibilityTimestamp
}
// SetVisibilityTimestamp gets the visibility time stamp
func (a *ActivityTimeoutTask) SetVisibilityTimestamp(t time.Time) {
a.VisibilityTimestamp = t
}
// GetType returns the type of the timer task
func (u *UserTimerTask) GetType() int {
return TaskTypeUserTimer
}
// GetTaskID returns the sequence ID of the timer task.
func (u *UserTimerTask) GetTaskID() int64 {
return u.TaskID
}
// SetTaskID sets the sequence ID of the timer task.
func (u *UserTimerTask) SetTaskID(id int64) {
u.TaskID = id
}
// GetVisibilityTimestamp gets the visibility time stamp
func (u *UserTimerTask) GetVisibilityTimestamp() time.Time {
return u.VisibilityTimestamp
}
// SetVisibilityTimestamp gets the visibility time stamp
func (u *UserTimerTask) SetVisibilityTimestamp(t time.Time) {
u.VisibilityTimestamp = t
}
// GetType returns the type of the timeout task.
func (u *WorkflowTimeoutTask) GetType() int {
return TaskTypeWorkflowTimeout
}
// GetTaskID returns the sequence ID of the cancel transfer task.
func (u *WorkflowTimeoutTask) GetTaskID() int64 {
return u.TaskID
}
// SetTaskID sets the sequence ID of the cancel transfer task.
func (u *WorkflowTimeoutTask) SetTaskID(id int64) {
u.TaskID = id
}
// GetVisibilityTimestamp gets the visibility time stamp
func (u *WorkflowTimeoutTask) GetVisibilityTimestamp() time.Time {
return u.VisibilityTimestamp
}
// SetVisibilityTimestamp gets the visibility time stamp
func (u *WorkflowTimeoutTask) SetVisibilityTimestamp(t time.Time) {
u.VisibilityTimestamp = t
}
// GetType returns the type of the cancel transfer task
func (u *CancelExecutionTask) GetType() int {
return TransferTaskTypeCancelExecution
}
// GetTaskID returns the sequence ID of the cancel transfer task.
func (u *CancelExecutionTask) GetTaskID() int64 {
return u.TaskID
}
// SetTaskID sets the sequence ID of the cancel transfer task.
func (u *CancelExecutionTask) SetTaskID(id int64) {
u.TaskID = id
}
// GetType returns the type of the cancel transfer task
func (u *StartChildExecutionTask) GetType() int {
return TransferTaskTypeStartChildExecution
}
// GetTaskID returns the sequence ID of the cancel transfer task.
func (u *StartChildExecutionTask) GetTaskID() int64 {
return u.TaskID
}
// SetTaskID sets the sequence ID of the cancel transfer task.
func (u *StartChildExecutionTask) SetTaskID(id int64) {
u.TaskID = id
}
// NewHistoryEventBatch returns a new instance of HistoryEventBatch
func NewHistoryEventBatch(version int, events []*workflow.HistoryEvent) *HistoryEventBatch {
return &HistoryEventBatch{
Version: version,
Events: events,
}
}
func (b *HistoryEventBatch) String() string {
return fmt.Sprint("[version:%v, events:%v]", b.Version, b.Events)
}
// NewSerializedHistoryEventBatch constructs and returns a new instance of of SerializedHistoryEventBatch
func NewSerializedHistoryEventBatch(data []byte, encoding common.EncodingType, version int) *SerializedHistoryEventBatch {
return &SerializedHistoryEventBatch{
EncodingType: encoding,
Version: version,
Data: data,
}
}
func (h *SerializedHistoryEventBatch) String() string {
return fmt.Sprintf("[encodingType:%v,historyVersion:%v,history:%v]",
h.EncodingType, h.Version, string(h.Data))
}