예제 #1
0
    def _deactivation_handler(self, actor_type_name, actor_id):
        try:
            asyncio.run(ActorRuntime.deactivate(actor_type_name, actor_id))
        except DaprInternalError as ex:
            return wrap_response(500, ex.as_dict())
        except Exception as ex:
            return wrap_response(500, repr(ex), ERROR_CODE_UNKNOWN)

        msg = f'deactivated actor: {actor_type_name}.{actor_id}'
        self._app.logger.debug(msg)
        return wrap_response(200, msg)
예제 #2
0
    def _timer_handler(self, actor_type_name, actor_id, timer_name):
        try:
            asyncio.run(
                ActorRuntime.fire_timer(actor_type_name, actor_id, timer_name))
        except DaprInternalError as ex:
            return wrap_response(500, ex.as_dict())
        except Exception as ex:
            return wrap_response(500, repr(ex), ERROR_CODE_UNKNOWN)

        msg = f'called timer. actor: {actor_type_name}.{actor_id}, timer: {timer_name}'
        self._app.logger.debug(msg)
        return wrap_response(200, msg)
예제 #3
0
파일: actor.py 프로젝트: zecloud/python-sdk
    def _method_handler(self, actor_type_name, actor_id, method_name):
        try:
            # Read raw bytes from request stream
            req_body = request.stream.read()
            result = asyncio.run(ActorRuntime.dispatch(
                actor_type_name, actor_id, method_name, req_body))
        except DaprInternalError as ex:
            return wrap_response(500, ex.as_dict())
        except Exception as ex:
            return wrap_response(500, repr(ex), ERROR_CODE_UNKNOWN)

        msg = f'called method. actor: {actor_type_name}.{actor_id}, method: {method_name}'
        self._app.logger.debug(msg)
        return wrap_response(200, result)
예제 #4
0
파일: actor.py 프로젝트: zecloud/python-sdk
    def _reminder_handler(self, actor_type_name, actor_id, reminder_name):
        try:
            # Read raw bytes from request stream
            req_body = request.stream.read()
            asyncio.run(ActorRuntime.fire_reminder(
                actor_type_name, actor_id, reminder_name, req_body))
        except DaprInternalError as ex:
            return wrap_response(500, ex.as_dict())
        except Exception as ex:
            return wrap_response(500, repr(ex), ERROR_CODE_UNKNOWN)

        msg = f'called reminder. actor: {actor_type_name}.{actor_id}, reminder: {reminder_name}'
        self._app.logger.debug(msg)
        return wrap_response(200, msg)
예제 #5
0
 async def dapr_config():
     serialized = self._dapr_serializer.serialize(ActorRuntime.get_actor_config())
     return _wrap_response(status.HTTP_200_OK, serialized)
예제 #6
0
 def _config_handler(self):
     serialized = self._dapr_serializer.serialize(
         ActorRuntime.get_actor_config())
     return wrap_response(200, serialized)
예제 #7
0
 def register_actor(self, actor: Type[Actor]) -> None:
     asyncio.run(ActorRuntime.register_actor(actor))
     self._app.logger.debug(f'registered actor: {actor.__class__.__name__}')