Skip to content

Commit 7977b5e

Browse files
committed
extra routing info
1 parent 1c705e3 commit 7977b5e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

mercury/platform.py

+2
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ def handle_event(self, event, instance):
239239
response = EventEnvelope().set_to(reply_to)
240240
if not error_code:
241241
response.set_exec_time((end - begin) * 1000)
242+
if 'extra' in event:
243+
response.set_extra(event['extra'])
242244
if 'cid' in event:
243245
response.set_correlation_id(event['cid'])
244246
if isinstance(result, EventEnvelope):

mercury/system/models.py

+15
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def __init__(self):
4444
self.to = None
4545
self.sender = None
4646
self.reply_to = None
47+
self.extra = None
4748
self.correlation_id = None
4849
self.broadcast = False
4950
self.exec_time = -1.0
@@ -93,6 +94,16 @@ def set_reply_to(self, reply_to: str, me=False):
9394
def get_reply_to(self):
9495
return self.reply_to
9596

97+
def set_extra(self, extra: str):
98+
if isinstance(extra, str):
99+
self.extra = extra
100+
else:
101+
raise ValueError('extra must be str')
102+
return self
103+
104+
def get_extra(self):
105+
return self.extra
106+
96107
def set_correlation_id(self, correlation_id: str):
97108
self.correlation_id = correlation_id if isinstance(correlation_id, str) else str(correlation_id)
98109
return self
@@ -153,6 +164,8 @@ def to_map(self):
153164
result['body'] = self.body
154165
if self.reply_to:
155166
result['reply_to'] = self.reply_to
167+
if self.extra:
168+
result['extra'] = self.extra
156169
if self.correlation_id:
157170
result['cid'] = self.correlation_id
158171
if self.broadcast:
@@ -178,6 +191,8 @@ def from_map(self, data: dict):
178191
self.body = data['body']
179192
if 'reply_to' in data and isinstance(data['reply_to'], str):
180193
self.reply_to = data['reply_to']
194+
if 'extra' in data and isinstance(data['extra'], str):
195+
self.extra = data['extra']
181196
if 'cid' in data:
182197
self.correlation_id = data['cid']
183198
if 'status' in data:

0 commit comments

Comments
 (0)