Services dependency and interaction in Twisted Pyt

2019-08-04 10:47发布

while working on Twisted, I was wondering if there is:

  1. a way to explicitly define services dependencies (e.g. in order to start service B, before I need to fire service A)
  2. a "pythonic" way to make two services communicate (e.g. B shares information with A, A can control B execution)

Thanks

1条回答
不美不萌又怎样
2楼-- · 2019-08-04 11:49

Take a look at Twisted Application Documentation. It sounds like you want to create a MultiService each with its own sub-Service implementation. What you do is define a number of services, implementing a startService and stopService and arrange your services in a tree hierarchy (via setServiceParent) to determine arbitrary startup and shutdown orderings.

If you're more interested in distributed service coordination, then that is slightly more difficult. This is something Erlang excels at, though if you're not averse to using a system like Zookeeper that could be a solution.

As to your final point, there are a number of ways for services to communicate. You can use something like Perspective Broker for object communication, or go for something more heavy and generalized like RabbitMQ

查看更多
登录 后发表回答