Class: AMQP::Client::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/amqp/client/configuration.rb

Overview

Configuration for AMQP::Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(codec_registry) ⇒ Configuration

Initialize a new configuration

Parameters:



18
19
20
21
22
23
# File 'lib/amqp/client/configuration.rb', line 18

def initialize(codec_registry)
  @codec_registry = codec_registry
  @strict_coding = false
  @default_content_type = nil
  @default_content_encoding = nil
end

Instance Attribute Details

#codec_registryObject (readonly)

Returns the value of attribute codec_registry.



14
15
16
# File 'lib/amqp/client/configuration.rb', line 14

def codec_registry
  @codec_registry
end

#default_content_encodingString?

Returns Default content encoding for published messages.

Returns:

  • (String, nil)

    Default content encoding for published messages



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/amqp/client/configuration.rb', line 12

class Configuration
  attr_accessor :strict_coding, :default_content_type, :default_content_encoding
  attr_reader :codec_registry

  # Initialize a new configuration
  # @param codec_registry [MessageCodecRegistry] The codec registry to use
  def initialize(codec_registry)
    @codec_registry = codec_registry
    @strict_coding = false
    @default_content_type = nil
    @default_content_encoding = nil
  end

  # Enable all built-in codecs (parsers and coders) for automatic message encoding/decoding
  # This is a convenience method that delegates to the codec registry
  # @return [self]
  def enable_builtin_codecs
    codec_registry.enable_builtin_codecs
    self
  end

  # Enable built-in parsers for common content types
  # @return [self]
  def enable_builtin_parsers
    codec_registry.enable_builtin_parsers
    self
  end

  # Enable built-in coders for common content encodings
  # @return [self]
  def enable_builtin_coders
    codec_registry.enable_builtin_coders
    self
  end

  # Register a custom parser for a content type
  # @param content_type [String] The content_type to match
  # @param parser [Object] The parser object
  # @return [self]
  def register_parser(content_type:, parser:)
    codec_registry.register_parser(content_type:, parser:)
    self
  end

  # Register a custom coder for a content encoding
  # @param content_encoding [String] The content_encoding to match
  # @param coder [Object] The coder object
  # @return [self]
  def register_coder(content_encoding:, coder:)
    codec_registry.register_coder(content_encoding:, coder:)
    self
  end
end

#default_content_typeString?

Returns Default content type for published messages.

Returns:

  • (String, nil)

    Default content type for published messages



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/amqp/client/configuration.rb', line 12

class Configuration
  attr_accessor :strict_coding, :default_content_type, :default_content_encoding
  attr_reader :codec_registry

  # Initialize a new configuration
  # @param codec_registry [MessageCodecRegistry] The codec registry to use
  def initialize(codec_registry)
    @codec_registry = codec_registry
    @strict_coding = false
    @default_content_type = nil
    @default_content_encoding = nil
  end

  # Enable all built-in codecs (parsers and coders) for automatic message encoding/decoding
  # This is a convenience method that delegates to the codec registry
  # @return [self]
  def enable_builtin_codecs
    codec_registry.enable_builtin_codecs
    self
  end

  # Enable built-in parsers for common content types
  # @return [self]
  def enable_builtin_parsers
    codec_registry.enable_builtin_parsers
    self
  end

  # Enable built-in coders for common content encodings
  # @return [self]
  def enable_builtin_coders
    codec_registry.enable_builtin_coders
    self
  end

  # Register a custom parser for a content type
  # @param content_type [String] The content_type to match
  # @param parser [Object] The parser object
  # @return [self]
  def register_parser(content_type:, parser:)
    codec_registry.register_parser(content_type:, parser:)
    self
  end

  # Register a custom coder for a content encoding
  # @param content_encoding [String] The content_encoding to match
  # @param coder [Object] The coder object
  # @return [self]
  def register_coder(content_encoding:, coder:)
    codec_registry.register_coder(content_encoding:, coder:)
    self
  end
end

#strict_codingBoolean

Returns Whether to raise on unknown codecs.

Returns:

  • (Boolean)

    Whether to raise on unknown codecs



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/amqp/client/configuration.rb', line 12

class Configuration
  attr_accessor :strict_coding, :default_content_type, :default_content_encoding
  attr_reader :codec_registry

  # Initialize a new configuration
  # @param codec_registry [MessageCodecRegistry] The codec registry to use
  def initialize(codec_registry)
    @codec_registry = codec_registry
    @strict_coding = false
    @default_content_type = nil
    @default_content_encoding = nil
  end

  # Enable all built-in codecs (parsers and coders) for automatic message encoding/decoding
  # This is a convenience method that delegates to the codec registry
  # @return [self]
  def enable_builtin_codecs
    codec_registry.enable_builtin_codecs
    self
  end

  # Enable built-in parsers for common content types
  # @return [self]
  def enable_builtin_parsers
    codec_registry.enable_builtin_parsers
    self
  end

  # Enable built-in coders for common content encodings
  # @return [self]
  def enable_builtin_coders
    codec_registry.enable_builtin_coders
    self
  end

  # Register a custom parser for a content type
  # @param content_type [String] The content_type to match
  # @param parser [Object] The parser object
  # @return [self]
  def register_parser(content_type:, parser:)
    codec_registry.register_parser(content_type:, parser:)
    self
  end

  # Register a custom coder for a content encoding
  # @param content_encoding [String] The content_encoding to match
  # @param coder [Object] The coder object
  # @return [self]
  def register_coder(content_encoding:, coder:)
    codec_registry.register_coder(content_encoding:, coder:)
    self
  end
end

Instance Method Details

#enable_builtin_codecsself

Enable all built-in codecs (parsers and coders) for automatic message encoding/decoding This is a convenience method that delegates to the codec registry

Returns:

  • (self)


28
29
30
31
# File 'lib/amqp/client/configuration.rb', line 28

def enable_builtin_codecs
  codec_registry.enable_builtin_codecs
  self
end

#enable_builtin_codersself

Enable built-in coders for common content encodings

Returns:

  • (self)


42
43
44
45
# File 'lib/amqp/client/configuration.rb', line 42

def enable_builtin_coders
  codec_registry.enable_builtin_coders
  self
end

#enable_builtin_parsersself

Enable built-in parsers for common content types

Returns:

  • (self)


35
36
37
38
# File 'lib/amqp/client/configuration.rb', line 35

def enable_builtin_parsers
  codec_registry.enable_builtin_parsers
  self
end

#register_coder(content_encoding:, coder:) ⇒ self

Register a custom coder for a content encoding

Parameters:

  • content_encoding (String)

    The content_encoding to match

  • coder (Object)

    The coder object

Returns:

  • (self)


60
61
62
63
# File 'lib/amqp/client/configuration.rb', line 60

def register_coder(content_encoding:, coder:)
  codec_registry.register_coder(content_encoding:, coder:)
  self
end

#register_parser(content_type:, parser:) ⇒ self

Register a custom parser for a content type

Parameters:

  • content_type (String)

    The content_type to match

  • parser (Object)

    The parser object

Returns:

  • (self)


51
52
53
54
# File 'lib/amqp/client/configuration.rb', line 51

def register_parser(content_type:, parser:)
  codec_registry.register_parser(content_type:, parser:)
  self
end