mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-02 10:10:05 +08:00
33 lines
749 B
Python
33 lines
749 B
Python
#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',
|
|
}
|