Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching #2935

Merged
merged 22 commits into from
Nov 20, 2023
Merged

Caching #2935

Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ buf-generate:

@#generate sdk flowcontrol stubs and copy them over

@#golang
@rm -rf ../sdks/aperture-go/gen/proto/flowcontrol/*
@cp -R gen/proto/go/aperture/flowcontrol/check ../sdks/aperture-go/gen/proto/flowcontrol/
@cp -R gen/proto/go/aperture/flowcontrol/checkhttp ../sdks/aperture-go/gen/proto/flowcontrol/

@#java
@rm -rf ../sdks/aperture-java/lib/core/src/main/java/com/fluxninja/generated/aperture/flowcontrol/*
@cp -R gen/proto/java/com/fluxninja/generated/aperture/flowcontrol/check ../sdks/aperture-java/lib/core/src/main/java/com/fluxninja/generated/aperture/flowcontrol/
Expand Down
45 changes: 45 additions & 0 deletions api/aperture/flowcontrol/check/v1/check.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ import "google/protobuf/timestamp.proto";
service FlowControlService {
// Check wraps the given arbitrary resource and matches the given labels against Flow Control Limiters to makes a decision whether to allow/deny.
rpc Check(CheckRequest) returns (CheckResponse) {}
rpc CacheUpsert(CacheUpsertRequest) returns (CacheUpsertResponse) {}
rpc CacheDelete(CacheDeleteRequest) returns (CacheDeleteResponse) {}
}

// CheckRequest contains fields required to perform Check call.
message CheckRequest {
string control_point = 1;
map<string, string> labels = 2;
bool ramp_mode = 3;
// Cache item to fetch.
string cache_key = 4;
}

// CheckResponse contains fields that represent decision made by Check call.
Expand Down Expand Up @@ -63,6 +67,47 @@ message CheckResponse {
// http_status contains the http status code to be returned to the client, if
// decision_type is REJECTED. Optional.
StatusCode denied_response_status_code = 14;
// Matching cached value.
CachedValue cached_value = 15;
}

enum CacheLookupResult {
HIT = 0;
MISS = 1;
}

enum CacheResponseCode {
SUCCESS = 0;
ERROR = 1;
}

message CachedValue {
bytes value = 1;
CacheLookupResult lookup_result = 2;
CacheResponseCode response_code = 3;
string message = 4;
}

message CacheUpsertRequest {
string control_point = 1;
string key = 2;
bytes value = 3;
google.protobuf.Duration ttl = 4;
}

message CacheUpsertResponse {
CacheResponseCode code = 1;
string message = 2;
}

message CacheDeleteRequest {
string control_point = 1;
string key = 2;
}

message CacheDeleteResponse {
CacheResponseCode code = 1;
string message = 2;
}

// ClassifierInfo describes details for each ClassifierInfo.
Expand Down
Loading
Loading