-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25407 from rallytime/bp-23236
Back-port #23236 to 2015.8
- Loading branch information
Showing
6 changed files
with
598 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- coding: utf-8 -*- | ||
''' | ||
Helper functions for transport components to handle message framing | ||
''' | ||
# Import python libs | ||
from __future__ import absolute_import | ||
import msgpack | ||
|
||
|
||
def frame_msg(body, header=None, raw_body=False): | ||
''' | ||
Frame the given message with our wire protocol | ||
''' | ||
framed_msg = {} | ||
if header is None: | ||
header = {} | ||
|
||
# if the body wasn't already msgpacked-- lets do that. | ||
if not raw_body: | ||
body = msgpack.dumps(body) | ||
|
||
framed_msg['head'] = header | ||
framed_msg['body'] = body | ||
framed_msg_packed = msgpack.dumps(framed_msg) | ||
return '{0} {1}'.format(len(framed_msg_packed), framed_msg_packed) |
Oops, something went wrong.