-
Notifications
You must be signed in to change notification settings - Fork 317
/
types.go
205 lines (173 loc) · 6.25 KB
/
types.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
package backendconfig
import (
"time"
"github.com/rudderlabs/rudder-server/utils/misc"
)
// Topic refers to a subset of backend config's updates, received after subscribing using the backend config's Subscribe function.
type Topic string
type Regulation string
const (
/*TopicBackendConfig topic provides updates on full backend config, via Subscribe function */
TopicBackendConfig Topic = "backendConfig"
/*TopicProcessConfig topic provides updates on backend config of processor enabled destinations, via Subscribe function */
TopicProcessConfig Topic = "processConfig"
/*RegulationSuppress refers to Suppress Regulation */
RegulationSuppress Regulation = "Suppress"
/*RegulationDelete refers to Suppress and Delete Regulation */
RegulationDelete Regulation = "Delete" // TODO Will add support soon.
/*RegulationSuppressAndDelete refers to Suppress and Delete Regulation */
RegulationSuppressAndDelete Regulation = "Suppress_With_Delete"
GlobalEventType = "global"
)
type DestinationDefinitionT struct {
ID string
Name string
DisplayName string
Config map[string]interface{}
ResponseRules map[string]interface{}
}
type SourceDefinitionT struct {
ID string
Name string
Category string
Type string // // Indicates whether source is one of {cloud, web, flutter, android, ios, warehouse, cordova, amp, reactnative, unity}. This field is not present in sources table
}
type DestinationT struct {
ID string
Name string
DestinationDefinition DestinationDefinitionT
Config map[string]interface{}
Enabled bool
WorkspaceID string
Transformations []TransformationT
IsProcessorEnabled bool
RevisionID string
}
type SourceT struct {
ID string
Name string
SourceDefinition SourceDefinitionT
Config map[string]interface{}
Enabled bool
WorkspaceID string
Destinations []DestinationT
WriteKey string
DgSourceTrackingPlanConfig DgSourceTrackingPlanConfigT
Transient bool
EventSchemasEnabled bool
}
type WorkspaceRegulationT struct {
ID string
RegulationType string
WorkspaceID string
UserID string
}
type SourceRegulationT struct {
ID string
RegulationType string
WorkspaceID string
SourceID string
UserID string
}
type ConfigT struct {
EnableMetrics bool `json:"enableMetrics"`
WorkspaceID string `json:"workspaceId"`
Sources []SourceT `json:"sources"`
Libraries LibrariesT `json:"libraries"`
ConnectionFlags ConnectionFlags `json:"flags"`
Settings Settings `json:"settings"`
UpdatedAt time.Time `json:"updatedAt"`
}
type Settings struct {
DataRetention DataRetention `json:"dataRetention"`
}
type DataRetention struct {
DisableReportingPII bool `json:"disableReportingPii"`
UseSelfStorage bool `json:"useSelfStorage"`
StorageBucket StorageBucket `json:"storageBucket"`
StoragePreferences StoragePreferences `json:"storagePreferences"`
RetentionPeriod string `json:"retentionPeriod"`
}
type StorageBucket struct {
Type string `json:"type"`
Config map[string]interface{}
}
type StoragePreferences struct {
ProcErrors bool `json:"procErrors"`
GatewayDumps bool `json:"gatewayDumps"`
ProcErrorDumps bool `json:"procErrorDumps"`
RouterDumps bool `json:"routerDumps"`
BatchRouterDumps bool `json:"batchRouterDumps"`
}
func (sp StoragePreferences) Backup(tableprefix string) bool {
switch tableprefix {
case "gw":
return sp.GatewayDumps
case "rt":
return sp.RouterDumps
case "batch_rt":
return sp.BatchRouterDumps
case "proc_error":
return sp.ProcErrorDumps
default:
return false
}
}
type ConnectionFlags struct {
URL string `json:"url"`
Services map[string]bool `json:"services"`
}
type WRegulationsT struct {
WorkspaceRegulations []WorkspaceRegulationT `json:"workspaceRegulations"`
Start int `json:"start"`
Limit int `json:"limit"`
Size int `json:"size"`
End bool `json:"end"`
Next int `json:"next"`
}
type SRegulationsT struct {
SourceRegulations []SourceRegulationT `json:"sourceRegulations"`
Start int `json:"start"`
Limit int `json:"limit"`
Size int `json:"size"`
End bool `json:"end"`
Next int `json:"next"`
}
type TransformationT struct {
VersionID string
ID string
Config map[string]interface{}
}
type LibraryT struct {
VersionID string
}
type LibrariesT []LibraryT
type DgSourceTrackingPlanConfigT struct {
SourceId string `json:"sourceId"`
SourceConfigVersion int `json:"version"`
Config map[string]map[string]interface{} `json:"config"`
MergedConfig map[string]interface{} `json:"mergedConfig"`
Deleted bool `json:"deleted"`
TrackingPlan TrackingPlanT `json:"trackingPlan"`
}
func (dgSourceTPConfigT *DgSourceTrackingPlanConfigT) GetMergedConfig(eventType string) map[string]interface{} {
if dgSourceTPConfigT.MergedConfig == nil {
globalConfig := dgSourceTPConfigT.fetchEventConfig(GlobalEventType)
eventSpecificConfig := dgSourceTPConfigT.fetchEventConfig(eventType)
outputConfig := misc.MergeMaps(globalConfig, eventSpecificConfig)
dgSourceTPConfigT.MergedConfig = outputConfig
}
return dgSourceTPConfigT.MergedConfig
}
func (dgSourceTPConfigT *DgSourceTrackingPlanConfigT) fetchEventConfig(eventType string) map[string]interface{} {
emptyMap := map[string]interface{}{}
_, eventSpecificConfigPresent := dgSourceTPConfigT.Config[eventType]
if !eventSpecificConfigPresent {
return emptyMap
}
return dgSourceTPConfigT.Config[eventType]
}
type TrackingPlanT struct {
Id string `json:"id"`
Version int `json:"version"`
}