Skip to content

Commit

Permalink
ENG-48445: Added generic filter and optional upsert condition (for op…
Browse files Browse the repository at this point in the history
…timistic updates) (#226)

* remove lock changes

* fix type

* refactor and review comments
  • Loading branch information
harshit-kumar-v2 authored Aug 19, 2024
1 parent 423b874 commit b5bb276
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ message UpsertConfigRequest {
// optional - only required if config applies to a specific context.
// If empty, specified config is associated with a default context.
string context = 4;

// optional - required when we want to update the target record when condition passes
// if no condition present creates or replaces the existing document
Filter upsert_condition = 5;
}

message UpsertConfigResponse {
Expand Down Expand Up @@ -161,3 +165,39 @@ message UpsertAllConfigsResponse {
optional google.protobuf.Value prev_config = 5;
}
}

message Filter {
oneof type {
RelationalFilter relational_filter = 1;
LogicalFilter logical_filter = 2;
}
}

message RelationalFilter {
string config_json_path = 1;
RelationalOperator operator = 2;
google.protobuf.Value value = 3;
}

message LogicalFilter {
LogicalOperator operator = 1;
repeated Filter operands = 2;
}

enum RelationalOperator {
RELATIONAL_OPERATOR_UNSPECIFIED = 0;
RELATIONAL_OPERATOR_EQ = 1;
RELATIONAL_OPERATOR_NEQ = 2;
RELATIONAL_OPERATOR_IN = 3;
RELATIONAL_OPERATOR_NOT_IN = 4;
RELATIONAL_OPERATOR_GT = 5;
RELATIONAL_OPERATOR_LT = 6;
RELATIONAL_OPERATOR_GTE = 7;
RELATIONAL_OPERATOR_LTE = 8;
}

enum LogicalOperator {
LOGICAL_OPERATOR_UNSPECIFIED = 0;
LOGICAL_OPERATOR_AND = 1;
LOGICAL_OPERATOR_OR = 2;
}

0 comments on commit b5bb276

Please sign in to comment.