Skip to content

Commit

Permalink
Merge pull request #249 from hello-wn/feat-reflection
Browse files Browse the repository at this point in the history
feat: enable grpc reflection
  • Loading branch information
nicholasxuu authored Aug 28, 2023
2 parents 6c60a91 + bf31059 commit 630673e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# CHANGELOG

## [Unreleased] - 2022-10-25
## [Unreleased] - 2023-08-21
### Added
- Support grpc reflection

## [3.1.0] - 2022-11-10
### Changed
- Upgrade depebdebcies to support python 3.10+
- Changed CI from Travis CI to Github Actions

## [3.0.0] - 2022-06-24

### Added
- Added multiprocessing worker class
### Changed
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
grpcio>=1.27.0,<1.49.0
grpcio-tools>=1.27.0,<1.49.0
grpcio-reflection
protobuf<4.0.0
pendulum
blinker
Expand Down
4 changes: 4 additions & 0 deletions sea/server/multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import List

import grpc
from grpc_reflection.v1alpha import reflection

from sea import signals

Expand Down Expand Up @@ -45,6 +46,9 @@ def _run_server(self, bind_address):
],
)
self.server = server # set server in slave process
# register reflection service
if self.app.config.get("GRPC_REFLECTION_SERVICES"):
reflection.enable_server_reflection((reflection.SERVICE_NAME, *self.app.config["GRPC_REFLECTION_SERVICES"]), self.server)

for _, (add_func, servicer) in self.app.servicers.items():
add_func(servicer(), server)
Expand Down
4 changes: 4 additions & 0 deletions sea/server/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from concurrent import futures

import grpc
from grpc_reflection.v1alpha import reflection

from sea import signals

Expand All @@ -28,6 +29,9 @@ def run(self):
from prometheus_client import start_http_server

start_http_server(self.app.config["PROMETHEUS_PORT"])
# register reflection service
if self.app.config.get("GRPC_REFLECTION_SERVICES"):
reflection.enable_server_reflection((reflection.SERVICE_NAME, *self.app.config["GRPC_REFLECTION_SERVICES"]), self.server)
# run grpc server
for name, (add_func, servicer) in self.app.servicers.items():
add_func(servicer(), self.server)
Expand Down
1 change: 1 addition & 0 deletions tests/wd/configs/default/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@

TIMEZONE = "Asia/Shanghai"
GRPC_GRACE = 0
GRPC_REFLECTION_SERVICES = ["helloworld.Greeter"]
PROMETHEUS_SCRAPE = True

0 comments on commit 630673e

Please sign in to comment.