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

uber / cadence / 01875e2f-959c-4c4d-87af-1d7805759bcc

08 Apr 2023 12:26AM UTC coverage: 57.178% (+0.1%) from 57.072%
01875e2f-959c-4c4d-87af-1d7805759bcc

Pull #5197

buildkite

Steven L
bad cleanup -> good cleanup
Pull Request #5197: Demonstrate a way to get rid of the cadence-idl repo

85396 of 149351 relevant lines covered (57.18%)

2283.28 hits per line

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

87.16
/common/persistence/nosql/nosqlplugin/cassandra/workflowParsingUtils.go
1
// Copyright (c) 2021 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
package cassandra
23

24
import (
25
        "time"
26

27
        cql "github.com/gocql/gocql"
28

29
        "github.com/uber/cadence/common"
30
        "github.com/uber/cadence/common/checksum"
31
        "github.com/uber/cadence/common/persistence"
32
        "github.com/uber/cadence/common/persistence/nosql/nosqlplugin"
33
        "github.com/uber/cadence/common/persistence/nosql/nosqlplugin/cassandra/gocql"
34
        "github.com/uber/cadence/common/types"
35
)
36

37
var _emptyUUID = cql.UUID{}
38

39
func parseWorkflowExecutionInfo(
40
        result map[string]interface{},
41
) *persistence.InternalWorkflowExecutionInfo {
318✔
42

318✔
43
        info := &persistence.InternalWorkflowExecutionInfo{}
318✔
44
        var completionEventData []byte
318✔
45
        var completionEventEncoding common.EncodingType
318✔
46
        var autoResetPoints []byte
318✔
47
        var autoResetPointsEncoding common.EncodingType
318✔
48

318✔
49
        for k, v := range result {
19,022✔
50
                switch k {
18,704✔
51
                case "domain_id":
318✔
52
                        info.DomainID = v.(gocql.UUID).String()
318✔
53
                case "workflow_id":
318✔
54
                        info.WorkflowID = v.(string)
318✔
55
                case "run_id":
318✔
56
                        info.RunID = v.(gocql.UUID).String()
318✔
57
                case "first_run_id":
318✔
58
                        info.FirstExecutionRunID = v.(gocql.UUID).String()
318✔
59
                        if info.FirstExecutionRunID == _emptyUUID.String() {
390✔
60
                                // for backward compatibility, the gocql library doesn't handle the null uuid correectly https://github.com/gocql/gocql/blob/master/marshal.go#L1807
72✔
61
                                info.FirstExecutionRunID = ""
72✔
62
                        } else if info.FirstExecutionRunID == emptyRunID {
319✔
63
                                info.FirstExecutionRunID = ""
×
64
                        }
×
65
                case "parent_domain_id":
318✔
66
                        info.ParentDomainID = v.(gocql.UUID).String()
318✔
67
                        if info.ParentDomainID == emptyDomainID {
544✔
68
                                info.ParentDomainID = ""
226✔
69
                        }
226✔
70
                case "parent_workflow_id":
318✔
71
                        info.ParentWorkflowID = v.(string)
318✔
72
                case "parent_run_id":
318✔
73
                        info.ParentRunID = v.(gocql.UUID).String()
318✔
74
                        if info.ParentRunID == emptyRunID {
544✔
75
                                info.ParentRunID = ""
226✔
76
                        }
226✔
77
                case "initiated_id":
318✔
78
                        info.InitiatedID = v.(int64)
318✔
79
                case "completion_event_batch_id":
318✔
80
                        info.CompletionEventBatchID = v.(int64)
318✔
81
                case "completion_event":
318✔
82
                        completionEventData = v.([]byte)
318✔
83
                case "completion_event_data_encoding":
318✔
84
                        completionEventEncoding = common.EncodingType(v.(string))
318✔
85
                case "auto_reset_points":
318✔
86
                        autoResetPoints = v.([]byte)
318✔
87
                case "auto_reset_points_encoding":
318✔
88
                        autoResetPointsEncoding = common.EncodingType(v.(string))
318✔
89
                case "task_list":
318✔
90
                        info.TaskList = v.(string)
318✔
91
                case "workflow_type_name":
318✔
92
                        info.WorkflowTypeName = v.(string)
318✔
93
                case "workflow_timeout":
318✔
94
                        info.WorkflowTimeout = common.SecondsToDuration(int64(v.(int)))
318✔
95
                case "decision_task_timeout":
318✔
96
                        info.DecisionStartToCloseTimeout = common.SecondsToDuration(int64(v.(int)))
318✔
97
                case "execution_context":
318✔
98
                        info.ExecutionContext = v.([]byte)
318✔
99
                case "state":
318✔
100
                        info.State = v.(int)
318✔
101
                case "close_status":
318✔
102
                        info.CloseStatus = v.(int)
318✔
103
                case "last_first_event_id":
318✔
104
                        info.LastFirstEventID = v.(int64)
318✔
105
                case "last_event_task_id":
318✔
106
                        info.LastEventTaskID = v.(int64)
318✔
107
                case "next_event_id":
318✔
108
                        info.NextEventID = v.(int64)
318✔
109
                case "last_processed_event":
318✔
110
                        info.LastProcessedEvent = v.(int64)
318✔
111
                case "start_time":
318✔
112
                        info.StartTimestamp = v.(time.Time)
318✔
113
                case "last_updated_time":
318✔
114
                        info.LastUpdatedTimestamp = v.(time.Time)
318✔
115
                case "create_request_id":
318✔
116
                        info.CreateRequestID = v.(gocql.UUID).String()
318✔
117
                case "signal_count":
318✔
118
                        info.SignalCount = int32(v.(int))
318✔
119
                case "history_size":
318✔
120
                        info.HistorySize = v.(int64)
318✔
121
                case "decision_version":
318✔
122
                        info.DecisionVersion = v.(int64)
318✔
123
                case "decision_schedule_id":
318✔
124
                        info.DecisionScheduleID = v.(int64)
318✔
125
                case "decision_started_id":
318✔
126
                        info.DecisionStartedID = v.(int64)
318✔
127
                case "decision_request_id":
318✔
128
                        info.DecisionRequestID = v.(string)
318✔
129
                case "decision_timeout":
318✔
130
                        info.DecisionTimeout = common.SecondsToDuration(int64(v.(int)))
318✔
131
                case "decision_attempt":
318✔
132
                        info.DecisionAttempt = v.(int64)
318✔
133
                case "decision_timestamp":
318✔
134
                        info.DecisionStartedTimestamp = time.Unix(0, v.(int64))
318✔
135
                case "decision_scheduled_timestamp":
318✔
136
                        info.DecisionScheduledTimestamp = time.Unix(0, v.(int64))
318✔
137
                case "decision_original_scheduled_timestamp":
318✔
138
                        info.DecisionOriginalScheduledTimestamp = time.Unix(0, v.(int64))
318✔
139
                case "cancel_requested":
318✔
140
                        info.CancelRequested = v.(bool)
318✔
141
                case "cancel_request_id":
318✔
142
                        info.CancelRequestID = v.(string)
318✔
143
                case "sticky_task_list":
318✔
144
                        info.StickyTaskList = v.(string)
318✔
145
                case "sticky_schedule_to_start_timeout":
318✔
146
                        info.StickyScheduleToStartTimeout = common.SecondsToDuration(int64(v.(int)))
318✔
147
                case "client_library_version":
318✔
148
                        info.ClientLibraryVersion = v.(string)
318✔
149
                case "client_feature_version":
318✔
150
                        info.ClientFeatureVersion = v.(string)
318✔
151
                case "client_impl":
318✔
152
                        info.ClientImpl = v.(string)
318✔
153
                case "attempt":
318✔
154
                        info.Attempt = int32(v.(int))
318✔
155
                case "has_retry_policy":
318✔
156
                        info.HasRetryPolicy = v.(bool)
318✔
157
                case "init_interval":
318✔
158
                        info.InitialInterval = common.SecondsToDuration(int64(v.(int)))
318✔
159
                case "backoff_coefficient":
318✔
160
                        info.BackoffCoefficient = v.(float64)
318✔
161
                case "max_interval":
318✔
162
                        info.MaximumInterval = common.SecondsToDuration(int64(v.(int)))
318✔
163
                case "max_attempts":
318✔
164
                        info.MaximumAttempts = int32(v.(int))
318✔
165
                case "expiration_time":
318✔
166
                        info.ExpirationTime = v.(time.Time)
318✔
167
                case "non_retriable_errors":
318✔
168
                        info.NonRetriableErrors = v.([]string)
318✔
169
                case "branch_token":
318✔
170
                        info.BranchToken = v.([]byte)
318✔
171
                case "cron_schedule":
318✔
172
                        info.CronSchedule = v.(string)
318✔
173
                case "expiration_seconds":
318✔
174
                        info.ExpirationInterval = common.SecondsToDuration(int64(v.(int)))
318✔
175
                case "search_attributes":
318✔
176
                        info.SearchAttributes = v.(map[string][]byte)
318✔
177
                case "memo":
318✔
178
                        info.Memo = v.(map[string][]byte)
318✔
179
                }
180
        }
181
        info.CompletionEvent = persistence.NewDataBlob(completionEventData, completionEventEncoding)
318✔
182
        info.AutoResetPoints = persistence.NewDataBlob(autoResetPoints, autoResetPointsEncoding)
318✔
183
        return info
318✔
184
}
185

186
// TODO: remove this after all 2DC workflows complete
187
func parseReplicationState(
188
        result map[string]interface{},
189
) *persistence.ReplicationState {
247✔
190

247✔
191
        if len(result) == 0 {
494✔
192
                return nil
247✔
193
        }
247✔
194

195
        info := &persistence.ReplicationState{}
×
196
        for k, v := range result {
×
197
                switch k {
×
198
                case "current_version":
×
199
                        info.CurrentVersion = v.(int64)
×
200
                case "start_version":
×
201
                        info.StartVersion = v.(int64)
×
202
                case "last_write_version":
×
203
                        info.LastWriteVersion = v.(int64)
×
204
                case "last_write_event_id":
×
205
                        info.LastWriteEventID = v.(int64)
×
206
                case "last_replication_info":
×
207
                        info.LastReplicationInfo = make(map[string]*persistence.ReplicationInfo)
×
208
                        replicationInfoMap := v.(map[string]map[string]interface{})
×
209
                        for key, value := range replicationInfoMap {
×
210
                                info.LastReplicationInfo[key] = parseReplicationInfo(value)
×
211
                        }
×
212
                }
213
        }
214

215
        return info
×
216
}
217

218
func parseReplicationInfo(
219
        result map[string]interface{},
220
) *persistence.ReplicationInfo {
×
221

×
222
        info := &persistence.ReplicationInfo{}
×
223
        for k, v := range result {
×
224
                switch k {
×
225
                case "version":
×
226
                        info.Version = v.(int64)
×
227
                case "last_event_id":
×
228
                        info.LastEventID = v.(int64)
×
229
                }
230
        }
231

232
        return info
×
233
}
234

235
func parseActivityInfo(
236
        domainID string,
237
        result map[string]interface{},
238
) *persistence.InternalActivityInfo {
26✔
239

26✔
240
        info := &persistence.InternalActivityInfo{}
26✔
241
        var sharedEncoding common.EncodingType
26✔
242
        var scheduledEventData, startedEventData []byte
26✔
243
        for k, v := range result {
852✔
244
                switch k {
826✔
245
                case "version":
26✔
246
                        info.Version = v.(int64)
26✔
247
                case "schedule_id":
26✔
248
                        info.ScheduleID = v.(int64)
26✔
249
                case "scheduled_event_batch_id":
26✔
250
                        info.ScheduledEventBatchID = v.(int64)
26✔
251
                case "scheduled_event":
26✔
252
                        scheduledEventData = v.([]byte)
26✔
253
                case "scheduled_time":
26✔
254
                        info.ScheduledTime = v.(time.Time)
26✔
255
                case "started_id":
26✔
256
                        info.StartedID = v.(int64)
26✔
257
                case "started_event":
26✔
258
                        startedEventData = v.([]byte)
26✔
259
                case "started_time":
26✔
260
                        info.StartedTime = v.(time.Time)
26✔
261
                case "activity_id":
26✔
262
                        info.ActivityID = v.(string)
26✔
263
                case "request_id":
26✔
264
                        info.RequestID = v.(string)
26✔
265
                case "details":
26✔
266
                        info.Details = v.([]byte)
26✔
267
                case "schedule_to_start_timeout":
26✔
268
                        info.ScheduleToStartTimeout = common.SecondsToDuration(int64(v.(int)))
26✔
269
                case "schedule_to_close_timeout":
26✔
270
                        info.ScheduleToCloseTimeout = common.SecondsToDuration(int64(v.(int)))
26✔
271
                case "start_to_close_timeout":
26✔
272
                        info.StartToCloseTimeout = common.SecondsToDuration(int64(v.(int)))
26✔
273
                case "heart_beat_timeout":
26✔
274
                        info.HeartbeatTimeout = common.SecondsToDuration(int64(v.(int)))
26✔
275
                case "cancel_requested":
26✔
276
                        info.CancelRequested = v.(bool)
26✔
277
                case "cancel_request_id":
26✔
278
                        info.CancelRequestID = v.(int64)
26✔
279
                case "last_hb_updated_time":
26✔
280
                        info.LastHeartBeatUpdatedTime = v.(time.Time)
26✔
281
                case "timer_task_status":
26✔
282
                        info.TimerTaskStatus = int32(v.(int))
26✔
283
                case "attempt":
26✔
284
                        info.Attempt = int32(v.(int))
26✔
285
                case "task_list":
26✔
286
                        info.TaskList = v.(string)
26✔
287
                case "started_identity":
26✔
288
                        info.StartedIdentity = v.(string)
26✔
289
                case "has_retry_policy":
26✔
290
                        info.HasRetryPolicy = v.(bool)
26✔
291
                case "init_interval":
26✔
292
                        info.InitialInterval = common.SecondsToDuration(int64(v.(int)))
26✔
293
                case "backoff_coefficient":
26✔
294
                        info.BackoffCoefficient = v.(float64)
26✔
295
                case "max_interval":
26✔
296
                        info.MaximumInterval = common.SecondsToDuration(int64(v.(int)))
26✔
297
                case "max_attempts":
26✔
298
                        info.MaximumAttempts = (int32)(v.(int))
26✔
299
                case "expiration_time":
26✔
300
                        info.ExpirationTime = v.(time.Time)
26✔
301
                case "non_retriable_errors":
26✔
302
                        info.NonRetriableErrors = v.([]string)
26✔
303
                case "last_failure_reason":
26✔
304
                        info.LastFailureReason = v.(string)
26✔
305
                case "last_worker_identity":
26✔
306
                        info.LastWorkerIdentity = v.(string)
26✔
307
                case "last_failure_details":
26✔
308
                        info.LastFailureDetails = v.([]byte)
26✔
309
                case "event_data_encoding":
26✔
310
                        sharedEncoding = common.EncodingType(v.(string))
26✔
311
                }
312
        }
313
        info.DomainID = domainID
26✔
314
        info.ScheduledEvent = persistence.NewDataBlob(scheduledEventData, sharedEncoding)
26✔
315
        info.StartedEvent = persistence.NewDataBlob(startedEventData, sharedEncoding)
26✔
316

26✔
317
        return info
26✔
318
}
319

320
func parseTimerInfo(
321
        result map[string]interface{},
322
) *persistence.TimerInfo {
1✔
323

1✔
324
        info := &persistence.TimerInfo{}
1✔
325
        for k, v := range result {
2✔
326
                switch k {
1✔
327
                case "version":
1✔
328
                        info.Version = v.(int64)
1✔
329
                case "timer_id":
1✔
330
                        info.TimerID = v.(string)
1✔
331
                case "started_id":
1✔
332
                        info.StartedID = v.(int64)
1✔
333
                case "expiry_time":
1✔
334
                        info.ExpiryTime = v.(time.Time)
1✔
335
                case "task_id":
1✔
336
                        // task_id is a misleading variable, it actually serves
1✔
337
                        // the purpose of indicating whether a timer task is
1✔
338
                        // generated for this timer info
1✔
339
                        info.TaskStatus = v.(int64)
1✔
340
                }
341
        }
342
        return info
1✔
343
}
344

345
func parseChildExecutionInfo(
346
        result map[string]interface{},
347
) *persistence.InternalChildExecutionInfo {
2✔
348

2✔
349
        info := &persistence.InternalChildExecutionInfo{}
2✔
350
        var encoding common.EncodingType
2✔
351
        var initiatedData []byte
2✔
352
        var startedData []byte
2✔
353
        for k, v := range result {
17✔
354
                switch k {
15✔
355
                case "version":
2✔
356
                        info.Version = v.(int64)
2✔
357
                case "initiated_id":
2✔
358
                        info.InitiatedID = v.(int64)
2✔
359
                case "initiated_event_batch_id":
2✔
360
                        info.InitiatedEventBatchID = v.(int64)
2✔
361
                case "initiated_event":
2✔
362
                        initiatedData = v.([]byte)
2✔
363
                case "started_id":
2✔
364
                        info.StartedID = v.(int64)
2✔
365
                case "started_workflow_id":
2✔
366
                        info.StartedWorkflowID = v.(string)
2✔
367
                case "started_run_id":
2✔
368
                        info.StartedRunID = v.(gocql.UUID).String()
2✔
369
                case "started_event":
2✔
370
                        startedData = v.([]byte)
2✔
371
                case "create_request_id":
2✔
372
                        info.CreateRequestID = v.(gocql.UUID).String()
2✔
373
                case "event_data_encoding":
2✔
374
                        encoding = common.EncodingType(v.(string))
2✔
375
                case "domain_id":
2✔
376
                        info.DomainID = v.(gocql.UUID).String()
2✔
377
                        if info.DomainID == _emptyUUID.String() {
2✔
378
                                // for backward compatibility, the gocql library doesn't handle the null uuid correectly https://github.com/gocql/gocql/blob/master/marshal.go#L1807
×
379
                                info.DomainID = ""
×
380
                        }
×
381
                case "domain_name":
2✔
382
                        info.DomainNameDEPRECATED = v.(string)
2✔
383
                case "workflow_type_name":
2✔
384
                        info.WorkflowTypeName = v.(string)
2✔
385
                case "parent_close_policy":
2✔
386
                        info.ParentClosePolicy = types.ParentClosePolicy(v.(int))
2✔
387
                }
388
        }
389
        info.InitiatedEvent = persistence.NewDataBlob(initiatedData, encoding)
2✔
390
        info.StartedEvent = persistence.NewDataBlob(startedData, encoding)
2✔
391
        return info
2✔
392
}
393

394
func parseRequestCancelInfo(
395
        result map[string]interface{},
396
) *persistence.RequestCancelInfo {
×
397

×
398
        info := &persistence.RequestCancelInfo{}
×
399
        for k, v := range result {
×
400
                switch k {
×
401
                case "version":
×
402
                        info.Version = v.(int64)
×
403
                case "initiated_id":
×
404
                        info.InitiatedID = v.(int64)
×
405
                case "initiated_event_batch_id":
×
406
                        info.InitiatedEventBatchID = v.(int64)
×
407
                case "cancel_request_id":
×
408
                        info.CancelRequestID = v.(string)
×
409
                }
410
        }
411

412
        return info
×
413
}
414

415
func parseSignalInfo(
416
        result map[string]interface{},
417
) *persistence.SignalInfo {
1✔
418

1✔
419
        info := &persistence.SignalInfo{}
1✔
420
        for k, v := range result {
2✔
421
                switch k {
1✔
422
                case "version":
1✔
423
                        info.Version = v.(int64)
1✔
424
                case "initiated_id":
1✔
425
                        info.InitiatedID = v.(int64)
1✔
426
                case "initiated_event_batch_id":
1✔
427
                        info.InitiatedEventBatchID = v.(int64)
1✔
428
                case "signal_request_id":
1✔
429
                        info.SignalRequestID = v.(gocql.UUID).String()
1✔
430
                case "signal_name":
1✔
431
                        info.SignalName = v.(string)
1✔
432
                case "input":
1✔
433
                        info.Input = v.([]byte)
1✔
434
                case "control":
1✔
435
                        info.Control = v.([]byte)
1✔
436
                }
437
        }
438

439
        return info
1✔
440
}
441

442
func parseHistoryEventBatchBlob(
443
        result map[string]interface{},
444
) *persistence.DataBlob {
1✔
445

1✔
446
        eventBatch := &persistence.DataBlob{Encoding: common.EncodingTypeJSON}
1✔
447
        for k, v := range result {
4✔
448
                switch k {
3✔
449
                case "encoding_type":
1✔
450
                        eventBatch.Encoding = common.EncodingType(v.(string))
1✔
451
                case "data":
1✔
452
                        eventBatch.Data = v.([]byte)
1✔
453
                }
454
        }
455

456
        return eventBatch
1✔
457
}
458

459
func parseTimerTaskInfo(
460
        result map[string]interface{},
461
) *persistence.TimerTaskInfo {
2,679✔
462

2,679✔
463
        info := &persistence.TimerTaskInfo{}
2,679✔
464
        for k, v := range result {
29,460✔
465
                switch k {
26,781✔
466
                case "domain_id":
2,679✔
467
                        info.DomainID = v.(gocql.UUID).String()
2,679✔
468
                case "workflow_id":
2,679✔
469
                        info.WorkflowID = v.(string)
2,679✔
470
                case "run_id":
2,679✔
471
                        info.RunID = v.(gocql.UUID).String()
2,679✔
472
                case "visibility_ts":
2,679✔
473
                        info.VisibilityTimestamp = v.(time.Time)
2,679✔
474
                case "task_id":
2,679✔
475
                        info.TaskID = v.(int64)
2,679✔
476
                case "type":
2,679✔
477
                        info.TaskType = v.(int)
2,679✔
478
                case "timeout_type":
2,679✔
479
                        info.TimeoutType = v.(int)
2,679✔
480
                case "event_id":
2,679✔
481
                        info.EventID = v.(int64)
2,679✔
482
                case "schedule_attempt":
2,679✔
483
                        info.ScheduleAttempt = v.(int64)
2,679✔
484
                case "version":
2,679✔
485
                        info.Version = v.(int64)
2,679✔
486
                }
487
        }
488

489
        return info
2,679✔
490
}
491

492
func parseTransferTaskInfo(
493
        result map[string]interface{},
494
) *persistence.TransferTaskInfo {
1,839✔
495

1,839✔
496
        info := &persistence.TransferTaskInfo{}
1,839✔
497
        for k, v := range result {
29,410✔
498
                switch k {
27,571✔
499
                case "domain_id":
1,839✔
500
                        info.DomainID = v.(gocql.UUID).String()
1,839✔
501
                case "workflow_id":
1,839✔
502
                        info.WorkflowID = v.(string)
1,839✔
503
                case "run_id":
1,839✔
504
                        info.RunID = v.(gocql.UUID).String()
1,839✔
505
                case "visibility_ts":
1,839✔
506
                        info.VisibilityTimestamp = v.(time.Time)
1,839✔
507
                case "task_id":
1,839✔
508
                        info.TaskID = v.(int64)
1,839✔
509
                case "target_domain_id":
1,839✔
510
                        info.TargetDomainID = v.(gocql.UUID).String()
1,839✔
511
                case "target_domain_ids":
1,839✔
512
                        targetDomainIDs := make(map[string]struct{})
1,839✔
513
                        dList := mustConvertToSlice(result["target_domain_ids"])
1,839✔
514
                        for _, v := range dList {
1,839✔
515
                                targetDomainIDs[v.(gocql.UUID).String()] = struct{}{}
×
516
                        }
×
517
                        info.TargetDomainIDs = targetDomainIDs
1,839✔
518
                case "target_workflow_id":
1,839✔
519
                        info.TargetWorkflowID = v.(string)
1,839✔
520
                case "target_run_id":
1,839✔
521
                        info.TargetRunID = v.(gocql.UUID).String()
1,839✔
522
                        if info.TargetRunID == persistence.TransferTaskTransferTargetRunID {
3,668✔
523
                                info.TargetRunID = ""
1,829✔
524
                        }
1,829✔
525
                case "target_child_workflow_only":
1,839✔
526
                        info.TargetChildWorkflowOnly = v.(bool)
1,839✔
527
                case "task_list":
1,839✔
528
                        info.TaskList = v.(string)
1,839✔
529
                case "type":
1,839✔
530
                        info.TaskType = v.(int)
1,839✔
531
                case "schedule_id":
1,839✔
532
                        info.ScheduleID = v.(int64)
1,839✔
533
                case "record_visibility":
1,839✔
534
                        info.RecordVisibility = v.(bool)
1,839✔
535
                case "version":
1,839✔
536
                        info.Version = v.(int64)
1,839✔
537
                }
538
        }
539

540
        return info
1,839✔
541
}
542

543
func parseCrossClusterTaskInfo(
544
        result map[string]interface{},
545
) *persistence.CrossClusterTaskInfo {
×
546
        info := (*persistence.CrossClusterTaskInfo)(parseTransferTaskInfo(result))
×
547
        if persistence.CrossClusterTaskDefaultTargetRunID == persistence.TransferTaskTransferTargetRunID {
×
548
                return info
×
549
        }
×
550

551
        // incase CrossClusterTaskDefaultTargetRunID is updated and not equal to TransferTaskTransferTargetRunID
552
        if v, ok := result["target_run_id"]; ok {
×
553
                info.TargetRunID = v.(gocql.UUID).String()
×
554
                if info.TargetRunID == persistence.CrossClusterTaskDefaultTargetRunID {
×
555
                        info.TargetRunID = ""
×
556
                }
×
557
        }
558
        return info
×
559
}
560

561
func parseReplicationTaskInfo(
562
        result map[string]interface{},
563
) *nosqlplugin.ReplicationTask {
1✔
564

1✔
565
        info := &persistence.InternalReplicationTaskInfo{}
1✔
566
        for k, v := range result {
2✔
567
                switch k {
1✔
568
                case "domain_id":
1✔
569
                        info.DomainID = v.(gocql.UUID).String()
1✔
570
                case "workflow_id":
1✔
571
                        info.WorkflowID = v.(string)
1✔
572
                case "run_id":
1✔
573
                        info.RunID = v.(gocql.UUID).String()
1✔
574
                case "task_id":
1✔
575
                        info.TaskID = v.(int64)
1✔
576
                case "type":
1✔
577
                        info.TaskType = v.(int)
1✔
578
                case "first_event_id":
1✔
579
                        info.FirstEventID = v.(int64)
1✔
580
                case "next_event_id":
1✔
581
                        info.NextEventID = v.(int64)
1✔
582
                case "version":
1✔
583
                        info.Version = v.(int64)
1✔
584
                case "scheduled_id":
1✔
585
                        info.ScheduledID = v.(int64)
1✔
586
                case "branch_token":
1✔
587
                        info.BranchToken = v.([]byte)
1✔
588
                case "new_run_branch_token":
1✔
589
                        info.NewRunBranchToken = v.([]byte)
1✔
590
                case "created_time":
1✔
591
                        info.CreationTime = time.Unix(0, v.(int64))
1✔
592
                }
593
        }
594

595
        return info
1✔
596
}
597

598
func parseChecksum(result map[string]interface{}) checksum.Checksum {
247✔
599
        csum := checksum.Checksum{}
247✔
600
        if len(result) == 0 {
247✔
601
                return csum
×
602
        }
×
603
        for k, v := range result {
986✔
604
                switch k {
739✔
605
                case "flavor":
247✔
606
                        csum.Flavor = checksum.Flavor(v.(int))
247✔
607
                case "version":
247✔
608
                        csum.Version = v.(int)
247✔
609
                case "value":
247✔
610
                        csum.Value = v.([]byte)
247✔
611
                }
612
        }
613
        return csum
247✔
614
}
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

© 2025 Coveralls, Inc