Class: Ci::RegisterJobService::ResultFactory

Inherits:
Object
  • Object
show all
Defined in:
app/services/ci/register_job_service.rb

Class Method Summary collapse

Class Method Details

.conflict(valid:) ⇒ Object

Returns a conflict result without a build. When returned from process_build:

  • Continues the queue processing loop to try the next build

  • Marks the queue as invalid (valid: false) if there was a conflict

  • If all builds are exhausted, returns HTTP 409 Conflict to the runner



27
28
29
# File 'app/services/ci/register_job_service.rb', line 27

def self.conflict(valid:)
  Result.new(build: nil, build_json: nil, build_presented: nil, valid?: valid)
end

.invalidObject

Returns an invalid result (conflict with valid: false). Use this when a build cannot be assigned due to a conflict (e.g., StaleObjectError, InvalidTransition) to signal that the runner should retry the request. The loop continues to try other builds, but if all builds fail, returns HTTP 409.



35
36
37
# File 'app/services/ci/register_job_service.rb', line 35

def self.invalid
  conflict(valid: false)
end

.success(build, build_json, build_presented) ⇒ Object

Returns a successful result with a build assigned to the runner. This stops the queue processing loop and returns the build to the runner.



18
19
20
# File 'app/services/ci/register_job_service.rb', line 18

def self.success(build, build_json, build_presented)
  Result.new(build: build, build_json: build_json, build_presented: build_presented, valid?: true)
end