Module: OMQ::Compression::Zstd::EngineExt

Defined in:
lib/omq/compression/zstd/engine_ext.rb

Overview

Prepended onto OMQ::Engine to install a compression-aware connection wrapper. The wrapper is installed unconditionally at engine init time and inspects options.compression on each call – the user typically sets socket.compression = AFTER the engine has been constructed, so the closure must look up the compression object lazily.

Instance Method Summary collapse

Instance Method Details

#initialize(socket_type, options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/omq/compression/zstd/engine_ext.rb', line 19

def initialize(socket_type, options)
  super
  self.connection_wrapper = ->(conn) do
    compression = options.compression
    next conn unless compression
    next conn unless matched_profile(conn, compression)

    wrapper = Connection.new(
      conn,
      send_compression: compression,
      recv_compression: compression,
      max_message_size: options.max_message_size,
      engine: self,
    )
    wrapper.send_initial_dict!
    wrapper
  end
end