Services dependency and interaction in Twisted Python
while working on Twisted, I was wondering if there is:
- a way to explicitly define services dependencies (e.g. in order to sta开发者_开发知识库rt service B, before I need to fire service A)
- a "pythonic" way to make two services communicate (e.g. B shares information with A, A can control B execution)
Thanks
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
精彩评论