Sha256: 7b7b63a183496390a20a32c3a956a3a578f73b11099fd472450fc3621517ff5f

Contents?: true

Size: 1.16 KB

Versions: 11

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

require 'rails'
require 'action_view'
require 'parallel'

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

  # # Rails
  #
  # Use option to rails for prepare application with RRJ.
  # Initialize public queue to Janus instance.
  class Rails < ::Rails::Engine
    config.after_initialize do
      Log.debug '[RRJ] After initializer'
      cfg = RubyRabbitmqJanus::Tools::Config.instance
      number = cfg.public_queue_process

      require File.join(Dir.pwd, cfg.listener_path)
      require File.join(Dir.pwd, cfg.listener_admin_path)

      Log.debug "[RRJ] Create process : #{number}"
      process = RubyRabbitmqJanus::Process::Concurrencies
      actions = RubyRabbitmqJanus::ActionEvents.new.actions
      admin_actions = RubyRabbitmqJanus::ActionAdminEvents.new.actions

      Parallel.map([
                     process::Event.new.run(&actions),
                     process::EventAdmin.new.run(&admin_actions)
                   ], in_processes: number) do |listener|
        "Item: #{listener}, Worker: #{Parallel.worker_number}"
      end
    end
  end
end

require ::File.expand_path('config/environment', Dir.pwd)

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ruby_rabbitmq_janus-3.0.0.pre.354 lib/rrj/rails.rb
ruby_rabbitmq_janus-3.0.0.pre.352 lib/rrj/rails.rb
ruby_rabbitmq_janus-3.0.0.pre.351 lib/rrj/rails.rb
ruby_rabbitmq_janus-3.0.0.pre.336 lib/rrj/rails.rb
ruby_rabbitmq_janus-3.0.0.pre.335 lib/rrj/rails.rb
ruby_rabbitmq_janus-3.0.0.pre.334 lib/rrj/rails.rb
ruby_rabbitmq_janus-3.0.0.pre.330 lib/rrj/rails.rb
ruby_rabbitmq_janus-3.0.0.pre.328 lib/rrj/rails.rb
ruby_rabbitmq_janus-3.0.0.pre.327 lib/rrj/rails.rb
ruby_rabbitmq_janus-2.7.2 lib/rrj/rails.rb
ruby_rabbitmq_janus-2.7.2.pre.322 lib/rrj/rails.rb