From b5bb276f0e20ac897b7e017a21e51a2341ff2a3e Mon Sep 17 00:00:00 2001 From: Harshit Kumar Date: Mon, 19 Aug 2024 18:40:08 +0530 Subject: [PATCH] ENG-48445: Added generic filter and optional upsert condition (for optimistic updates) (#226) * remove lock changes * fix type * refactor and review comments --- .../config/service/v1/config_service.proto | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/config-service-api/src/main/proto/org/hypertrace/config/service/v1/config_service.proto b/config-service-api/src/main/proto/org/hypertrace/config/service/v1/config_service.proto index d7ec9181..0cfb9c92 100644 --- a/config-service-api/src/main/proto/org/hypertrace/config/service/v1/config_service.proto +++ b/config-service-api/src/main/proto/org/hypertrace/config/service/v1/config_service.proto @@ -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 { @@ -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; +}