https://github.com/llarsson/grpc-caching-interceptors
gRPC Interceptors for response caching, written in Go
https://github.com/llarsson/grpc-caching-interceptors
go golang grpc grpc-interceptor
Last synced: 9 months ago
JSON representation
gRPC Interceptors for response caching, written in Go
- Host: GitHub
- URL: https://github.com/llarsson/grpc-caching-interceptors
- Owner: llarsson
- License: gpl-3.0
- Created: 2020-01-10T07:03:14.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-25T06:58:02.000Z (over 5 years ago)
- Last Synced: 2024-11-15T07:36:38.100Z (over 1 year ago)
- Topics: go, golang, grpc, grpc-interceptor
- Language: Go
- Size: 115 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gRPC caching interceptors
Interceptors used to make gRPC caching-aware. Used in "Towards soft circuit breaking in service meshes via application-agnostic caching".
The `client/` directory contains the interceptor you want to use to get a simple TTL-abiding Cache component. See the [Value Service Caching Component](https://github.com/llarsson/value-service-caching) repo for how to use the code. You may want to use the reverse proxy that [our modified Protobuf compiler](https://github.com/llarsson/protobuf) gives you, but should not have to.
The `server/` directory contains the interceptor that lets you estimate how long a response is valid. You can affect how this estimate is produced by setting the following environment variables for your program that includes the interceptor:
* `PROXY_CACHE_BLACKLIST` should be a regular expression that blacklists operations in your gRPC service from caching (they will not be assigned a caching header, and thus, not cached).
* `PROXY_MAX_AGE` should be set to one of the following values (if not possible to parse, the Estimator will act in pass-through mode and just not assign a TTL to responses):
* `static-N`, where `N` is the number of seconds to statically always respond with, e.g., `static-10` for 10 second TTL for every response object.
* `dynamic-adaptive-N`, where N is the parameter to the Adaptive TTL algorithm (read the paper).
* `dynamic-updaterisk-N`, where N is the parameter to the Update-risk based algorithm (read the paper).
See the [Value Service Estimator Component](https://github.com/llarsson/value-service-estimator) repo for how to use the code. As with the Caching interceptor, you may want to use the reverse proxy that [our modified Protobuf compiler](https://github.com/llarsson/protobuf) gives you, but (again!) should not have to.