mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-17 11:16:40 +08:00
Unifying protocol and messaging.
This commit is contained in:
@@ -1,3 +1,32 @@
|
||||
#import msgpack
|
||||
#import ujson
|
||||
#import ultrajson_numpy
|
||||
|
||||
from ctypes import Structure, c_ubyte
|
||||
|
||||
def Enum(*options):
|
||||
"""
|
||||
Fast enums are very important when we want really tight zmq
|
||||
loops. These are probably going to evolve into pure C structs
|
||||
anyways so might as well get going on that.
|
||||
"""
|
||||
class cstruct(Structure):
|
||||
_fields_ = [(o, c_ubyte) for o in options]
|
||||
return cstruct(*range(len(options)))
|
||||
|
||||
CONTROL_PROTOCOL = Enum(
|
||||
'INIT' , # 0 - req
|
||||
'INFO' , # 1 - req
|
||||
'STATUS' , # 2 - req
|
||||
'SHUTDOWN' , # 3 - req
|
||||
'KILL' , # 4 - req
|
||||
|
||||
'OK' , # 5 - rep
|
||||
'DONE' , # 6 - rep
|
||||
'EXCEPTION' , # 7 - rep
|
||||
)
|
||||
|
||||
HEARTBEAT_PROTOCOL = {
|
||||
'REQ' : '\x01',
|
||||
'REP' : '\x02',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user