Sha256: 5f5aada227b1cc481886b38e4fb60612e201de058e927d61f92d1f9765081c0c

Contents?: true

Size: 677 Bytes

Versions: 1

Compression:

Stored size: 677 Bytes

Contents

require 'net/http'
require "uri"

module Perkins
  class Worker

    #include Celluloid

    def self.perform(repo, sha, branch)
      repo.load_git

      return if repo.runner.blank?

      repo.runner.sha    = sha
      repo.runner.branch = branch

      send_sse({repo: {id: repo.id, name: repo.name , status: "start"} })

      repo.runner.run(sha)

      report = repo.build_reports.find_by(sha: sha)
      send_sse({repo: {id: repo.id, name: repo.name , status: "stop", report: report } })
    end

    def self.send_sse(msg)
      postData = Net::HTTP.post_form(
        URI.parse('http://localhost:3000/sse'),
        {'msg'=> msg.to_json }
      )
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
perkins-0.0.1 lib/perkins/worker.rb