-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathprefab.proto
More file actions
480 lines (413 loc) · 10.4 KB
/
prefab.proto
File metadata and controls
480 lines (413 loc) · 10.4 KB
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
syntax = "proto3";
package prefab;
option java_package = "cloud.prefab.domain";
option java_outer_classname = "Prefab";
option go_package = "github.com/prefab-cloud/prefab-cloud-go/proto";
message ConfigServicePointer {
int64 project_id = 1;
int64 start_at_id = 2;
int64 project_env_id = 3;
}
message ConfigValue {
oneof type {
int64 int = 1;
string string = 2;
bytes bytes = 3;
double double = 4;
bool bool = 5;
WeightedValues weighted_values = 6;
LimitDefinition limit_definition = 7;
LogLevel log_level = 9;
StringList string_list = 10;
IntRange int_range = 11;
Provided provided = 12;
IsoDuration duration = 15;
Json json = 16;
Schema schema = 17;
}
optional bool confidential = 13; // don't log or telemetry this value
optional string decrypt_with = 14; // key name to decrypt with
}
message Json {
string json = 1;
}
message IsoDuration {
string definition = 1; // value is eg P1h30s
}
message Provided {
optional ProvidedSource source = 1;
optional string lookup = 2; // eg MY_ENV_VAR
}
enum ProvidedSource {
PROVIDED_SOURCE_NOT_SET = 0;
ENV_VAR = 1;
}
message IntRange {
optional int64 start = 1; // if empty treat as Long.MIN_VALUE. Inclusive
optional int64 end = 2; // if empty treat as Long.MAX_VALUE. Exclusive
}
message StringList {
repeated string values = 1;
}
message WeightedValue {
int32 weight = 1; // out of 1000
ConfigValue value = 2;
}
message WeightedValues {
repeated WeightedValue weighted_values = 1;
optional string hash_by_property_name = 2;
}
message ApiKeyMetadata {
reserved 2;
optional string key_id = 1; // numeric currently, but making it string will be more flexible over time
optional string user_id = 3; //ditto
}
message Configs {
repeated Config configs = 1;
ConfigServicePointer config_service_pointer = 2;
optional ApiKeyMetadata apikey_metadata = 3;
optional ContextSet default_context = 4;
optional bool keep_alive = 5;
}
enum ConfigType {
NOT_SET_CONFIG_TYPE = 0; // proto null
CONFIG = 1;
FEATURE_FLAG = 2;
LOG_LEVEL = 3;
SEGMENT = 4;
LIMIT_DEFINITION = 5;
DELETED = 6;
SCHEMA = 7;
}
message Config {
int64 id = 1;
int64 project_id = 2;
string key = 3;
ChangedBy changed_by = 4;
repeated ConfigRow rows = 5;
repeated ConfigValue allowable_values = 6;
ConfigType config_type = 7;
optional int64 draft_id = 8;
ValueType value_type = 9;
bool send_to_client_sdk = 10; // default value of a boolean in proto3 is false
optional string schema_key = 11;
enum ValueType {
NOT_SET_VALUE_TYPE = 0; // proto null
INT = 1;
STRING = 2;
BYTES = 3;
DOUBLE = 4;
BOOL = 5;
LIMIT_DEFINITION = 7;
LOG_LEVEL = 9;
STRING_LIST = 10;
INT_RANGE = 11;
DURATION = 12;
JSON = 13;
}
}
message ChangedBy {
int64 user_id = 1;
string email = 2;
string api_key_id = 3;
}
message ConfigRow {
optional int64 project_env_id = 1; // one row per project_env_id
repeated ConditionalValue values = 2;
map<string, ConfigValue> properties = 3; // can store "activated"
}
message ConditionalValue {
repeated Criterion criteria = 1; // if all criteria match, then the rule is matched and value is returned
ConfigValue value = 2;
}
enum LogLevel {
NOT_SET_LOG_LEVEL = 0;
TRACE = 1;
DEBUG = 2;
INFO = 3;
// NOTICE = 4;
WARN = 5;
ERROR = 6;
// CRITICAL = 7;
// ALERT = 8;
FATAL = 9;
}
message Criterion {
enum CriterionOperator {
NOT_SET = 0; // proto null
LOOKUP_KEY_IN = 1;
LOOKUP_KEY_NOT_IN = 2;
IN_SEG = 3;
NOT_IN_SEG = 4;
ALWAYS_TRUE = 5;
PROP_IS_ONE_OF = 6;
PROP_IS_NOT_ONE_OF = 7;
PROP_ENDS_WITH_ONE_OF = 8;
PROP_DOES_NOT_END_WITH_ONE_OF = 9;
HIERARCHICAL_MATCH = 10;
IN_INT_RANGE = 11;
PROP_STARTS_WITH_ONE_OF = 12;
PROP_DOES_NOT_START_WITH_ONE_OF =13;
PROP_CONTAINS_ONE_OF = 14;
PROP_DOES_NOT_CONTAIN_ONE_OF = 15;
PROP_LESS_THAN = 16;
PROP_LESS_THAN_OR_EQUAL = 17;
PROP_GREATER_THAN = 18;
PROP_GREATER_THAN_OR_EQUAL = 19;
PROP_BEFORE = 20;
PROP_AFTER = 21;
PROP_MATCHES = 22;
PROP_DOES_NOT_MATCH = 23;
PROP_SEMVER_LESS_THAN = 24;
PROP_SEMVER_EQUAL = 25;
PROP_SEMVER_GREATER_THAN = 26;
}
string property_name = 1;
CriterionOperator operator = 2;
ConfigValue value_to_match = 3;
}
message Loggers {
repeated Logger loggers = 1;
int64 start_at = 2;
int64 end_at = 3;
string instance_hash = 4; // random UUID generated on startup - represents the server so we can aggregate
optional string namespace = 5;
}
message Logger {
string logger_name = 1;
optional int64 traces = 2;
optional int64 debugs = 3;
optional int64 infos = 4;
optional int64 warns = 5;
optional int64 errors = 6;
optional int64 fatals = 7;
}
message LoggerReportResponse {
}
message LimitResponse {
enum LimitPolicyNames {
NOT_SET = 0;
SECONDLY_ROLLING = 1;
MINUTELY_ROLLING = 3;
HOURLY_ROLLING = 5;
DAILY_ROLLING = 7;
MONTHLY_ROLLING = 8;
INFINITE = 9;
YEARLY_ROLLING = 10;
}
bool passed = 1;
int64 expires_at = 2; // for returnable: rtn this value
string enforced_group = 3; // events:pageview:homepage:123123
int64 current_bucket = 4;
string policy_group = 5; // events:pageview
LimitPolicyNames policy_name = 6;
int32 policy_limit = 7;
int64 amount = 8;
int64 limit_reset_at = 9;
LimitDefinition.SafetyLevel safety_level = 10;
}
message LimitRequest {
int64 account_id = 1;
int32 acquire_amount = 2;
repeated string groups = 3;
enum LimitCombiner {
NOT_SET = 0;
MINIMUM = 1;
MAXIMUM = 2;
}
LimitCombiner limit_combiner = 4;
bool allow_partial_response = 5;
LimitDefinition.SafetyLevel safety_level = 6; // [default = L4_BEST_EFFORT];
}
// if the same Context type exists, last one wins
message ContextSet {
repeated Context contexts = 1;
}
message Context {
optional string type = 1;
map<string, ConfigValue> values = 2;
}
message Identity {
optional string lookup = 1;
map<string, string> attributes = 2;
}
message ConfigEvaluationMetaData {
optional int64 config_row_index = 1;
optional int64 conditional_value_index = 2;
optional int64 weighted_value_index = 3;
optional ConfigType type = 4;
optional int64 id = 5;
optional Config.ValueType value_type = 6;
}
message ClientConfigValue {
oneof type {
int64 int = 1;
string string = 2;
double double = 3;
bool bool = 4;
LogLevel log_level = 5;
StringList string_list = 7;
IntRange int_range = 8;
ClientDuration duration = 9;
Json json = 10;
}
optional ConfigEvaluationMetaData config_evaluation_metadata = 6;
}
message ClientDuration {
int64 seconds = 1; // the actual time is the sum of these, so 1.5 seconds would be seconds = 1, nanos = 500_000_000
int32 nanos = 2;
string definition = 3;
}
message ConfigEvaluations {
map<string, ClientConfigValue> values = 1;
optional ApiKeyMetadata apikey_metadata = 2;
optional ContextSet default_context = 3;
}
message LimitDefinition {
enum SafetyLevel {
NOT_SET = 0;
L4_BEST_EFFORT = 4;
L5_BOMBPROOF = 5;
}
LimitResponse.LimitPolicyNames policy_name = 2;
int32 limit = 3;
int32 burst = 4;
int64 account_id = 5;
int64 last_modified = 6;
bool returnable = 7;
SafetyLevel safety_level = 8; // [default = L4_BEST_EFFORT]; // Overridable by request
}
message LimitDefinitions {
repeated LimitDefinition definitions = 1;
}
enum OnFailure {
NOT_SET = 0;
LOG_AND_PASS = 1;
LOG_AND_FAIL = 2;
THROW = 3;
}
message BufferedRequest {
int64 account_id = 1;
string method = 2;
string uri = 3;
string body = 4;
repeated string limit_groups = 5;
string content_type = 6;
bool fifo = 7;
}
message BatchRequest {
int64 account_id = 1;
string method = 2;
string uri = 3;
string body = 4;
repeated string limit_groups = 5;
string batch_template = 6;
string batch_separator = 7;
}
message BasicResponse {
string message = 1;
}
message CreationResponse {
string message = 1;
int64 new_id = 2;
}
message IdBlock {
int64 project_id = 1;
int64 project_env_id = 2;
string sequence_name = 3;
int64 start = 4;
int64 end = 5;
}
message IdBlockRequest {
int64 project_id = 1;
int64 project_env_id = 2;
string sequence_name = 3;
int64 size = 4;
}
message ContextShape {
string name = 1;
map<string, int32> field_types = 2;
}
message ContextShapes {
repeated ContextShape shapes = 1;
optional string namespace = 2;
}
message EvaluatedKeys {
repeated string keys = 1;
optional string namespace = 2;
}
message EvaluatedConfig {
string key = 1;
int64 config_version = 2;
ConfigValue result = 3;
ContextSet context = 4;
int64 timestamp = 5;
}
message EvaluatedConfigs {
repeated EvaluatedConfig configs = 1;
}
message ConfigEvaluationCounter {
int64 count = 1;
optional int64 config_id = 2;
optional uint32 selected_index = 3; // index into the allowed-values list in the config
optional ConfigValue selected_value = 4;
optional uint32 config_row_index = 5; // which row matched
optional uint32 conditional_value_index = 6; // which ConditionalValue in the row matched?
optional uint32 weighted_value_index = 7; // index into the weighted value array
Reason reason = 8;
enum Reason {
UNKNOWN = 0;
}
}
message ConfigEvaluationSummary {
string key = 1;
ConfigType type = 2; // type of config eval
repeated ConfigEvaluationCounter counters = 3;
}
message ConfigEvaluationSummaries {
int64 start = 1;
int64 end = 2;
repeated ConfigEvaluationSummary summaries = 3;
}
message LoggersTelemetryEvent {
repeated Logger loggers = 1;
int64 start_at = 2;
int64 end_at = 3;
}
message TelemetryEvent {
oneof payload {
ConfigEvaluationSummaries summaries = 2;
ExampleContexts example_contexts = 3;
ClientStats client_stats = 4;
LoggersTelemetryEvent loggers = 5;
ContextShapes context_shapes = 6;
}
}
message TelemetryEvents {
string instance_hash = 1; // random UUID generated on startup - represents the server so we can aggregate
repeated TelemetryEvent events = 2;
}
message TelemetryEventsResponse {
bool success = 1;
}
message ExampleContexts {
repeated ExampleContext examples = 1;
}
message ExampleContext {
int64 timestamp = 1;
ContextSet contextSet = 2;
}
message ClientStats {
int64 start = 1;
int64 end = 2;
uint64 dropped_event_count = 3;
}
message Schema {
enum SchemaType {
UNKNOWN = 0;
ZOD = 1;
JSON_SCHEMA = 2;
}
string schema = 1;
SchemaType schema_type = 2;
}