Class: Integrations::IrkerWorker

Inherits:
Object
  • Object
show all
Includes:
ApplicationWorker
Defined in:
app/workers/integrations/irker_worker.rb

Overview

rubocop:disable Scalability/IdempotentWorker

Constant Summary

Constants included from ApplicationWorker

ApplicationWorker::LOGGING_EXTRA_KEY, ApplicationWorker::SAFE_PUSH_BULK_LIMIT

Constants included from Gitlab::Loggable

Gitlab::Loggable::ANONYMOUS

Constants included from WorkerAttributes

WorkerAttributes::DEFAULT_DATA_CONSISTENCY, WorkerAttributes::DEFAULT_DEFER_DELAY, WorkerAttributes::NAMESPACE_WEIGHTS, WorkerAttributes::VALID_DATA_CONSISTENCIES, WorkerAttributes::VALID_RESOURCE_BOUNDARIES, WorkerAttributes::VALID_URGENCIES

Instance Method Summary collapse

Methods included from Gitlab::Loggable

#build_structured_payload

Methods included from Gitlab::SidekiqVersioning::Worker

#job_version

Methods included from WorkerContext

#with_context

Instance Method Details

#perform(project_id, channels, colors, push_data, settings) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/workers/integrations/irker_worker.rb', line 16

def perform(project_id, channels, colors, push_data, settings)
  # Establish connection to irker server
  return false unless start_connection(
    settings['server_host'],
    settings['server_port']
  )

  @project = Project.find(project_id)
  @colors = colors
  @channels = channels

  @repo_path = @project.full_path
  @repo_name = push_data['repository']['name']
  @committer = push_data['user_name']
  @branch = push_data['ref'].gsub(%r{refs/[^/]*/}, '')

  if @colors
    @repo_name = "\x0304#{@repo_name}\x0f"
    @branch = "\x0305#{@branch}\x0f"
  end

  # First messages are for branch creation/deletion
  send_branch_updates(push_data)

  # Next messages are for commits
  send_commits(push_data)

  close_connection
  true
end