コード例 #1
0
 def Check(self, request, context):
     with self._lock:
         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=status)
    def Check(self, request, context):
        status = request.service
        if status is None:
            context.set_code(grpc.StatusCode.NOT_FOUND)
            return health_pb2.HealthCheckResponse()
        elif status != "SERVING":
            context.set_code(grpc.StatusCode.UNAVAILABLE)
            return health_pb2.HealthCheckResponse()

        return health_pb2.HealthCheckResponse(status=status)
コード例 #3
0
 def Check(self, request, context):
     trace_parent = self.extract_trace_parent(context)
     client.begin_transaction('request', trace_parent=trace_parent)
     response = health_pb2.HealthCheckResponse(
         status=health_pb2.HealthCheckResponse.SERVING)
     client.end_transaction('/hipstershop.EmailService/Check', 'success')
     return response
コード例 #4
0
    async def Watch(self, request: _health_pb2.HealthCheckRequest,
                    context) -> None:
        condition = self._server_watchers[request.service]
        last_status = None
        try:
            async with condition:
                while True:
                    status = self._server_status.get(
                        request.service,
                        _health_pb2.HealthCheckResponse.SERVICE_UNKNOWN)

                    # NOTE(lidiz) If the observed status is the same, it means
                    # there are missing intermediate statuses. It's considered
                    # acceptable since peer only interested in eventual status.
                    if status != last_status:
                        # Responds with current health state
                        await context.write(
                            _health_pb2.HealthCheckResponse(status=status))

                    # Records the last sent status
                    last_status = status

                    # Polling on health state changes
                    await condition.wait()
        finally:
            if request.service in self._server_watchers:
                del self._server_watchers[request.service]
コード例 #5
0
    async def Check(self, request: _health_pb2.HealthCheckRequest,
                    context) -> None:
        status = self._server_status.get(request.service)

        if status is None:
            await context.abort(grpc.StatusCode.NOT_FOUND)
        else:
            return _health_pb2.HealthCheckResponse(status=status)
コード例 #6
0
    def Check(self, request, context):
        try:
            status = self.health_mgr.check()
            status = status.value
            self.update_status(status)

        except Exception as e:
            _LOGGER.error(f'[Check] Health Check Error: {e}')
            status = 'UNKNOWN'

        return health_pb2.HealthCheckResponse(status=status)
コード例 #7
0
ファイル: st.py プロジェクト: NEBYUzekarias/nunet
 def Check(self, request, context):
     response = heartb_pb2.HealthCheckResponse()
     response.status = HealthStatus.UNKNOWN
     if request.service == "opencog_services":
         ocs = self.db.query(Service, service_name="OPENCOG_SERVICES")
         if ocs:
             s = self.create_health_stub(ocs.service_host, ocs.service_port)
             response.status = self.get_server_status(s)
         else:
             response.status = HealthStatus.NOT_SERVING
     return response
コード例 #8
0
    def set(self, service, status):
        """Sets the status of a service.

        Args:
          service: string, the name of the service. NOTE, '' must be set.
          status: HealthCheckResponse.status enum value indicating the status of
            the service
        """
        with self._lock:
            self._server_status[service] = status
            if service in self._watchers:
                for watcher in self._watchers[service]:
                    watcher.add(_health_pb2.HealthCheckResponse(status=status))
コード例 #9
0
 def Watch(self, request, context):
     service = request.service
     with self._lock:
         status = self._server_status.get(service)
         if status is None:
             status = _health_pb2.HealthCheckResponse.SERVICE_UNKNOWN  # pylint: disable=no-member
         watcher = _Watcher()
         watcher.add(_health_pb2.HealthCheckResponse(status=status))
         if service not in self._watchers:
             self._watchers[service] = set()
         self._watchers[service].add(watcher)
         context.add_callback(self._on_close_callback(watcher, service))
     return watcher
コード例 #10
0
    def Check(self, request, context):
        tag = ''
        for key, value in context.invocation_metadata():
            if key == "x-dynatrace":
                tag = value

        incall = oneagent.get_sdk().trace_incoming_remote_call(
            'Check',
            'RecommendationService',
            'grpc://hipstershop.RecommendationService',
            protocol_name='gRPC',
            str_tag=tag)

        with incall:
            return health_pb2.HealthCheckResponse(
                status=health_pb2.HealthCheckResponse.SERVING)
コード例 #11
0
    def Check(self, request, context):

        try:
            status = self.actuator.check()

            if isinstance(status, Health.Status):
                status = status.value
                self.update_status(status)
            else:
                _LOGGER.debug(
                    f'[Check] status is not type of Health.Status. (status={type(status)})'
                )
        except Exception as e:
            _LOGGER.error(f'[Check] Health Check Error: {e}')

        return health_pb2.HealthCheckResponse(status=status)
コード例 #12
0
ファイル: health.py プロジェクト: Denticle/docker-base
    def set(self, service, status):
        """Sets the status of a service.

        Args:
          service: string, the name of the service.
          status: HealthCheckResponse.status enum value indicating the status of
            the service
        """
        with self._lock:
            if self._gracefully_shutting_down:
                return
            else:
                self._server_status[service] = status
                if service in self._send_response_callbacks:
                    for send_response_callback in self._send_response_callbacks[
                            service]:
                        send_response_callback(
                            _health_pb2.HealthCheckResponse(status=status))
コード例 #13
0
ファイル: health.py プロジェクト: carinwang/grpc
 def Watch(self, request, context, send_response_callback=None):
     blocking_watcher = None
     if send_response_callback is None:
         # The server does not support the experimental_non_blocking
         # parameter. For backwards compatibility, return a blocking response
         # generator.
         blocking_watcher = _Watcher()
         send_response_callback = _watcher_to_send_response_callback_adapter(
             blocking_watcher)
     service = request.service
     with self._lock:
         status = self._server_status.get(service)
         if status is None:
             status = _health_pb2.HealthCheckResponse.SERVICE_UNKNOWN  # pylint: disable=no-member
         send_response_callback(
             _health_pb2.HealthCheckResponse(status=status))
         if service not in self._send_response_callbacks:
             self._send_response_callbacks[service] = set()
         self._send_response_callbacks[service].add(send_response_callback)
         context.add_callback(
             self._on_close_callback(send_response_callback, service))
     return blocking_watcher
コード例 #14
0
 def Check(_request, _context):
     # SERVING = 1
     return heartb_pb2.HealthCheckResponse(status=1)
コード例 #15
0
 def Check(self, request, context):
     return health_pb2.HealthCheckResponse(
         status=health_pb2.HealthCheckResponse.SERVING)
コード例 #16
0
 def Watch(self, request, context):
     return health_pb2.HealthCheckResponse(
         status=health_pb2.HealthCheckResponse.UNIMPLEMENTED)
コード例 #17
0
 def Check(self, request, context):
     newrelic.agent.set_transaction_name('Check')
     return health_pb2.HealthCheckResponse(
         status=health_pb2.HealthCheckResponse.SERVING)
コード例 #18
0
 def Check(self, request, context):
     SERVING_STATUS = health_pb2.HealthCheckResponse.SERVING
     return health_pb2.HealthCheckResponse(status=SERVING_STATUS)
コード例 #19
0
 def Watch(self, request, context, send_response_callback=None):
     context.write(health_pb2.HealthCheckResponse(status=health_pb2.HealthCheckResponse.SERVING))