Module: Sanford::Protocol
- Extended by:
- Protocol
- Included in:
- Protocol, Connection
- Defined in:
- lib/sanford-protocol.rb,
lib/sanford-protocol/request.rb,
lib/sanford-protocol/version.rb,
lib/sanford-protocol/msg_data.rb,
lib/sanford-protocol/response.rb,
lib/sanford-protocol/connection.rb,
lib/sanford-protocol/fake_socket.rb,
lib/sanford-protocol/test_helpers.rb,
lib/sanford-protocol/fake_connection.rb,
lib/sanford-protocol/response_status.rb
Defined Under Namespace
Modules: StringifyParams, TestHelpers Classes: BadMessageError, BsonBody, Connection, FakeConnection, FakeSocket, MsgBody, MsgData, MsgSize, MsgVersion, PackedHeader, Request, Response, ResponseStatus, Socket, TimeoutError
Constant Summary collapse
- VERSION =
If anything changes in this file, the VERSION number should be incremented. This is used by clients and servers to ensure they are working under the same assumptions. In addition to incrementing this, the README needs to be updated to display the current version and needs to describe everything in this file.
2
- GEM_VERSION =
"0.12.0"
Instance Method Summary collapse
-
#msg_body ⇒ Object
THe message body is encoded using BSON.
-
#msg_size ⇒ Object
The message size is encoded using Array#pack ‘N’.
-
#msg_version ⇒ Object
The message version is the 1B encoding of the ‘VERSION` above.
Instance Method Details
#msg_body ⇒ Object
THe message body is encoded using BSON.
33 |
# File 'lib/sanford-protocol.rb', line 33 def msg_body; @msg_body ||= BsonBody.new; end |
#msg_size ⇒ Object
The message size is encoded using Array#pack ‘N’. This encoding represents a 32-bit (4 byte) unsigned integer. The max value that can be encoded in 4 bytes is 4,294,967,295 (‘(2 ** 32) - 1`) or a size of ~4GB.
29 |
# File 'lib/sanford-protocol.rb', line 29 def msg_size; @msg_size ||= PackedHeader.new(4, 'N'); end |
#msg_version ⇒ Object
The message version is the 1B encoding of the ‘VERSION` above. It is encoded using Array#pack ’C’ (8-bit unsigned integer). The max value it can encode is 255 (‘(2 ** 8) - 1`).
23 |
# File 'lib/sanford-protocol.rb', line 23 def msg_version; @msg_version ||= PackedHeader.new(1, 'C').encode(VERSION); end |