Sha256: 4371e9fca744dec800be5fc1b6a0323086ac3aea0e2cc7140516e7c01c930fa8
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true require "net/http" require "time" module Neetodeploy class Worker attr_reader :mutex, :queue, :thread def initialize @mutex = Mutex.new @queue = Queue.new end def push(msg) start && queue.push(msg) end def start mutex.synchronize do return true if thread&.alive? @thread = Thread.new { run } end true end private def run until queue.empty? queue_time = queue.pop work(queue_time) end end def work(payload) url = URI.parse("http://nd-queue-time-exporter-web-deployment:3000/metrics") url.query = payload post = Net::HTTP::Post.new(url) post["AuthToken"] = "K0An3O3MSyEEMTCnRd1IHgGjdGQkzy" begin Net::HTTP.start(url.host, url.port, use_ssl: false) do |http| response = http.request(post) end rescue StandardError => e puts "Exception in sending post request to exporter from Rails process: #{e.message}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
neetodeploy-autoscale-1.0.5 | lib/neetodeploy/autoscale/worker.rb |