Sha256: 3b31d81d817fa20d8549caef8d18ba7ab34c80f22b68e8292babef690e6c0b25

Contents?: true

Size: 967 Bytes

Versions: 2

Compression:

Stored size: 967 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
        if !enable && session_id.nil? && thread_id.nil?
          ::Log.info 'Create session'
          janus_instance = keepalive_object_new
          set(session: janus_instance.session, enable: true)
        else
          ::Log.info "Janus Instance #{name} 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

2 entries across 2 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-2.7.2.pre.286 lib/rrj/models/concerns/methods.rb
ruby_rabbitmq_janus-2.7.2.pre.285 lib/rrj/models/concerns/methods.rb