How to use the dapr.serializers.DefaultJSONSerializer function in dapr

To help you get started, we’ve selected a few dapr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dapr / python-sdk / tests / actor / test_actor_runtime.py View on Github external
def setUp(self):
        ActorRuntime._actor_managers = {}
        ActorRuntime.set_actor_config(ActorRuntimeConfig())
        self._serializer = DefaultJSONSerializer()
        _run(ActorRuntime.register_actor(FakeSimpleActor))
        _run(ActorRuntime.register_actor(FakeMultiInterfacesActor))
github dapr / python-sdk / tests / actor / test_actor_manager.py View on Github external
def setUp(self):
        self._test_type_info = ActorTypeInformation.create(FakeMultiInterfacesActor)
        self._serializer = DefaultJSONSerializer()

        self._fake_client = FakeDaprActorClient
        self._runtime_ctx = ActorRuntimeContext(
            self._test_type_info, self._serializer,
            self._serializer, self._fake_client)
        self._manager = ActorManager(self._runtime_ctx)
github dapr / python-sdk / tests / actor / test_client_proxy.py View on Github external
def create(self, actor_interface,
               actor_type, actor_id) -> ActorProxy:
        return ActorProxy(self._dapr_client, actor_interface,
                          actor_type, actor_id, DefaultJSONSerializer())
github dapr / python-sdk / tests / actor / test_actor.py View on Github external
def setUp(self):
        ActorRuntime._actor_managers = {}
        ActorRuntime.set_actor_config(ActorRuntimeConfig())
        self._serializer = DefaultJSONSerializer()
        _run(ActorRuntime.register_actor(FakeSimpleActor))
        _run(ActorRuntime.register_actor(FakeMultiInterfacesActor))
github dapr / python-sdk / tests / actor / test_method_dispatcher.py View on Github external
def setUp(self):
        self._testActorTypeInfo = ActorTypeInformation.create(FakeSimpleActor)
        self._serializer = DefaultJSONSerializer()
        self._fake_client = FakeDaprActorClient
        self._fake_runtime_ctx = ActorRuntimeContext(
            self._testActorTypeInfo, self._serializer,
            self._serializer, self._fake_client)
github dapr / python-sdk / dapr / actor / runtime / runtime.py View on Github external
async def register_actor(
            cls, actor: Type[Actor],
            message_serializer: Serializer = DefaultJSONSerializer(),
            state_serializer: Serializer = DefaultJSONSerializer()) -> None:
        """Registers an :class:`Actor` object with the runtime.

        Args:
            actor (:class:`Actor`): Actor implementation.
            message_serializer (:class:`Serializer`): A serializer that serializes message
                between actors.
            state_serializer (:class:`Serializer`): Serializer that serializes state values.
        """
        type_info = ActorTypeInformation.create(actor)
        # TODO: We will allow to use gRPC client later.
        actor_client = DaprActorHttpClient()
        ctx = ActorRuntimeContext(type_info, message_serializer, state_serializer, actor_client)

        # Create an ActorManager, override existing entry if registered again.
        async with cls._actor_managers_lock:
github dapr / python-sdk / dapr / actor / runtime / runtime.py View on Github external
async def register_actor(
            cls, actor: Type[Actor],
            message_serializer: Serializer = DefaultJSONSerializer(),
            state_serializer: Serializer = DefaultJSONSerializer()) -> None:
        """Registers an :class:`Actor` object with the runtime.

        Args:
            actor (:class:`Actor`): Actor implementation.
            message_serializer (:class:`Serializer`): A serializer that serializes message
                between actors.
            state_serializer (:class:`Serializer`): Serializer that serializes state values.
        """
        type_info = ActorTypeInformation.create(actor)
        # TODO: We will allow to use gRPC client later.
        actor_client = DaprActorHttpClient()
        ctx = ActorRuntimeContext(type_info, message_serializer, state_serializer, actor_client)

        # Create an ActorManager, override existing entry if registered again.
        async with cls._actor_managers_lock:
            cls._actor_managers[type_info.type_name] = ActorManager(ctx)
github dapr / python-sdk / dapr / actor / client / proxy.py View on Github external
    def __init__(self, message_serializer=DefaultJSONSerializer()):
        # TODO: support serializer for state store later
        self._dapr_client = DaprActorHttpClient()
        self._message_serializer = message_serializer
github dapr / python-sdk / dapr / actor / runtime / state_provider.py View on Github external
def __init__(
            self,
            actor_client: DaprActorClientBase,
            state_serializer: Serializer = None):
        self._state_client = actor_client
        self._state_serializer = state_serializer or DefaultJSONSerializer()
github dapr / python-sdk / dapr / clients / http / dapr_actor_http_client.py View on Github external
def __init__(self, timeout=60):
        self._timeout = aiohttp.ClientTimeout(total=timeout)
        self._serializer = DefaultJSONSerializer()