Traffic Quota
Token bucket server to control web API requests.
You can check whether the request conforms to defined limits on rate and burstiness by querying this service at the beginning of your API.
Quick Start
Starting trafficquotad
go run ./cmd/trafficquotad
Using trafficquotad
from Your Application
After go get github.com/orgplace/trafficquota/client
or dep ensure -add github.com/orgplace/trafficquota/client
:
import "github.com/orgplace/trafficquota/client"
c, _ := client.NewInsecureClient("localhost:3895")
allowed, _ := c.Take("key")
Please see examples directory and godoc for more detail.
Installation
Docker
Pull image from Docker Hub and run:
docker run -it --rm -p3895:3895 orgplace/trafficquota:latest
In your docker-compose.yml
:
services:
trafficquota:
image: orgplace/trafficquota
ports:
- "3895:3895"
DEB/RPM Repository
You can use DEB/RPM repository (packagecloud).
Currently, Ubuntu 18.04, Ubuntu 18.10, Debian 9, Fedora 29 and RHEL 7 are supprted.
To register repository, follow packagecloud instruction (deb, rpm).
After registration:
# Ubuntu/Debian
apt-get install trafficquota
# Fedora
dnf install trafficquota
# RHEL
yum install trafficquota
When you use the package, systemd unit file for trafficquotad
is also installed.
# Start
sudo systemctl start trafficquotad
# Enable
sudo systemctl enable trafficquotad
# Customize
sudo systemctl edit trafficquotad
# Log
journalctl -xeu trafficquotad
From tarball/Build Source
Download tarball form GitHub Releases or build from source:
go build -o trafficquotad ./cmd/trafficquotad
Monitoring
Health Check
trafficquotad
supports gRPC Health Checking Protocol.
You can query health of the server using grpc-health-probe.
grpc-health-probe -addr=localhost:3895