|
1 # |
|
2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net> |
|
3 # All Rights Reserved. |
|
4 # |
|
5 # This software is subject to the provisions of the Zope Public License, |
|
6 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. |
|
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED |
|
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS |
|
10 # FOR A PARTICULAR PURPOSE. |
|
11 # |
|
12 |
|
13 __docformat__ = 'restructuredtext' |
|
14 |
|
15 from zope.interface import Attribute, Interface, implementer |
|
16 from zope.interface.interfaces import IObjectEvent, ObjectEvent |
|
17 |
|
18 |
|
19 class IZMQProcess(Interface): |
|
20 """ZeroMQ process interface""" |
|
21 |
|
22 socket_type = Attribute("Socket type") |
|
23 |
|
24 def setup(self): |
|
25 """Initialize process context and events loop and initialize stream""" |
|
26 |
|
27 def stream(self, sock_type, addr, bind, callback=None, subscribe=b''): |
|
28 """Create ZMQStream""" |
|
29 |
|
30 def init_stream(self): |
|
31 """initialize response stream""" |
|
32 |
|
33 def start(self): |
|
34 """Start the process""" |
|
35 |
|
36 def stop(self): |
|
37 """Stop the process""" |
|
38 |
|
39 |
|
40 class IZMQProcessStartedEvent(IObjectEvent): |
|
41 """ZMQ process started event interface""" |
|
42 |
|
43 |
|
44 @implementer(IZMQProcessStartedEvent) |
|
45 class ZMQProcessStartedEvent(ObjectEvent): |
|
46 """ZMQ process started event""" |
|
47 |
|
48 |
|
49 class IZMQMessageHandler(Interface): |
|
50 """ZeroMQ message handler""" |
|
51 |
|
52 handler = Attribute("Concrete message handler") |