Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Now properly generating GRPC files for python3
Browse files Browse the repository at this point in the history
  • Loading branch information
thrawn01 committed Feb 18, 2019
1 parent 2d39ecb commit 96bf538
Show file tree
Hide file tree
Showing 13 changed files with 822 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea/
.vscode/
__pycache__
5 changes: 5 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in the repo.
* @thrawn01
Empty file added python/gubernator/__init__.py
Empty file.
14 changes: 14 additions & 0 deletions python/gubernator/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import gubernator.pb.ratelimit_pb2 as pb
import gubernator.pb.ratelimit_pb2_grpc as pb_grpc
import grpc


class Client(object):
def __init__(self, endpoint='127.0.0.1:9090', timeout=None,
username=None, password=None):
channel = grpc.insecure_channel(endpoint)
print(dir(pb))
self.stub = pb_grpc.RateLimitServiceStub(channel)

def ping(self):
print(self.stub.Ping(pb.HealthCheckRequest()))
Empty file.
137 changes: 137 additions & 0 deletions python/gubernator/pb/peers_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions python/gubernator/pb/peers_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
import grpc

import peers_pb2 as peers__pb2


class PeersServiceStub(object):
# missing associated documentation comment in .proto file
pass

def __init__(self, channel):
"""Constructor.
Args:
channel: A grpc.Channel.
"""
self.GetPeerRateLimits = channel.unary_unary(
'/pb.gubernator.PeersService/GetPeerRateLimits',
request_serializer=peers__pb2.PeerRateLimitRequest.SerializeToString,
response_deserializer=peers__pb2.PeerRateLimitResponse.FromString,
)


class PeersServiceServicer(object):
# missing associated documentation comment in .proto file
pass

def GetPeerRateLimits(self, request, context):
"""Used by peers to relay batches of requests to an authoritative peer
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')


def add_PeersServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
'GetPeerRateLimits': grpc.unary_unary_rpc_method_handler(
servicer.GetPeerRateLimits,
request_deserializer=peers__pb2.PeerRateLimitRequest.FromString,
response_serializer=peers__pb2.PeerRateLimitResponse.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'pb.gubernator.PeersService', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))
Loading

0 comments on commit 96bf538

Please sign in to comment.