Skip to content

Commit

Permalink
small cleanups
Browse files Browse the repository at this point in the history
Signed-off-by: Edward Oakes <[email protected]>
  • Loading branch information
edoakes committed Jan 18, 2025
1 parent 252e78c commit 1450275
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions python/ray/serve/_private/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@
os.environ.get("RAY_SERVE_GRPC_MAX_MESSAGE_SIZE", (2 * 1024 * 1024 * 1024) - 1)
)

# Serve's gRPC server options.
SERVE_GRPC_OPTIONS = [
# Default options passed when constructing gRPC servers.
DEFAULT_GRPC_SERVER_OPTIONS = [
("grpc.max_send_message_length", RAY_SERVE_GRPC_MAX_MESSAGE_SIZE),
("grpc.max_receive_message_length", RAY_SERVE_GRPC_MAX_MESSAGE_SIZE),
]
Expand Down
12 changes: 8 additions & 4 deletions python/ray/serve/_private/grpc_util.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Sequence
from typing import Callable, List, Optional, Sequence, Tuple

import grpc
from grpc.aio._server import Server

from ray.serve._private.constants import SERVE_GRPC_OPTIONS
from ray.serve._private.constants import DEFAULT_GRPC_SERVER_OPTIONS


class gRPCServer(Server):
Expand Down Expand Up @@ -51,7 +51,11 @@ def add_generic_rpc_handlers(
super().add_generic_rpc_handlers(generic_rpc_handlers)


def create_serve_grpc_server(service_handler_factory):
def create_serve_grpc_server(
service_handler_factory: Callable,
*,
extra_options: Optional[List[Tuple[str, str]]] = None
):
"""Custom function to create Serve's gRPC server.
This function works similar to `grpc.server()`, but it creates a Serve defined
Expand All @@ -63,7 +67,7 @@ def create_serve_grpc_server(service_handler_factory):
thread_pool=None,
generic_handlers=(),
interceptors=(),
options=SERVE_GRPC_OPTIONS,
options=DEFAULT_GRPC_SERVER_OPTIONS + (extra_options or []),
maximum_concurrent_rpcs=None,
compression=None,
service_handler_factory=service_handler_factory,
Expand Down

0 comments on commit 1450275

Please sign in to comment.