Sha256: 83849420ae978a6065dc49890b86b87996c1fba89fbde440319de2d0cdc351ec

Contents?: true

Size: 1.61 KB

Versions: 40

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

module RubyRabbitmqJanus
  module Tools
    module Replaces
      # Format message request with good data to HASH format for Admin request.
      # Manage level, debug and admin_secret
      #
      # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
      class Admin < Handle
        private

        KEY_ACCEPTED = %w[colors
                          debug
                          level
                          filename
                          folder
                          max_nack_queue
                          no_media_timer
                          timestamps
                          token
                          truncate
                          timeout].freeze

        def replace_element_classic
          super
          replace_admins if request.key?('admin_secret')
          add_secret if opts.key?('add')
        end

        def add_secret
          values = opts['add']
          request.merge!(values)
        end

        def replace_admins
          replace_admin
          KEY_ACCEPTED.each do |key|
            replace_component(key) if request.key?(key)
          end
        end

        def replace_component(key)
          request[key] = type.convert(key, opts)
        rescue => exception
          ::Log.warn "Error replace #{key} : #{exception}"
        end

        def replace_admin
          request['admin_secret'] = admin_pass
        rescue => exception
          ::Log.warn "Error replace admin_secret : #{exception}"
        end

        def admin_pass
          Tools::Config.instance.options['rabbit']['admin_pass']
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-3.0.0.pre.336 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-3.0.0.pre.335 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-3.0.0.pre.334 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-3.0.0.pre.330 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-3.0.0.pre.328 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-3.0.0.pre.327 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.7.2 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.7.2.pre.322 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.7.2.pre.320 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.7.2.pre.319 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.7.2.pre.318 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.7.2.pre.317 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.7.2.pre.316 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.7.2.pre.315 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.7.2.pre.314 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.7.2.pre.312 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.7.2.pre.310 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.7.2.pre.309 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.7.2.pre.308 lib/rrj/tools/replaces/admin.rb
ruby_rabbitmq_janus-2.7.2.pre.307 lib/rrj/tools/replaces/admin.rb