You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the user code should implement worker by inheriting from WorkerBase
if the user wants to do fancier stuff like replacing default json into something like msgpack or bjson, they just write their own pack and unpack methods
classServiceBase:
"""Defines the default py-ingress/egress methods"""defunpack(self): # ingress# by default using pydantic classjson.loads()
defpack(self): # egress# by default using pydantic classjson.dumps()
classWorkerBase(ServiceBase):
"""Defines the default py-ipc de/serialize methods"""example= ...
def__init__(self):
self.stage="x"# updated when doing the server.append_worker, used to determine pack/unpack; {"ingress", "x", "egress"}self.max_batch_size=1# updated when doing the server.append_worker, used before __call__ to index elementdefserialize(self, data):
returnpickle.dumps(data, protocol=pickle.HIGHEST_PROTOCOL)
defdeserialize(self, data):
returnpickle.loads(data)
# users' implementation:# 1) no customizationclassNormalStage(WorkerBase):
def__init__():
passdef__call__():
pass# 2) custimized ingress/egress methods for potential speedupclassCustomizedService(WorkerBase):
defunpack(): # ingressmsgpack.packb()
defpack(): # egressmsgpack.unpackb()
classCustomizedStage(CumtomizedService):
def__init__():
passdef__call__():
pass
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Base structures:
WorkerBase
json
into something likemsgpack
orbjson
, they just write their ownpack
andunpack
methodsBeta Was this translation helpful? Give feedback.
All reactions