mosquito-cr/mosquito

Replace job#succeeded/failed/executed with an enum

Closed this issue · 0 comments

In several places the logic which determines the state of a job is getting complicated because the sate is held in several places. It would probably improve readability to combine #executed? #succeeded? and #failed? under an Enum:

    def run
      before_hook

      raise DoubleRun.new if executed
      @state = State::Running
      perform
    rescue JobFailed
      @state = State::Failed
    rescue e : DoubleRun
      raise e
    rescue e
      log "Job failed! Raised #{e.class}: #{e.message}"
      e.backtrace.each do |trace|
        log trace
      end

      @state = State::Failed
    else
      @state = State::Succeeded
    end