Skip to content

Commit

Permalink
grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
William Parsley committed Nov 17, 2023
1 parent a26334c commit 1ca9a69
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ message HealthCheckResponse {

service Health {
rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
}
}
25 changes: 20 additions & 5 deletions sdk/python/feast/transformation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from concurrent import futures

import grpc
from grpc_health.v1 import health
from grpc_health.v1 import health_pb2_grpc
import pyarrow as pa
from grpc_reflection.v1alpha import reflection

Expand All @@ -21,11 +19,28 @@
TransformationServiceServicer,
add_TransformationServiceServicer_to_server,
)
from feast.protos.feast.third_party.grpc.health.v1.HealthService_pb2 import (
HealthCheckResponse,
ServingStatus,
)
from feast.protos.feast.third_party.grpc.health.v1.HealthService_pb2_grpc import (
HealthServicer,
add_HealthServicer_to_server,
)
from feast.version import get_version

log = logging.getLogger(__name__)


class HealthServer(HealthServicer):
def __init__(self) -> None:
super().__init__()

def Check(self, request, context):
response = HealthCheckResponse(status=ServingStatus.SERVING)
return response


class TransformationServer(TransformationServiceServicer):
def __init__(self, fs: FeatureStore) -> None:
super().__init__()
Expand Down Expand Up @@ -64,12 +79,12 @@ def TransformFeatures(self, request, context):


def start_server(store: FeatureStore, port: int):
log.info("Starting server..")
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
add_TransformationServiceServicer_to_server(TransformationServer(store), server)

# Add health check service
health_servicer = health.HealthServicer()
health_pb2_grpc.add_HealthServicer_to_server(health_servicer, server)
# Add health check service to server
add_HealthServicer_to_server(HealthServer(), server)

service_names_available_for_reflection = (
DESCRIPTOR.services_by_name["TransformationService"].full_name,
Expand Down

0 comments on commit 1ca9a69

Please sign in to comment.