Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
ActorRuntime._actor_managers = {}
ActorRuntime.set_actor_config(ActorRuntimeConfig())
self._serializer = DefaultJSONSerializer()
_run(ActorRuntime.register_actor(FakeSimpleActor))
_run(ActorRuntime.register_actor(FakeMultiInterfacesActor))
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)
def create(self, actor_interface,
actor_type, actor_id) -> ActorProxy:
return ActorProxy(self._dapr_client, actor_interface,
actor_type, actor_id, DefaultJSONSerializer())
def setUp(self):
ActorRuntime._actor_managers = {}
ActorRuntime.set_actor_config(ActorRuntimeConfig())
self._serializer = DefaultJSONSerializer()
_run(ActorRuntime.register_actor(FakeSimpleActor))
_run(ActorRuntime.register_actor(FakeMultiInterfacesActor))
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)
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:
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)
def __init__(self, message_serializer=DefaultJSONSerializer()):
# TODO: support serializer for state store later
self._dapr_client = DaprActorHttpClient()
self._message_serializer = message_serializer
def __init__(
self,
actor_client: DaprActorClientBase,
state_serializer: Serializer = None):
self._state_client = actor_client
self._state_serializer = state_serializer or DefaultJSONSerializer()
def __init__(self, timeout=60):
self._timeout = aiohttp.ClientTimeout(total=timeout)
self._serializer = DefaultJSONSerializer()