| Class | Mongo::Protocol::Message |
| In: |
lib/mongo/protocol/message.rb
|
| Parent: | Object |
A base class providing functionality required by all messages in the MongoDB wire protocol. It provides a minimal DSL for defining typed fields to enable serialization and deserialization over the wire.
@example
class WireProtocolMessage < Message
private
def op_code
1234
end
FLAGS = [:first_bit, :bit_two]
# payload
field :flags, BitVector.new(FLAGS)
field :namespace, CString
field :document, Document
field :documents, Document, true
end
@abstract @api semiprivate
| BATCH_SIZE | = | 'batchSize'.freeze |
The batch size constant.
@since 2.2.0 |
|
| COLLECTION | = | 'collection'.freeze |
The collection constant.
@since 2.2.0 |
|
| LIMIT | = | 'limit'.freeze |
The limit constant.
@since 2.2.0 |
|
| ORDERED | = | 'ordered'.freeze |
The ordered constant.
@since 2.2.0 |
|
| Q | = | 'q'.freeze |
The q constant.
@since 2.2.0 |
|
| MAX_MESSAGE_SIZE | = | 50331648.freeze |
Default max message size of 48MB.
@since 2.2.1 |
| request_id | [R] |
Returns the request id for the message
@return [Fixnum] The request id for this message |
Tests for equality between two wire protocol messages by comparing class and field values.
@param other [Mongo::Protocol::Message] The wire protocol message. @return [true, false] The equality of the messages.
Compress a message.
@param [ String, Symbol ] compressor The compressor to use. @param [ Integer ] zlib_compression_level The zlib compression level to use.
@return [ self ] Always returns self. Other message types should override this method.
@since 2.5.0
Inflate a message.
@return [ self ] Always returns self. Other message types should override this method.
@since 2.5.0
Default number returned value for protocol messages.
@return [ 0 ] This method must be overridden, otherwise, always returns 0.
@since 2.5.0
The default for messages is not to require a reply after sending a message to the server.
@example Does the message require a reply?
message.replyable?
@return [ false ] The default is to not require a reply.
@since 2.0.0
Serializes message into bytes that can be sent on the wire
@param buffer [String] buffer where the message should be inserted @return [String] buffer containing the serialized message