Core libraries and tools part for pro architecture. It's a submodule - use from this perspective http://git.maniak.pro/madmaniak/pro
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
687 B
26 lines
687 B
require 'connection_pool'
|
|
require 'disque'
|
|
|
|
require_relative '../../db/postgres/db'
|
|
require_relative 'helpers/monkey_patches'
|
|
require_relative 'helpers/load_models'
|
|
require_relative 'helpers/load_services'
|
|
|
|
PathsResolver.free # PathsResolver will be not used anymore
|
|
|
|
connect_disque = ->{ Disque.new(["#{ENV['disque_host']}:#{ENV['disque_port']}"]) }
|
|
$dis = ConnectionPool.new(size: 8, timeout: 2) { connect_disque.call }
|
|
dis = connect_disque.call
|
|
|
|
services = $services.reduce({}){ |h, (name, service)|
|
|
h[name] = service.new; h
|
|
}
|
|
|
|
NAME = 0
|
|
ID = 1
|
|
PAYLOAD = 2
|
|
|
|
loop do
|
|
jobs = dis.que(:getjob, :from, *$services.keys)
|
|
jobs.each do |job| services[job[NAME]].run(job[PAYLOAD]) end
|
|
end
|
|
|