问题描述
我想了解是否可以在我的应用程序中使用 gRPC。我有一个复杂的自定义类,它包含各种数据类型(其他类以及内置类)。我想创建一个服务来封装这个类并允许客户端与其交互(调用它的方法、检索数据、更改数据)。有没有办法使用 gRPC 来做到这一点?
效果如下:
class AnotherClass:
def __init__(self):
self.a = 1
class ExampleData:
def __init__(self):
self.x = 0
self.inner_complex_obj = AnotherClass()
def foo(self):
self.x += 1
class MyService:
def __init__(self,example_data):
self.example_data = example_data
def run_foo(self):
self.example_data.foo()
def get_example_data(self):
return self.example_data
# server
MyService().start()
# client
client = connect()
client.run_foo()
example_data = client.get_example_data()
print(example_data.x)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)