Class Mongo::Protocol::Compressed
In: lib/mongo/protocol/compressed.rb
Parent: Message

MongoDB Wire protocol Compressed message.

This is a bi-directional message that compresses another opcode.

@api semipublic

@since 2.5.0

Methods

inflate!   new   replyable?  

Constants

ZLIB_BYTE = 2.chr.force_encoding(BSON::BINARY).freeze   The byte signaling that the message has been compressed with Zlib.

@since 2.5.0

ZLIB = 'zlib'.freeze   The Zlib compressor identifier.

@since 2.5.0

COMPRESSOR_ID_MAP = { ZLIB => ZLIB_BYTE }.freeze   The compressor identifier to byte map.

@since 2.5.0

OP_CODE = 2012   The operation code for a Compressed message. @return [ Fixnum ] the operation code.

@since 2.5.0

Public Class methods

Creates a new OP_COMPRESSED message.

@example Create an OP_COMPRESSED message.

  Compressed.new(original_message, 'zlib')

@param [ Mongo::Protocol::Message ] message The original message. @param [ String, Symbol ] compressor The compression algorithm to use. @param [ Integer ] zlib_compression_level The zlib compression level to use.

  -1 and nil imply default.

@since 2.5.0

Public Instance methods

Inflate an OP_COMRESSED message and return the original message.

@example Inflate a compressed message.

 message.inflate!

@return [ Protocol::Message ] The inflated message.

@since 2.5.0

Whether the message expects a reply from the database.

@example Does the message require a reply?

  message.replyable?

@return [ true, false ] If the message expects a reply.

@since 2.5.0

[Validate]