Class: Ci::UpdateBuildStateService

Inherits:
Object
  • Object
show all
Includes:
Gitlab::ExclusiveLeaseHelpers, Gitlab::Utils::StrongMemoize
Defined in:
app/services/ci/update_build_state_service.rb

Defined Under Namespace

Classes: Result

Constant Summary collapse

InvalidTraceError =
Class.new(StandardError)
ACCEPT_TIMEOUT =
5.minutes.freeze

Constants included from Gitlab::ExclusiveLeaseHelpers

Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::ExclusiveLeaseHelpers

#in_lock

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Constructor Details

#initialize(build, params, metrics = ::Gitlab::Ci::Trace::Metrics.new) ⇒ UpdateBuildStateService

Returns a new instance of UpdateBuildStateService.


15
16
17
18
19
# File 'app/services/ci/update_build_state_service.rb', line 15

def initialize(build, params, metrics = ::Gitlab::Ci::Trace::Metrics.new)
  @build = build
  @params = params
  @metrics = metrics
end

Instance Attribute Details

#buildObject (readonly)

Returns the value of attribute build.


13
14
15
# File 'app/services/ci/update_build_state_service.rb', line 13

def build
  @build
end

#metricsObject (readonly)

Returns the value of attribute metrics.


13
14
15
# File 'app/services/ci/update_build_state_service.rb', line 13

def metrics
  @metrics
end

#paramsObject (readonly)

Returns the value of attribute params.


13
14
15
# File 'app/services/ci/update_build_state_service.rb', line 13

def params
  @params
end

Instance Method Details

#executeObject


21
22
23
24
25
26
27
28
29
30
31
# File 'app/services/ci/update_build_state_service.rb', line 21

def execute
  unless accept_available?
    return update_build_state!
  end

  ensure_pending_state!

  in_build_trace_lock do
    process_build_state!
  end
end