Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
 async def dapr_config():
     serialized = self._dapr_serializer.serialize(ActorRuntime.get_actor_config())
     return _wrap_response(status.HTTP_200_OK, serialized)
Ejemplo n.º 6
0
 def _config_handler(self):
     serialized = self._dapr_serializer.serialize(
         ActorRuntime.get_actor_config())
     return wrap_response(200, serialized)
Ejemplo n.º 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__}')