@@ -6,10 +6,15 @@ import (
6
6
"github.com/PeerDB-io/peer-flow/peerdbenv"
7
7
)
8
8
9
+ type (
10
+ ContextKey string
11
+ TaskQueueID string
12
+ )
13
+
9
14
const (
10
15
// Task Queues
11
- peerFlowTaskQueue = "peer-flow-task-queue"
12
- snapshotFlowTaskQueue = "snapshot-flow-task-queue"
16
+ PeerFlowTaskQueue TaskQueueID = "peer-flow-task-queue"
17
+ SnapshotFlowTaskQueue TaskQueueID = "snapshot-flow-task-queue"
13
18
14
19
// Queries
15
20
CDCFlowStateQuery = "q-cdc-flow-state"
@@ -22,42 +27,20 @@ const (
22
27
23
28
const MirrorNameSearchAttribute = "MirrorName"
24
29
25
- type (
26
- ContextKey string
27
- )
28
-
29
30
const (
30
31
FlowNameKey ContextKey = "flowName"
31
32
PartitionIDKey ContextKey = "partitionId"
32
33
DeploymentUIDKey ContextKey = "deploymentUid"
33
34
)
34
35
35
- type TaskQueueID int64
36
-
37
- const (
38
- PeerFlowTaskQueueID TaskQueueID = iota
39
- SnapshotFlowTaskQueueID TaskQueueID = iota
40
- )
41
-
42
36
const FetchAndChannelSize = 256 * 1024
43
37
44
- func GetPeerFlowTaskQueueName (taskQueueID TaskQueueID ) (string , error ) {
45
- switch taskQueueID {
46
- case PeerFlowTaskQueueID :
47
- return prependUIDToTaskQueueName (peerFlowTaskQueue ), nil
48
- case SnapshotFlowTaskQueueID :
49
- return prependUIDToTaskQueueName (snapshotFlowTaskQueue ), nil
50
- default :
51
- return "" , fmt .Errorf ("unknown task queue id %d" , taskQueueID )
52
- }
53
- }
54
-
55
- func prependUIDToTaskQueueName (taskQueueName string ) string {
38
+ func GetPeerFlowTaskQueueName (taskQueueID TaskQueueID ) string {
56
39
deploymentUID := peerdbenv .PeerDBDeploymentUID ()
57
40
if deploymentUID == "" {
58
- return taskQueueName
41
+ return string ( taskQueueID )
59
42
}
60
- return fmt .Sprintf ("%s-%s" , deploymentUID , taskQueueName )
43
+ return fmt .Sprintf ("%s-%s" , deploymentUID , taskQueueID )
61
44
}
62
45
63
46
func GetDeploymentUID () string {
0 commit comments