Skip to content

Commit 0e5b0eb

Browse files
committed
Feat. Added support to async and pooled invocations
1 parent a6ad896 commit 0e5b0eb

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

example/spawn_example.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
request.language = "erlang"
1515

1616
spawn = Spawn()
17+
# .add_actor(joe_actor)
1718
spawn.port(8091).proxy_port(9003).actor_system(
18-
"spawn-system").add_actor(joe_actor).add_actor(abstract).start()
19+
"spawn-system").add_actor(abstract).start()
1920

2021
# Get abstract actor reference called mike
2122
mike_actor: ActorRef = Spawn.create_actor_ref(
@@ -24,6 +25,7 @@
2425
parent="abs_actor"
2526
)
2627

27-
(status, result) = mike_actor.invoke("setLanguage", request)
28+
(status, result) = mike_actor.invoke(
29+
action="setLanguage", request=request)
2830
print("Invocation Result Status: " + status)
2931
print("Invocation Result Value: " + str(result.response))

spawn/eigr/functions/actors/api/reference.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ def __init__(self, client: SpawnClient, system: str, actor: str, parent: str = N
4343
spawn(self.__spawn_client, self.actor_system,
4444
self.actor_name, self.actor_parent, self.revision)
4545

46-
def invoke(self, action: str, request: any = None):
47-
req: InvocationRequest = self.__build_request(action, request)
46+
def invoke(self, action: str, request: any = None, async_mode: bool = False, pooled: bool = False):
47+
req: InvocationRequest = self.__build_request(
48+
action, request, async_mode, pooled)
4849
resp: InvocationResponse = self.__spawn_client.invoke(
4950
self.actor_system, self.actor_name, req)
5051

5152
return self.__build_result(resp)
5253

53-
def __build_request(self, action: str, request: any):
54+
def __build_request(self, action: str, request: any, async_mode: bool = False, pooled: bool = False):
5455
req: InvocationRequest = InvocationRequest()
5556
system = ActorSystem()
5657
system.name = self.actor_system
@@ -65,6 +66,8 @@ def __build_request(self, action: str, request: any):
6566
req.system.CopyFrom(system)
6667
req.actor.CopyFrom(actor)
6768
req.action_name = action
69+
req.pooled = pooled
70+
setattr(req, 'async', async_mode)
6871

6972
if request != None:
7073
req.value.CopyFrom(pack(request))

0 commit comments

Comments
 (0)