-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Neil Booth
committed
Mar 12, 2018
1 parent
8c8f717
commit 44a584a
Showing
5 changed files
with
49 additions
and
4 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
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,45 @@ | ||
.. currentmodule:: aiorpcx | ||
|
||
Framing | ||
======= | ||
|
||
Message :dfn:`framing` is the method by which RPC messages are wrapped | ||
in a byte stream so that message boundaries can be determined. | ||
|
||
:mod:`aiorpcx` provides an abstract base class for framers, and a | ||
single implementation: :class:`NewlineFramer`. A framer must know how | ||
to take outgoing messages and frame them, and also how to break an | ||
incoming byte stream into message frames in order to extract the RPC | ||
messages from it. | ||
|
||
.. class:: FramerBase | ||
|
||
Derive from this class to implement your own message framing | ||
methodology. | ||
|
||
.. method:: frame(messages) | ||
|
||
Frame each message and return the concatenated result. | ||
|
||
:param message: an iterable; each message should be of type | ||
:class:`bytes` or :class:`bytearray` | ||
:return: the concatenated bytestream | ||
:rtype: bytes | ||
|
||
.. method:: messages(data) | ||
|
||
:param data: incoming data of type :class:`bytes` or | ||
:class:`bytearray` | ||
:raises MemoryError: if the internal data buffer overflows | ||
|
||
.. note:: since this may raise an exception, the caller should | ||
process messages as they are yielded. Converting the | ||
messages to a list will lose earlier ones if an | ||
exception is raised later. | ||
|
||
|
||
.. class:: NewlineFramer(max_size=1000000) | ||
|
||
A framer where messages are delimited by an ASCII newline character in | ||
a text stream. The internal buffer for partial messages will hold up | ||
to *max_size* bytes. |
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 |
---|---|---|
|
@@ -47,6 +47,7 @@ Documentation | |
|
||
.. toctree:: | ||
|
||
framing | ||
json-rpc | ||
rpc | ||
|
||
|
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