Class: Perkins::GitLoaderWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
lib/perkins/git_loader_worker.rb

Instance Method Summary collapse

Instance Method Details

#perform(repo_id) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/perkins/git_loader_worker.rb', line 9

def perform(repo_id)
  repo = Perkins::Repo.find(repo_id)
  #it actually clone repo and instantiates git data
  send_sse({repo: {id: repo.id, name: repo.name , status: "downloading"} })

  repo.load_git

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

#send_sse(msg) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/perkins/git_loader_worker.rb', line 19

def send_sse(msg)
  url = "#{Perkins::Application.instance.sse_endpoint}/sse"
  puts "send sse post to #{url} with msg: #{msg.to_json}".pink
  postData = Net::HTTP.post_form(
    URI.parse(url),
    {'msg'=> msg.to_json }
  )
end