forked from frain-dev/convoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
type.go
125 lines (99 loc) · 3 KB
/
type.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
package convoy
import (
"embed"
"strings"
)
type HttpMethod string
type TaskName string
type QueueName string
type CacheKey string
//go:embed VERSION
var F embed.FS
//go:embed sql/*.sql
var MigrationFiles embed.FS
func (t TaskName) SetPrefix(prefix string) TaskName {
var name strings.Builder
delim := "-"
name.WriteString(prefix)
name.WriteString(delim)
name.WriteString(string(t))
return TaskName(name.String())
}
func (c CacheKey) Get(suffix string) CacheKey {
var name strings.Builder
delim := ":"
name.WriteString(string(c))
name.WriteString(delim)
name.WriteString(suffix)
return CacheKey(name.String())
}
func (c CacheKey) String() string {
return string(c)
}
func readVersion(fs embed.FS) ([]byte, error) {
data, err := fs.ReadFile("VERSION")
if err != nil {
return nil, err
}
return data, nil
}
// TODO(subomi): This needs to be refactored for everywhere we depend
// on this code.
func GetVersion() string {
v := "0.1.0"
f, err := readVersion(F)
if err != nil {
return v
}
v = strings.TrimSpace(string(f))
return v
}
func GetVersionFromFS(fs embed.FS) string {
v := "0.1.0"
f, err := readVersion(fs)
if err != nil {
return v
}
v = strings.TrimSpace(string(f))
return v
}
const (
EventProcessor TaskName = "EventProcessor"
RetryEventProcessor TaskName = "RetryEventProcessor"
CreateEventProcessor TaskName = "CreateEventProcessor"
CreateDynamicEventProcessor TaskName = "CreateDynamicEventProcessor"
CreateBroadcastEventProcessor TaskName = "CreateBroadcastEventProcessor"
MetaEventProcessor TaskName = "MetaEventProcessor"
NotificationProcessor TaskName = "NotificationProcessor"
TokenizeSearch TaskName = "tokenize search"
TokenizeSearchForProject TaskName = "tokenize search for project"
DailyAnalytics TaskName = "daily analytics"
StreamCliEventsProcessor TaskName = "StreamCliEventsProcessor"
MonitorTwitterSources TaskName = "monitor twitter sources"
RetentionPolicies TaskName = "retention_policies"
EmailProcessor TaskName = "EmailProcessor"
ExpireSecretsProcessor TaskName = "ExpireSecretsProcessor"
DeleteArchivedTasksProcessor TaskName = "DeleteArchivedTasksProcessor"
EndpointCacheKey CacheKey = "endpoints"
ApiKeyCacheKey CacheKey = "api_keys"
OrganisationCacheKey CacheKey = "organisations"
ProjectsCacheKey CacheKey = "projects"
SubscriptionCacheKey CacheKey = "subscriptions"
TokenCacheKey CacheKey = "tokens"
SourceCacheKey CacheKey = "sources"
)
// queues
const (
EventQueue QueueName = "EventQueue"
CreateEventQueue QueueName = "CreateEventQueue"
MetaEventQueue QueueName = "MetaEventQueue"
RetryEventQueue QueueName = "RetryEventQueue"
StreamQueue QueueName = "StreamQueue"
ScheduleQueue QueueName = "ScheduleQueue"
DefaultQueue QueueName = "DefaultQueue"
)
// Exports dir
const (
DefaultOnPremDir = "/var/convoy/export"
TmpExportDir = "/tmp/convoy/export"
)