client.0.3.21-pre1.source-code.prefab.proto Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of client Show documentation
Show all versions of client Show documentation
API Client for https://prefab.cloud: rate limits, feature flags and semaphores as a service
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;
}
optional bool confidential = 13; // don't log or telemetry this value
optional string decrypt_with = 14; // key name to decrypt with
}
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;
}
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
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;
}
}
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 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;
}
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 values = 2;
}
message Identity {
optional string lookup = 1;
map 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;
}
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;
}
message ConfigEvaluations {
map 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 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;
}