Sha256: b623d1f9be6108f123ff826bc382b080a5fb2ab90495a997e92cd1e84f85ff38

Contents?: true

Size: 1005 Bytes

Versions: 7

Compression:

Stored size: 1005 Bytes

Contents

# frozen_string_literal: true

# :reek:NilCheck

module RubyRabbitmqJanus
  module Models
    # Add method for Janus Instance model
    module Methods
      extend ActiveSupport::Concern

      # Create thread keepalive
      def create_keepalive
        ::Log.info "Janus Instance #{name} ..."
        if !enable && session_id.nil? && thread_id.nil?
          ::Log.info 'has a new keepalive session'
          janus_instance = keepalive_object_new
          set(session: janus_instance.session, enable: true)
        else
          ::Log.info 'has already keepalive session'
        end
      end

      # Stop thread keepalive
      def stop_keepalive
        ::Log.info 'Destroy session'
        unset(%I[thread thread_adm session])
        set(enable: false)
      end

      # Start Janus instance
      # @since 2.7.1
      def start!
        update(enable: true)
      end

      # Stop Janus instance
      # @since 2.7.1
      def stop!
        update(enable: false)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-2.7.2.pre.308 lib/rrj/models/concerns/methods.rb
ruby_rabbitmq_janus-2.7.2.pre.307 lib/rrj/models/concerns/methods.rb
ruby_rabbitmq_janus-2.7.2.pre.306 lib/rrj/models/concerns/methods.rb
ruby_rabbitmq_janus-2.7.2.pre.305 lib/rrj/models/concerns/methods.rb
ruby_rabbitmq_janus-2.7.2.pre.302 lib/rrj/models/concerns/methods.rb
ruby_rabbitmq_janus-2.7.2.pre.297 lib/rrj/models/concerns/methods.rb
ruby_rabbitmq_janus-2.7.2.pre.296 lib/rrj/models/concerns/methods.rb