aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/python/grpcio_health_checking
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/grpcio_health_checking')
-rw-r--r--src/python/grpcio_health_checking/MANIFEST.in3
-rw-r--r--src/python/grpcio_health_checking/grpc/__init__.py (renamed from src/python/grpcio_health_checking/grpc_health/health/v1/__init__.py)2
-rw-r--r--src/python/grpcio_health_checking/grpc/health/__init__.py (renamed from src/python/grpcio_health_checking/grpc_health/__init__.py)0
-rw-r--r--src/python/grpcio_health_checking/grpc/health/v1/__init__.py (renamed from src/python/grpcio_health_checking/grpc_health/health/__init__.py)0
-rw-r--r--src/python/grpcio_health_checking/grpc/health/v1/health.py (renamed from src/python/grpcio_health_checking/grpc_health/health/v1/health.py)19
-rw-r--r--src/python/grpcio_health_checking/grpc_version.py32
-rw-r--r--src/python/grpcio_health_checking/health_commands.py29
-rw-r--r--src/python/grpcio_health_checking/setup.py23
8 files changed, 70 insertions, 38 deletions
diff --git a/src/python/grpcio_health_checking/MANIFEST.in b/src/python/grpcio_health_checking/MANIFEST.in
index 7d26647697..7407f646d1 100644
--- a/src/python/grpcio_health_checking/MANIFEST.in
+++ b/src/python/grpcio_health_checking/MANIFEST.in
@@ -1,3 +1,4 @@
+include grpc_version.py
include health_commands.py
-graft grpc_health
+graft grpc
global-exclude *.pyc
diff --git a/src/python/grpcio_health_checking/grpc_health/health/v1/__init__.py b/src/python/grpcio_health_checking/grpc/__init__.py
index 7086519106..fcc7048815 100644
--- a/src/python/grpcio_health_checking/grpc_health/health/v1/__init__.py
+++ b/src/python/grpcio_health_checking/grpc/__init__.py
@@ -27,4 +27,4 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
+__import__('pkg_resources').declare_namespace(__name__)
diff --git a/src/python/grpcio_health_checking/grpc_health/__init__.py b/src/python/grpcio_health_checking/grpc/health/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_health_checking/grpc_health/__init__.py
+++ b/src/python/grpcio_health_checking/grpc/health/__init__.py
diff --git a/src/python/grpcio_health_checking/grpc_health/health/__init__.py b/src/python/grpcio_health_checking/grpc/health/v1/__init__.py
index 7086519106..7086519106 100644
--- a/src/python/grpcio_health_checking/grpc_health/health/__init__.py
+++ b/src/python/grpcio_health_checking/grpc/health/v1/__init__.py
diff --git a/src/python/grpcio_health_checking/grpc_health/health/v1/health.py b/src/python/grpcio_health_checking/grpc/health/v1/health.py
index 8da60c70cb..8108ac1096 100644
--- a/src/python/grpcio_health_checking/grpc_health/health/v1/health.py
+++ b/src/python/grpcio_health_checking/grpc/health/v1/health.py
@@ -31,10 +31,12 @@
import threading
-from grpc_health.health.v1 import health_pb2
+import grpc
+from grpc.health.v1 import health_pb2
-class HealthServicer(health_pb2.BetaHealthServicer):
+
+class HealthServicer(health_pb2.HealthServicer):
"""Servicer handling RPCs for service statuses."""
def __init__(self):
@@ -43,14 +45,12 @@ class HealthServicer(health_pb2.BetaHealthServicer):
def Check(self, request, context):
with self._server_status_lock:
- if request.service not in self._server_status:
- # TODO(atash): once the Python API has a way of setting the server
- # status, bring us into conformance with the health check spec by
- # returning the NOT_FOUND status here.
- raise NotImplementedError()
+ status = self._server_status.get(request.service)
+ if status is None:
+ context.set_code(grpc.StatusCode.NOT_FOUND)
+ return health_pb2.HealthCheckResponse()
else:
- return health_pb2.HealthCheckResponse(
- status=self._server_status[request.service])
+ return health_pb2.HealthCheckResponse(status=status)
def set(self, service, status):
"""Sets the status of a service.
@@ -63,4 +63,3 @@ class HealthServicer(health_pb2.BetaHealthServicer):
"""
with self._server_status_lock:
self._server_status[service] = status
-
diff --git a/src/python/grpcio_health_checking/grpc_version.py b/src/python/grpcio_health_checking/grpc_version.py
new file mode 100644
index 0000000000..2e48fde893
--- /dev/null
+++ b/src/python/grpcio_health_checking/grpc_version.py
@@ -0,0 +1,32 @@
+# Copyright 2016, Google Inc.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above
+# copyright notice, this list of conditions and the following disclaimer
+# in the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Google Inc. nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio_health_checking/grpc_version.py.template`!!!
+
+VERSION='1.0.0rc1'
diff --git a/src/python/grpcio_health_checking/health_commands.py b/src/python/grpcio_health_checking/health_commands.py
index a7a59f6974..66df25da63 100644
--- a/src/python/grpcio_health_checking/health_commands.py
+++ b/src/python/grpcio_health_checking/health_commands.py
@@ -29,16 +29,10 @@
"""Provides distutils command classes for the GRPC Python setup process."""
-import distutils
-import glob
import os
-import os.path
import shutil
-import subprocess
-import sys
import setuptools
-from setuptools.command import build_py
ROOT_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
HEALTH_PROTO = os.path.join(ROOT_DIR, '../../proto/grpc/health/v1/health.proto')
@@ -60,12 +54,25 @@ class CopyProtoModules(setuptools.Command):
if os.path.isfile(HEALTH_PROTO):
shutil.copyfile(
HEALTH_PROTO,
- os.path.join(ROOT_DIR, 'grpc_health/health/v1/health.proto'))
+ os.path.join(ROOT_DIR, 'grpc/health/v1/health.proto'))
-class BuildPy(build_py.build_py):
- """Custom project build command."""
+class BuildPackageProtos(setuptools.Command):
+ """Command to generate project *_pb2.py modules from proto files."""
+
+ description = 'build grpc protobuf modules'
+ user_options = []
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
def run(self):
- self.run_command('build_proto_modules')
- build_py.build_py.run(self)
+ # due to limitations of the proto generator, we require that only *one*
+ # directory is provided as an 'include' directory. We assume it's the '' key
+ # to `self.distribution.package_dir` (and get a key error if it's not
+ # there).
+ from grpc.tools import command
+ command.build_package_protos(self.distribution.package_dir[''])
diff --git a/src/python/grpcio_health_checking/setup.py b/src/python/grpcio_health_checking/setup.py
index 70b4575bf5..727d628885 100644
--- a/src/python/grpcio_health_checking/setup.py
+++ b/src/python/grpcio_health_checking/setup.py
@@ -30,49 +30,42 @@
"""Setup module for the GRPC Python package's optional health checking."""
import os
-import os.path
import sys
-from distutils import core as _core
import setuptools
-import grpc.tools.command
-
# Ensure we're in the proper directory whether or not we're being used by pip.
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Break import-style to ensure we can actually find our commands module.
import health_commands
-
-PACKAGES = (
- setuptools.find_packages('.')
-)
+import grpc_version
PACKAGE_DIRECTORIES = {
'': '.',
}
SETUP_REQUIRES = (
- 'grpcio-tools>=0.14.0',
+ 'grpcio-tools>=0.15.0',
)
INSTALL_REQUIRES = (
- 'grpcio>=0.13.1',
+ 'grpcio>=0.15.0',
)
COMMAND_CLASS = {
# Run preprocess from the repository *before* doing any packaging!
'preprocess': health_commands.CopyProtoModules,
-
- 'build_proto_modules': grpc.tools.command.BuildProtoModules,
- 'build_py': health_commands.BuildPy,
+ 'build_package_protos': health_commands.BuildPackageProtos,
}
setuptools.setup(
name='grpcio-health-checking',
- version='0.14.0',
- packages=list(PACKAGES),
+ version=grpc_version.VERSION,
+ license='3-clause BSD',
package_dir=PACKAGE_DIRECTORIES,
+ packages=setuptools.find_packages('.'),
+ namespace_packages=['grpc'],
install_requires=INSTALL_REQUIRES,
setup_requires=SETUP_REQUIRES,
cmdclass=COMMAND_CLASS