Sha256: f7176bc9c25a407282cf3075b83b3d4429dcffc195a0d869b9b8fe17a1273e3d

Contents?: true

Size: 653 Bytes

Versions: 3

Compression:

Stored size: 653 Bytes

Contents

require "crono_trigger/worker"

module CronoTrigger
  module Models
    class Worker < ActiveRecord::Base
      self.table_name = "crono_trigger_workers"

      ALIVE_THRESHOLD = CronoTrigger::Worker::HEARTBEAT_INTERVAL * 5

      enum executor_status: {running: "running", quiet: "quiet", shuttingdown: "shuttingdown", shutdown: "shutdown"}

      if ActiveRecord.version >= Gem::Version.new("7.1.0")
        serialize :polling_model_names, coder: JSON
      else
        serialize :polling_model_names, JSON
      end

      scope :alive_workers, proc { where(arel_table[:last_heartbeated_at].gteq(Time.current - ALIVE_THRESHOLD)) }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
crono_trigger-0.8.1 lib/crono_trigger/models/worker.rb
crono_trigger-0.8.0 lib/crono_trigger/models/worker.rb
crono_trigger-0.7.1 lib/crono_trigger/models/worker.rb