This repository has been archived by the owner on Apr 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 99
Introduced Release Candidate v3.0 #206
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,5 @@ coverage.out | |
coverage.html | ||
/gubernator | ||
/gubernator-cli | ||
.run/ | ||
tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ clean: | |
|
||
.PHONY: proto | ||
proto: | ||
scripts/proto.sh | ||
buf build | ||
|
||
.PHONY: certs | ||
certs: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -15,7 +15,6 @@ Gubernator is a distributed, high performance, cloud native and stateless rate-l | |||||
kubernetes or nomad trivial. | ||||||
* Gubernator holds no state on disk, It’s configuration is passed to it by the | ||||||
client on a per-request basis. | ||||||
* Gubernator provides both GRPC and HTTP access to the API. | ||||||
* It Can be run as a sidecar to services that need rate limiting or as a separate service. | ||||||
* It Can be used as a library to implement a domain-specific rate limiting service. | ||||||
* Supports optional eventually consistent rate limit distribution for extremely | ||||||
|
@@ -38,11 +37,13 @@ $ docker-compose up -d | |||||
``` | ||||||
Now you can make rate limit requests via CURL | ||||||
``` | ||||||
# Hit the HTTP API at localhost:9080 (GRPC is at 9081) | ||||||
$ curl http://localhost:9080/v1/HealthCheck | ||||||
# Hit the HTTP API at localhost:9080 | ||||||
$ curl http://localhost:9080/v1/health.check | ||||||
|
||||||
# TODO: Update this example | ||||||
|
||||||
# Make a rate limit request | ||||||
$ curl http://localhost:9080/v1/GetRateLimits \ | ||||||
$ curl http://localhost:9080/v1/rate-limits.check \ | ||||||
--header 'Content-Type: application/json' \ | ||||||
--data '{ | ||||||
"requests": [ | ||||||
|
@@ -59,7 +60,7 @@ $ curl http://localhost:9080/v1/GetRateLimits \ | |||||
|
||||||
### ProtoBuf Structure | ||||||
|
||||||
An example rate limit request sent via GRPC might look like the following | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if it's strictly necessary but it may be worth adding a note that gRPC was dropped? Just for anyone who may have been using Gub with gRPC has an explicit warning |
||||||
An example rate limit request sent with protobuf might look like the following | ||||||
```yaml | ||||||
rate_limits: | ||||||
# Scopes the request to a specific rate limit | ||||||
|
@@ -189,7 +190,7 @@ limiting service. | |||||
|
||||||
When you use the library, your service becomes a full member of the cluster | ||||||
participating in the same consistent hashing and caching as a stand alone | ||||||
Gubernator server would. All you need to do is provide the GRPC server instance | ||||||
Gubernator server would. All you need to do is provide the server instance | ||||||
and tell Gubernator where the peers in your cluster are located. The | ||||||
`cmd/gubernator/main.go` is a great example of how to use Gubernator as a | ||||||
library. | ||||||
|
@@ -213,29 +214,22 @@ to support rate limit durations longer than a minute, day or month, calls to | |||||
those rate limits that have durations over a self determined limit. | ||||||
|
||||||
### API | ||||||
All methods are accessed via GRPC but are also exposed via HTTP using the | ||||||
[GRPC Gateway](https://github.com/grpc-ecosystem/grpc-gateway) | ||||||
|
||||||
#### Health Check | ||||||
Health check returns `unhealthy` in the event a peer is reported by etcd or kubernetes | ||||||
as `up` but the server instance is unable to contact that peer via it's advertised address. | ||||||
|
||||||
###### GRPC | ||||||
```grpc | ||||||
rpc HealthCheck (HealthCheckReq) returns (HealthCheckResp) | ||||||
``` | ||||||
|
||||||
###### HTTP | ||||||
``` | ||||||
GET /v1/HealthCheck | ||||||
GET /v1/health.check | ||||||
``` | ||||||
|
||||||
Example response: | ||||||
|
||||||
```json | ||||||
{ | ||||||
"status": "healthy", | ||||||
"peer_count": 3 | ||||||
"peerCount": 3 | ||||||
} | ||||||
``` | ||||||
|
||||||
|
@@ -244,14 +238,9 @@ Rate limits can be applied or retrieved using this interface. If the client | |||||
makes a request to the server with `hits: 0` then current state of the rate | ||||||
limit is retrieved but not incremented. | ||||||
|
||||||
###### GRPC | ||||||
```grpc | ||||||
rpc GetRateLimits (GetRateLimitsReq) returns (GetRateLimitsResp) | ||||||
``` | ||||||
|
||||||
###### HTTP | ||||||
``` | ||||||
POST /v1/GetRateLimits | ||||||
POST /v1/rate-limit.check | ||||||
``` | ||||||
|
||||||
Example Payload | ||||||
|
@@ -289,20 +278,10 @@ Example response: | |||||
``` | ||||||
|
||||||
### Deployment | ||||||
NOTE: Gubernator uses `etcd`, Kubernetes or round-robin DNS to discover peers and | ||||||
NOTE: Gubernator uses `memberlist` Kubernetes or round-robin DNS to discover peers and | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Just to make it clear that memberlist != K8S There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would go as far as adding the Oxford comma, too. |
||||||
establish a cluster. If you don't have either, the docker-compose method is the | ||||||
simplest way to try gubernator out. | ||||||
|
||||||
|
||||||
##### Docker with existing etcd cluster | ||||||
```bash | ||||||
$ docker run -p 8081:81 -p 9080:80 -e GUBER_ETCD_ENDPOINTS=etcd1:2379,etcd2:2379 \ | ||||||
ghcr.io/mailgun/gubernator:latest | ||||||
|
||||||
# Hit the HTTP API at localhost:9080 | ||||||
$ curl http://localhost:9080/v1/HealthCheck | ||||||
``` | ||||||
|
||||||
##### Kubernetes | ||||||
```bash | ||||||
# Download the kubernetes deployment spec | ||||||
|
@@ -321,14 +300,13 @@ you can use same fully-qualified domain name to both let your business logic con | |||||
instances to find `gubernator` and for `gubernator` containers/instances to find each other. | ||||||
|
||||||
##### TLS | ||||||
Gubernator supports TLS for both HTTP and GRPC connections. You can see an example with | ||||||
self signed certs by running `docker-compose-tls.yaml` | ||||||
Gubernator supports TLS. You can see an example with self signed certs by running `docker-compose-tls.yaml` | ||||||
```bash | ||||||
# Run docker compose | ||||||
$ docker-compose -f docker-compose-tls.yaml up -d | ||||||
|
||||||
# Hit the HTTP API at localhost:9080 (GRPC is at 9081) | ||||||
$ curl --cacert certs/ca.cert --cert certs/gubernator.pem --key certs/gubernator.key https://localhost:9080/v1/HealthCheck | ||||||
# Hit the HTTP API at localhost:9080 | ||||||
$ curl -X POST --cacert certs/ca.cert --cert certs/gubernator.pem --key certs/gubernator.key https://localhost:9080/v1/health.check | ||||||
``` | ||||||
|
||||||
### Configuration | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to
handler.go
, at least :D