forked from dapr/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactor_interface.py
49 lines (35 loc) · 1.13 KB
/
actor_interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-
"""
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
"""
from abc import ABC
class ActorInterface(ABC):
"""A base class that Dapr Actor inherits.
Actor requires to inherit ActorInterface as a base class.
Example::
class DaprActorInterface(ActorInterface):
@actormethod('DoActorMethod1')
async def do_actor_method1(self, param):
...
@actormethod('DoActorMethod2')
async def do_actor_method2(self, param):
...
"""
...
def actormethod(name: str = None):
"""Decorate actor method to define the method invoked by the remote actor.
This allows users to call the decorated name via the proxy client.
Example::
class DaprActorInterface(ActorInterface):
@actormethod(name='DoActorCall')
async def do_actor_call(self, param):
...
Args:
name (str): the name of actor method.
"""
def wrapper(funcobj):
funcobj.__actormethod__ = name
funcobj.__isabstractmethod__ = True
return funcobj
return wrapper