From 4d0838125b8ff11a564b5bb46b835e9e2f4ecd8d Mon Sep 17 00:00:00 2001 From: Maria Ines Parnisari Date: Sun, 21 Jan 2024 22:09:54 -0300 Subject: [PATCH] chore: update protos and Makefile --- .gitattributes | 4 ++ Makefile | 30 ++++++----- buf.gen.yaml | 4 +- buf.lock | 4 +- gubernator.pb.go | 21 ++++---- gubernator.proto | 8 +-- gubernator_grpc.pb.go | 9 ++-- peers.pb.go | 7 ++- peers.proto | 4 +- peers_grpc.pb.go | 17 +++---- python/gubernator/gubernator_pb2.py | 79 +++++++++++++++-------------- python/gubernator/peers_pb2.py | 39 +++++++------- python/gubernator/peers_pb2_grpc.py | 4 +- 13 files changed, 117 insertions(+), 113 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..5ca46841 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,4 @@ +*.pb.go linguist-generated=true +*.pb.*.go linguist-generated=true +go.sum linguist-generated=true +buf.lock linguist-generated=true \ No newline at end of file diff --git a/Makefile b/Makefile index fde55c98..850102d1 100644 --- a/Makefile +++ b/Makefile @@ -1,46 +1,50 @@ -.DEFAULT_GOAL := release +.DEFAULT_GOAL := build VERSION=$(shell cat version) LDFLAGS="-X main.Version=$(VERSION)" GOLANGCI_LINT = $(GOPATH)/bin/golangci-lint GOLANGCI_LINT_VERSION = 1.54.2 -$(GOLANGCI_LINT): +.PHONY: help +help: + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +$(GOLANGCI_LINT): ## Download Go linter curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION) .PHONY: lint -lint: $(GOLANGCI_LINT) - $(GOLANGCI_LINT) run +lint: $(GOLANGCI_LINT) ## Run Go linter + $(GOLANGCI_LINT) run -v --fix -c .golangci.yml ./... .PHONY: test -test: +test: ## Run unit tests and measure code coverage (go test -v -race -p=1 -count=1 -coverprofile coverage.out ./...; ret=$$?; \ go tool cover -func coverage.out; \ go tool cover -html coverage.out -o coverage.html; \ exit $$ret) .PHONY: bench -bench: +bench: ## Run Go benchmarks go test ./... -bench . -benchtime 5s -timeout 0 -run=XXX -benchmem .PHONY: docker -docker: +docker: ## Build Docker image docker build --build-arg VERSION=$(VERSION) -t ghcr.io/mailgun/gubernator:$(VERSION) . docker tag ghcr.io/mailgun/gubernator:$(VERSION) ghcr.io/mailgun/gubernator:latest -.PHONY: release -release: +.PHONY: build +build: ## Build binary go build -v -ldflags $(LDFLAGS) -o gubernator ./cmd/gubernator/main.go .PHONY: clean -clean: +clean: ## Clean binaries rm -f gubernator gubernator-cli .PHONY: proto -proto: - scripts/proto.sh +proto: ## Build protos + ./buf.gen.yaml .PHONY: certs -certs: +certs: ## Generate SSL certificates rm certs/*.key || rm certs/*.srl || rm certs/*.csr || rm certs/*.pem || rm certs/*.cert || true openssl genrsa -out certs/ca.key 4096 openssl req -new -x509 -key certs/ca.key -sha256 -subj "/C=US/ST=TX/O=Mailgun Technologies, Inc." -days 3650 -out certs/ca.cert diff --git a/buf.gen.yaml b/buf.gen.yaml index 65a065c5..9366c73f 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -1,6 +1,8 @@ +#!/usr/bin/env -S buf generate --template +--- version: v1 plugins: - - name: go + - plugin: buf.build/protocolbuffers/go:v1.28.1 out: ./ opt: paths=source_relative - plugin: buf.build/grpc/go:v1.3.0 diff --git a/buf.lock b/buf.lock index 3435191d..4144ecf5 100644 --- a/buf.lock +++ b/buf.lock @@ -4,5 +4,5 @@ deps: - remote: buf.build owner: googleapis repository: googleapis - commit: 711e289f6a384c4caeebaff7c6931ade - digest: shake256:e08fb55dad7469f69df00304eed31427d2d1576e9aab31e6bf86642688e04caaf0372f15fe6974cf79432779a635b3ea401ca69c943976dc42749524e4c25d94 + commit: a86849a25cc04f4dbe9b15ddddfbc488 + digest: shake256:e19143328f8cbfe13fc226aeee5e63773ca494693a72740a7560664270039a380d94a1344234b88c7691311460df9a9b1c2982190d0a2612eae80368718e1943 diff --git a/gubernator.pb.go b/gubernator.pb.go index 1e902315..5756c5ce 100644 --- a/gubernator.pb.go +++ b/gubernator.pb.go @@ -16,18 +16,17 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.7 +// protoc (unknown) // source: gubernator.proto package gubernator import ( - reflect "reflect" - sync "sync" - _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( @@ -110,7 +109,7 @@ const ( // distributed to each peer and cached locally. A rate limit request received from any peer in the // cluster will first check the local cache for a rate limit answer, if it exists the peer will // immediately return the answer to the client and asynchronously forward the aggregate hits to - // the peer coordinator. Because of GLOBALS async nature we lose some accuracy in rate limit + // the owner peer. Because of GLOBALS async nature we lose some accuracy in rate limit // reporting, which may result in allowing some requests beyond the chosen rate limit. However we // gain massive performance as every request coming into the system does not have to wait for a // single peer to decide if the rate limit has been reached. @@ -473,15 +472,15 @@ type RateLimitResp struct { // The status of the rate limit. Status Status `protobuf:"varint,1,opt,name=status,proto3,enum=pb.gubernator.Status" json:"status,omitempty"` - // The currently configured request limit (Identical to RateLimitRequest.rate_limit_config.limit). + // The currently configured request limit (Identical to [[RateLimitReq.limit]]). Limit int64 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"` - // This is the number of requests remaining before the limit is hit. + // This is the number of requests remaining after the rate limiting is applied Remaining int64 `protobuf:"varint,3,opt,name=remaining,proto3" json:"remaining,omitempty"` // This is the time when the rate limit span will be reset, provided as a unix timestamp in milliseconds. ResetTime int64 `protobuf:"varint,4,opt,name=reset_time,json=resetTime,proto3" json:"reset_time,omitempty"` // Contains the error; If set all other values should be ignored Error string `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` - // This is additional metadata that a client might find useful. (IE: Additional headers, corrdinator ownership, etc..) + // This is additional metadata that a client might find useful. (IE: Additional headers, coordinator ownership, etc..) Metadata map[string]string `protobuf:"bytes,6,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } @@ -750,9 +749,9 @@ var file_gubernator_proto_rawDesc = []byte{ 0x2e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x20, 0x2e, 0x70, 0x62, 0x2e, 0x67, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x52, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x73, 0x52, - 0x65, 0x73, 0x70, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x22, 0x11, 0x2f, 0x76, 0x31, - 0x2f, 0x47, 0x65, 0x74, 0x52, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x73, 0x3a, 0x01, - 0x2a, 0x12, 0x65, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, + 0x65, 0x73, 0x70, 0x22, 0x1c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x16, 0x3a, 0x01, 0x2a, 0x22, 0x11, + 0x2f, 0x76, 0x31, 0x2f, 0x47, 0x65, 0x74, 0x52, 0x61, 0x74, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, + 0x73, 0x12, 0x65, 0x0a, 0x0b, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x1d, 0x2e, 0x70, 0x62, 0x2e, 0x67, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x2e, 0x48, 0x65, 0x61, 0x6c, 0x74, 0x68, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x70, 0x62, 0x2e, 0x67, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x61, 0x74, 0x6f, 0x72, 0x2e, diff --git a/gubernator.proto b/gubernator.proto index c8f237e8..4b52e6ad 100644 --- a/gubernator.proto +++ b/gubernator.proto @@ -86,7 +86,7 @@ enum Behavior { // distributed to each peer and cached locally. A rate limit request received from any peer in the // cluster will first check the local cache for a rate limit answer, if it exists the peer will // immediately return the answer to the client and asynchronously forward the aggregate hits to - // the peer coordinator. Because of GLOBALS async nature we lose some accuracy in rate limit + // the owner peer. Because of GLOBALS async nature we lose some accuracy in rate limit // reporting, which may result in allowing some requests beyond the chosen rate limit. However we // gain massive performance as every request coming into the system does not have to wait for a // single peer to decide if the rate limit has been reached. @@ -174,15 +174,15 @@ enum Status { message RateLimitResp { // The status of the rate limit. Status status = 1; - // The currently configured request limit (Identical to RateLimitRequest.rate_limit_config.limit). + // The currently configured request limit (Identical to [[RateLimitReq.limit]]). int64 limit = 2; - // This is the number of requests remaining before the limit is hit. + // This is the number of requests remaining before the rate limit is hit but after subtracting the hits from the current request int64 remaining = 3; // This is the time when the rate limit span will be reset, provided as a unix timestamp in milliseconds. int64 reset_time = 4; // Contains the error; If set all other values should be ignored string error = 5; - // This is additional metadata that a client might find useful. (IE: Additional headers, corrdinator ownership, etc..) + // This is additional metadata that a client might find useful. (IE: Additional headers, coordinator ownership, etc..) map metadata = 6; } diff --git a/gubernator_grpc.pb.go b/gubernator_grpc.pb.go index 20b4c442..209b75aa 100644 --- a/gubernator_grpc.pb.go +++ b/gubernator_grpc.pb.go @@ -16,14 +16,13 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v3.21.7 +// - protoc (unknown) // source: gubernator.proto package gubernator import ( context "context" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -77,7 +76,7 @@ func (c *v1Client) HealthCheck(ctx context.Context, in *HealthCheckReq, opts ... } // V1Server is the server API for V1 service. -// All implementations must embed UnimplementedV1Server +// All implementations should embed UnimplementedV1Server // for forward compatibility type V1Server interface { // Given a list of rate limit requests, return the rate limits of each. @@ -85,10 +84,9 @@ type V1Server interface { // This method is for round trip benchmarking and can be used by // the client to determine connectivity to the server HealthCheck(context.Context, *HealthCheckReq) (*HealthCheckResp, error) - mustEmbedUnimplementedV1Server() } -// UnimplementedV1Server must be embedded to have forward compatible implementations. +// UnimplementedV1Server should be embedded to have forward compatible implementations. type UnimplementedV1Server struct { } @@ -98,7 +96,6 @@ func (UnimplementedV1Server) GetRateLimits(context.Context, *GetRateLimitsReq) ( func (UnimplementedV1Server) HealthCheck(context.Context, *HealthCheckReq) (*HealthCheckResp, error) { return nil, status.Errorf(codes.Unimplemented, "method HealthCheck not implemented") } -func (UnimplementedV1Server) mustEmbedUnimplementedV1Server() {} // UnsafeV1Server may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to V1Server will diff --git a/peers.pb.go b/peers.pb.go index 597cd02a..c46650b7 100644 --- a/peers.pb.go +++ b/peers.pb.go @@ -16,17 +16,16 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.28.1 -// protoc v3.21.7 +// protoc (unknown) // source: peers.proto package gubernator import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( diff --git a/peers.proto b/peers.proto index 5caefae4..1ce2a431 100644 --- a/peers.proto +++ b/peers.proto @@ -26,10 +26,10 @@ import "gubernator.proto"; // NOTE: For use by gubernator peers only service PeersV1 { - // Used by peers to relay batches of requests to an authoritative peer + // Used by peers to relay batches of requests to an owner peer rpc GetPeerRateLimits (GetPeerRateLimitsReq) returns (GetPeerRateLimitsResp) {} - // Used by peers send global rate limit updates to other peers + // Used by owner peers to send global rate limit updates to non-owner peers rpc UpdatePeerGlobals (UpdatePeerGlobalsReq) returns (UpdatePeerGlobalsResp) {} } diff --git a/peers_grpc.pb.go b/peers_grpc.pb.go index 355c43d6..e74a7d16 100644 --- a/peers_grpc.pb.go +++ b/peers_grpc.pb.go @@ -16,14 +16,13 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v3.21.7 +// - protoc (unknown) // source: peers.proto package gubernator import ( context "context" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -43,9 +42,9 @@ const ( // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. type PeersV1Client interface { - // Used by peers to relay batches of requests to an authoritative peer + // Used by peers to relay batches of requests to an owner peer GetPeerRateLimits(ctx context.Context, in *GetPeerRateLimitsReq, opts ...grpc.CallOption) (*GetPeerRateLimitsResp, error) - // Used by peers send global rate limit updates to other peers + // Used by owner peers to send global rate limit updates to non-owner peers UpdatePeerGlobals(ctx context.Context, in *UpdatePeerGlobalsReq, opts ...grpc.CallOption) (*UpdatePeerGlobalsResp, error) } @@ -76,17 +75,16 @@ func (c *peersV1Client) UpdatePeerGlobals(ctx context.Context, in *UpdatePeerGlo } // PeersV1Server is the server API for PeersV1 service. -// All implementations must embed UnimplementedPeersV1Server +// All implementations should embed UnimplementedPeersV1Server // for forward compatibility type PeersV1Server interface { - // Used by peers to relay batches of requests to an authoritative peer + // Used by peers to relay batches of requests to an owner peer GetPeerRateLimits(context.Context, *GetPeerRateLimitsReq) (*GetPeerRateLimitsResp, error) - // Used by peers send global rate limit updates to other peers + // Used by owner peers to send global rate limit updates to non-owner peers UpdatePeerGlobals(context.Context, *UpdatePeerGlobalsReq) (*UpdatePeerGlobalsResp, error) - mustEmbedUnimplementedPeersV1Server() } -// UnimplementedPeersV1Server must be embedded to have forward compatible implementations. +// UnimplementedPeersV1Server should be embedded to have forward compatible implementations. type UnimplementedPeersV1Server struct { } @@ -96,7 +94,6 @@ func (UnimplementedPeersV1Server) GetPeerRateLimits(context.Context, *GetPeerRat func (UnimplementedPeersV1Server) UpdatePeerGlobals(context.Context, *UpdatePeerGlobalsReq) (*UpdatePeerGlobalsResp, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdatePeerGlobals not implemented") } -func (UnimplementedPeersV1Server) mustEmbedUnimplementedPeersV1Server() {} // UnsafePeersV1Server may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to PeersV1Server will diff --git a/python/gubernator/gubernator_pb2.py b/python/gubernator/gubernator_pb2.py index ed3b2695..51749b92 100644 --- a/python/gubernator/gubernator_pb2.py +++ b/python/gubernator/gubernator_pb2.py @@ -1,11 +1,12 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: gubernator.proto +# Protobuf Python Version: 4.25.2 """Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() @@ -14,44 +15,44 @@ from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x10gubernator.proto\x12\rpb.gubernator\x1a\x1cgoogle/api/annotations.proto\"A\n\x10GetRateLimitsReq\x12-\n\x08requests\x18\x01 \x03(\x0b\x32\x1b.pb.gubernator.RateLimitReq\"D\n\x11GetRateLimitsResp\x12/\n\tresponses\x18\x01 \x03(\x0b\x32\x1c.pb.gubernator.RateLimitResp\"\xb4\x02\n\x0cRateLimitReq\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\nunique_key\x18\x02 \x01(\t\x12\x0c\n\x04hits\x18\x03 \x01(\x03\x12\r\n\x05limit\x18\x04 \x01(\x03\x12\x10\n\x08\x64uration\x18\x05 \x01(\x03\x12+\n\talgorithm\x18\x06 \x01(\x0e\x32\x18.pb.gubernator.Algorithm\x12)\n\x08\x62\x65havior\x18\x07 \x01(\x0e\x32\x17.pb.gubernator.Behavior\x12\r\n\x05\x62urst\x18\x08 \x01(\x03\x12;\n\x08metadata\x18\t \x03(\x0b\x32).pb.gubernator.RateLimitReq.MetadataEntry\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xea\x01\n\rRateLimitResp\x12%\n\x06status\x18\x01 \x01(\x0e\x32\x15.pb.gubernator.Status\x12\r\n\x05limit\x18\x02 \x01(\x03\x12\x11\n\tremaining\x18\x03 \x01(\x03\x12\x12\n\nreset_time\x18\x04 \x01(\x03\x12\r\n\x05\x65rror\x18\x05 \x01(\t\x12<\n\x08metadata\x18\x06 \x03(\x0b\x32*.pb.gubernator.RateLimitResp.MetadataEntry\x1a/\n\rMetadataEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x10\n\x0eHealthCheckReq\"F\n\x0fHealthCheckResp\x12\x0e\n\x06status\x18\x01 \x01(\t\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\x12\n\npeer_count\x18\x03 \x01(\x05*/\n\tAlgorithm\x12\x10\n\x0cTOKEN_BUCKET\x10\x00\x12\x10\n\x0cLEAKY_BUCKET\x10\x01*w\n\x08\x42\x65havior\x12\x0c\n\x08\x42\x41TCHING\x10\x00\x12\x0f\n\x0bNO_BATCHING\x10\x01\x12\n\n\x06GLOBAL\x10\x02\x12\x19\n\x15\x44URATION_IS_GREGORIAN\x10\x04\x12\x13\n\x0fRESET_REMAINING\x10\x08\x12\x10\n\x0cMULTI_REGION\x10\x10*)\n\x06Status\x12\x0f\n\x0bUNDER_LIMIT\x10\x00\x12\x0e\n\nOVER_LIMIT\x10\x01\x32\xdd\x01\n\x02V1\x12p\n\rGetRateLimits\x12\x1f.pb.gubernator.GetRateLimitsReq\x1a .pb.gubernator.GetRateLimitsResp\"\x1c\x82\xd3\xe4\x93\x02\x16\"\x11/v1/GetRateLimits:\x01*\x12\x65\n\x0bHealthCheck\x12\x1d.pb.gubernator.HealthCheckReq\x1a\x1e.pb.gubernator.HealthCheckResp\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/v1/HealthCheckB\"Z\x1dgithub.com/mailgun/gubernator\x80\x01\x01\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x10gubernator.proto\x12\rpb.gubernator\x1a\x1cgoogle/api/annotations.proto\"K\n\x10GetRateLimitsReq\x12\x37\n\x08requests\x18\x01 \x03(\x0b\x32\x1b.pb.gubernator.RateLimitReqR\x08requests\"O\n\x11GetRateLimitsResp\x12:\n\tresponses\x18\x01 \x03(\x0b\x32\x1c.pb.gubernator.RateLimitRespR\tresponses\"\x8e\x03\n\x0cRateLimitReq\x12\x12\n\x04name\x18\x01 \x01(\tR\x04name\x12\x1d\n\nunique_key\x18\x02 \x01(\tR\tuniqueKey\x12\x12\n\x04hits\x18\x03 \x01(\x03R\x04hits\x12\x14\n\x05limit\x18\x04 \x01(\x03R\x05limit\x12\x1a\n\x08\x64uration\x18\x05 \x01(\x03R\x08\x64uration\x12\x36\n\talgorithm\x18\x06 \x01(\x0e\x32\x18.pb.gubernator.AlgorithmR\talgorithm\x12\x33\n\x08\x62\x65havior\x18\x07 \x01(\x0e\x32\x17.pb.gubernator.BehaviorR\x08\x62\x65havior\x12\x14\n\x05\x62urst\x18\x08 \x01(\x03R\x05\x62urst\x12\x45\n\x08metadata\x18\t \x03(\x0b\x32).pb.gubernator.RateLimitReq.MetadataEntryR\x08metadata\x1a;\n\rMetadataEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n\x05value\x18\x02 \x01(\tR\x05value:\x02\x38\x01\"\xac\x02\n\rRateLimitResp\x12-\n\x06status\x18\x01 \x01(\x0e\x32\x15.pb.gubernator.StatusR\x06status\x12\x14\n\x05limit\x18\x02 \x01(\x03R\x05limit\x12\x1c\n\tremaining\x18\x03 \x01(\x03R\tremaining\x12\x1d\n\nreset_time\x18\x04 \x01(\x03R\tresetTime\x12\x14\n\x05\x65rror\x18\x05 \x01(\tR\x05\x65rror\x12\x46\n\x08metadata\x18\x06 \x03(\x0b\x32*.pb.gubernator.RateLimitResp.MetadataEntryR\x08metadata\x1a;\n\rMetadataEntry\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n\x05value\x18\x02 \x01(\tR\x05value:\x02\x38\x01\"\x10\n\x0eHealthCheckReq\"b\n\x0fHealthCheckResp\x12\x16\n\x06status\x18\x01 \x01(\tR\x06status\x12\x18\n\x07message\x18\x02 \x01(\tR\x07message\x12\x1d\n\npeer_count\x18\x03 \x01(\x05R\tpeerCount*/\n\tAlgorithm\x12\x10\n\x0cTOKEN_BUCKET\x10\x00\x12\x10\n\x0cLEAKY_BUCKET\x10\x01*w\n\x08\x42\x65havior\x12\x0c\n\x08\x42\x41TCHING\x10\x00\x12\x0f\n\x0bNO_BATCHING\x10\x01\x12\n\n\x06GLOBAL\x10\x02\x12\x19\n\x15\x44URATION_IS_GREGORIAN\x10\x04\x12\x13\n\x0fRESET_REMAINING\x10\x08\x12\x10\n\x0cMULTI_REGION\x10\x10*)\n\x06Status\x12\x0f\n\x0bUNDER_LIMIT\x10\x00\x12\x0e\n\nOVER_LIMIT\x10\x01\x32\xdd\x01\n\x02V1\x12p\n\rGetRateLimits\x12\x1f.pb.gubernator.GetRateLimitsReq\x1a .pb.gubernator.GetRateLimitsResp\"\x1c\x82\xd3\xe4\x93\x02\x16\"\x11/v1/GetRateLimits:\x01*\x12\x65\n\x0bHealthCheck\x12\x1d.pb.gubernator.HealthCheckReq\x1a\x1e.pb.gubernator.HealthCheckResp\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/v1/HealthCheckB\"Z\x1dgithub.com/mailgun/gubernator\x80\x01\x01\x62\x06proto3') -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'gubernator_pb2', globals()) +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'gubernator_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - DESCRIPTOR._serialized_options = b'Z\035github.com/mailgun/gubernator\200\001\001' - _RATELIMITREQ_METADATAENTRY._options = None - _RATELIMITREQ_METADATAENTRY._serialized_options = b'8\001' - _RATELIMITRESP_METADATAENTRY._options = None - _RATELIMITRESP_METADATAENTRY._serialized_options = b'8\001' - _V1.methods_by_name['GetRateLimits']._options = None - _V1.methods_by_name['GetRateLimits']._serialized_options = b'\202\323\344\223\002\026\"\021/v1/GetRateLimits:\001*' - _V1.methods_by_name['HealthCheck']._options = None - _V1.methods_by_name['HealthCheck']._serialized_options = b'\202\323\344\223\002\021\022\017/v1/HealthCheck' - _ALGORITHM._serialized_start=840 - _ALGORITHM._serialized_end=887 - _BEHAVIOR._serialized_start=889 - _BEHAVIOR._serialized_end=1008 - _STATUS._serialized_start=1010 - _STATUS._serialized_end=1051 - _GETRATELIMITSREQ._serialized_start=65 - _GETRATELIMITSREQ._serialized_end=130 - _GETRATELIMITSRESP._serialized_start=132 - _GETRATELIMITSRESP._serialized_end=200 - _RATELIMITREQ._serialized_start=203 - _RATELIMITREQ._serialized_end=511 - _RATELIMITREQ_METADATAENTRY._serialized_start=464 - _RATELIMITREQ_METADATAENTRY._serialized_end=511 - _RATELIMITRESP._serialized_start=514 - _RATELIMITRESP._serialized_end=748 - _RATELIMITRESP_METADATAENTRY._serialized_start=464 - _RATELIMITRESP_METADATAENTRY._serialized_end=511 - _HEALTHCHECKREQ._serialized_start=750 - _HEALTHCHECKREQ._serialized_end=766 - _HEALTHCHECKRESP._serialized_start=768 - _HEALTHCHECKRESP._serialized_end=838 - _V1._serialized_start=1054 - _V1._serialized_end=1275 + _globals['DESCRIPTOR']._options = None + _globals['DESCRIPTOR']._serialized_options = b'Z\035github.com/mailgun/gubernator\200\001\001' + _globals['_RATELIMITREQ_METADATAENTRY']._options = None + _globals['_RATELIMITREQ_METADATAENTRY']._serialized_options = b'8\001' + _globals['_RATELIMITRESP_METADATAENTRY']._options = None + _globals['_RATELIMITRESP_METADATAENTRY']._serialized_options = b'8\001' + _globals['_V1'].methods_by_name['GetRateLimits']._options = None + _globals['_V1'].methods_by_name['GetRateLimits']._serialized_options = b'\202\323\344\223\002\026\"\021/v1/GetRateLimits:\001*' + _globals['_V1'].methods_by_name['HealthCheck']._options = None + _globals['_V1'].methods_by_name['HealthCheck']._serialized_options = b'\202\323\344\223\002\021\022\017/v1/HealthCheck' + _globals['_ALGORITHM']._serialized_start=1045 + _globals['_ALGORITHM']._serialized_end=1092 + _globals['_BEHAVIOR']._serialized_start=1094 + _globals['_BEHAVIOR']._serialized_end=1213 + _globals['_STATUS']._serialized_start=1215 + _globals['_STATUS']._serialized_end=1256 + _globals['_GETRATELIMITSREQ']._serialized_start=65 + _globals['_GETRATELIMITSREQ']._serialized_end=140 + _globals['_GETRATELIMITSRESP']._serialized_start=142 + _globals['_GETRATELIMITSRESP']._serialized_end=221 + _globals['_RATELIMITREQ']._serialized_start=224 + _globals['_RATELIMITREQ']._serialized_end=622 + _globals['_RATELIMITREQ_METADATAENTRY']._serialized_start=563 + _globals['_RATELIMITREQ_METADATAENTRY']._serialized_end=622 + _globals['_RATELIMITRESP']._serialized_start=625 + _globals['_RATELIMITRESP']._serialized_end=925 + _globals['_RATELIMITRESP_METADATAENTRY']._serialized_start=563 + _globals['_RATELIMITRESP_METADATAENTRY']._serialized_end=622 + _globals['_HEALTHCHECKREQ']._serialized_start=927 + _globals['_HEALTHCHECKREQ']._serialized_end=943 + _globals['_HEALTHCHECKRESP']._serialized_start=945 + _globals['_HEALTHCHECKRESP']._serialized_end=1043 + _globals['_V1']._serialized_start=1259 + _globals['_V1']._serialized_end=1480 # @@protoc_insertion_point(module_scope) diff --git a/python/gubernator/peers_pb2.py b/python/gubernator/peers_pb2.py index 98ade704..116ee6eb 100644 --- a/python/gubernator/peers_pb2.py +++ b/python/gubernator/peers_pb2.py @@ -1,11 +1,12 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! # source: peers.proto +# Protobuf Python Version: 4.25.2 """Generated protocol buffer code.""" -from google.protobuf.internal import builder as _builder from google.protobuf import descriptor as _descriptor from google.protobuf import descriptor_pool as _descriptor_pool from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() @@ -14,24 +15,24 @@ import gubernator_pb2 as gubernator__pb2 -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0bpeers.proto\x12\rpb.gubernator\x1a\x10gubernator.proto\"E\n\x14GetPeerRateLimitsReq\x12-\n\x08requests\x18\x01 \x03(\x0b\x32\x1b.pb.gubernator.RateLimitReq\"J\n\x15GetPeerRateLimitsResp\x12\x31\n\x0brate_limits\x18\x01 \x03(\x0b\x32\x1c.pb.gubernator.RateLimitResp\"H\n\x14UpdatePeerGlobalsReq\x12\x30\n\x07globals\x18\x01 \x03(\x0b\x32\x1f.pb.gubernator.UpdatePeerGlobal\"z\n\x10UpdatePeerGlobal\x12\x0b\n\x03key\x18\x01 \x01(\t\x12,\n\x06status\x18\x02 \x01(\x0b\x32\x1c.pb.gubernator.RateLimitResp\x12+\n\talgorithm\x18\x03 \x01(\x0e\x32\x18.pb.gubernator.Algorithm\"\x17\n\x15UpdatePeerGlobalsResp2\xcd\x01\n\x07PeersV1\x12`\n\x11GetPeerRateLimits\x12#.pb.gubernator.GetPeerRateLimitsReq\x1a$.pb.gubernator.GetPeerRateLimitsResp\"\x00\x12`\n\x11UpdatePeerGlobals\x12#.pb.gubernator.UpdatePeerGlobalsReq\x1a$.pb.gubernator.UpdatePeerGlobalsResp\"\x00\x42\"Z\x1dgithub.com/mailgun/gubernator\x80\x01\x01\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0bpeers.proto\x12\rpb.gubernator\x1a\x10gubernator.proto\"O\n\x14GetPeerRateLimitsReq\x12\x37\n\x08requests\x18\x01 \x03(\x0b\x32\x1b.pb.gubernator.RateLimitReqR\x08requests\"V\n\x15GetPeerRateLimitsResp\x12=\n\x0brate_limits\x18\x01 \x03(\x0b\x32\x1c.pb.gubernator.RateLimitRespR\nrateLimits\"Q\n\x14UpdatePeerGlobalsReq\x12\x39\n\x07globals\x18\x01 \x03(\x0b\x32\x1f.pb.gubernator.UpdatePeerGlobalR\x07globals\"\x92\x01\n\x10UpdatePeerGlobal\x12\x10\n\x03key\x18\x01 \x01(\tR\x03key\x12\x34\n\x06status\x18\x02 \x01(\x0b\x32\x1c.pb.gubernator.RateLimitRespR\x06status\x12\x36\n\talgorithm\x18\x03 \x01(\x0e\x32\x18.pb.gubernator.AlgorithmR\talgorithm\"\x17\n\x15UpdatePeerGlobalsResp2\xcd\x01\n\x07PeersV1\x12`\n\x11GetPeerRateLimits\x12#.pb.gubernator.GetPeerRateLimitsReq\x1a$.pb.gubernator.GetPeerRateLimitsResp\"\x00\x12`\n\x11UpdatePeerGlobals\x12#.pb.gubernator.UpdatePeerGlobalsReq\x1a$.pb.gubernator.UpdatePeerGlobalsResp\"\x00\x42\"Z\x1dgithub.com/mailgun/gubernator\x80\x01\x01\x62\x06proto3') -_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals()) -_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'peers_pb2', globals()) +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'peers_pb2', _globals) if _descriptor._USE_C_DESCRIPTORS == False: - - DESCRIPTOR._options = None - DESCRIPTOR._serialized_options = b'Z\035github.com/mailgun/gubernator\200\001\001' - _GETPEERRATELIMITSREQ._serialized_start=48 - _GETPEERRATELIMITSREQ._serialized_end=117 - _GETPEERRATELIMITSRESP._serialized_start=119 - _GETPEERRATELIMITSRESP._serialized_end=193 - _UPDATEPEERGLOBALSREQ._serialized_start=195 - _UPDATEPEERGLOBALSREQ._serialized_end=267 - _UPDATEPEERGLOBAL._serialized_start=269 - _UPDATEPEERGLOBAL._serialized_end=391 - _UPDATEPEERGLOBALSRESP._serialized_start=393 - _UPDATEPEERGLOBALSRESP._serialized_end=416 - _PEERSV1._serialized_start=419 - _PEERSV1._serialized_end=624 + _globals['DESCRIPTOR']._options = None + _globals['DESCRIPTOR']._serialized_options = b'Z\035github.com/mailgun/gubernator\200\001\001' + _globals['_GETPEERRATELIMITSREQ']._serialized_start=48 + _globals['_GETPEERRATELIMITSREQ']._serialized_end=127 + _globals['_GETPEERRATELIMITSRESP']._serialized_start=129 + _globals['_GETPEERRATELIMITSRESP']._serialized_end=215 + _globals['_UPDATEPEERGLOBALSREQ']._serialized_start=217 + _globals['_UPDATEPEERGLOBALSREQ']._serialized_end=298 + _globals['_UPDATEPEERGLOBAL']._serialized_start=301 + _globals['_UPDATEPEERGLOBAL']._serialized_end=447 + _globals['_UPDATEPEERGLOBALSRESP']._serialized_start=449 + _globals['_UPDATEPEERGLOBALSRESP']._serialized_end=472 + _globals['_PEERSV1']._serialized_start=475 + _globals['_PEERSV1']._serialized_end=680 # @@protoc_insertion_point(module_scope) diff --git a/python/gubernator/peers_pb2_grpc.py b/python/gubernator/peers_pb2_grpc.py index 7b8f4c99..9ebb860d 100644 --- a/python/gubernator/peers_pb2_grpc.py +++ b/python/gubernator/peers_pb2_grpc.py @@ -32,14 +32,14 @@ class PeersV1Servicer(object): """ def GetPeerRateLimits(self, request, context): - """Used by peers to relay batches of requests to an authoritative peer + """Used by peers to relay batches of requests to an owner peer """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!') def UpdatePeerGlobals(self, request, context): - """Used by peers send global rate limit updates to other peers + """Used by owner peers to send global rate limit updates to non-owner peers """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!')