Sha256: c39d754cd617a3c18bd896b33b861ff8aba135f290e3470d614971f4c2d46a33

Contents?: true

Size: 1.39 KB

Versions: 32

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

module RubyRabbitmqJanus
  module Tools
    # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>

    # # Manage Janus instance
    class Cluster
      include Singleton

      # Initialize object for managing each instance to Janus
      def initialize
        @current_instance = nil
      end

      # Create session (just one Janus Instance)
      def create_session
        @current_instance = 1
        Models::JanusInstance.create(instance: @current_instance)
      rescue
        raise Errors::Tools::Cluster::CreateSession
      end

      # Restart a thread keepalive for an instance
      def restart_session
        Models::JanusInstance.enabled.each do |ji|
          ji.send(:create_a_session_in_janus_instance)
        end
      rescue
        raise Errors::Tools::Cluster::RestartInstance
      end

      # Specify a name to queue
      def queue_to(instance = nil)
        Tools::Config.instance.options['queues']['standard']['to'] + \
          "-#{instance.blank? ? @current_instance : instance}"
      rescue
        raise Errors::Tools::Cluster::QueueTo
      end

      # Specify a name to admin queue
      def queue_admin_to(instance = nil)
        Tools::Config.instance.options['queues']['admin']['to'] + \
          "-#{instance.blank? ? @current_instance : instance}"
      rescue
        raise Errors::Tools::Cluster::QueueAdminTo
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-2.2.0.pre.179 lib/rrj/tools/gem/cluster.rb
ruby_rabbitmq_janus-2.2.0 lib/rrj/tools/gem/cluster.rb
ruby_rabbitmq_janus-2.2.0.pre.177 lib/rrj/tools/gem/cluster.rb
ruby_rabbitmq_janus-2.2.0.pre.173 lib/rrj/tools/gem/cluster.rb
ruby_rabbitmq_janus-2.2.0.pre.170 lib/rrj/tools/gem/cluster.rb
ruby_rabbitmq_janus-2.2.0.pre.168 lib/rrj/tools/gem/cluster.rb
ruby_rabbitmq_janus-2.2.0.pre.167 lib/rrj/tools/gem/cluster.rb
ruby_rabbitmq_janus-2.2.0.pre.166 lib/rrj/tools/gem/cluster.rb
ruby_rabbitmq_janus-2.2.0.pre.165 lib/rrj/tools/gem/cluster.rb
ruby_rabbitmq_janus-2.2.0.pre.164 lib/rrj/tools/gem/cluster.rb
ruby_rabbitmq_janus-2.2.0.pre.161 lib/rrj/tools/gem/cluster.rb
ruby_rabbitmq_janus-2.2.0.pre.159 lib/rrj/tools/gem/cluster.rb