A simple, distributed rate limiter service built with Go, Redis, Terraform and GCP.
The service exposes a REST api described in the Openapi document. It exposes the following endpoints:
GET /
andGET /healthz
perform a health check and returns200
if the service can connect to Redis.GET /token/{token_id}
will increment the request count for the given token, and will return a response that details the number of tokens remaining, and the number of seconds until reset.
- Infrastructure described with terraform, including a bootstrap script, for deploying to GCP.
- CI/CD config in cloudbuild.yaml.
make build
builds the binary.make test
runs unit tests. Note that this requires an instance of Redis 4 to be running locally.make up
starts a full local environment with docker-compose.make deploy
runs the cloud init and deployment scripts, powered by Terraform.
- There are a few
TODO
's in the code base for small code improvements. (grep -r TODO .
) - Functions are deployed to public endpoints, without IAM authentication.
- Cloud functions have a warm up time that can sometimes be a few seconds. This could be unsuitable in production if consistent latency is important.