Class: Rubino::API::Operations::Runs::StopOperation

Inherits:
Object
  • Object
show all
Defined in:
lib/rubino/api/operations/runs/stop_operation.rb

Overview

POST /v1/runs/:id/stop Cooperative stop: flags the run for cancellation; the executor checks between turns and exits cleanly. Returns 200 immediately — the run may still take a turn to wind down.

Raises:

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository: nil) ⇒ StopOperation

Accepts an alternate repository for tests.



19
20
21
# File 'lib/rubino/api/operations/runs/stop_operation.rb', line 19

def initialize(repository: nil)
  @repository = repository || ::Rubino::Run::Repository.new
end

Class Method Details

.call(request) ⇒ Object



14
15
16
# File 'lib/rubino/api/operations/runs/stop_operation.rb', line 14

def self.call(request)
  new.call(request)
end

Instance Method Details

#call(request) ⇒ Object

Raises:



23
24
25
26
27
28
29
# File 'lib/rubino/api/operations/runs/stop_operation.rb', line 23

def call(request)
  id = request.params.fetch("id")
  raise NotFoundError.new("run", id) unless @repository.find(id)

  @repository.request_stop!(id)
  [200, { id: id, status: "stop_requested" }]
end