Class: Judoscale::Config::JobAdapterConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/judoscale/config.rb

Constant Summary collapse

UUID_REGEXP =
/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/
DEFAULT_QUEUE_FILTER =
->(queue_name) { !UUID_REGEXP.match?(queue_name) }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier, support_busy_jobs: true) ⇒ JobAdapterConfig

Returns a new instance of JobAdapterConfig.



26
27
28
29
30
# File 'lib/judoscale/config.rb', line 26

def initialize(identifier, support_busy_jobs: true)
  @identifier = identifier
  @support_busy_jobs = support_busy_jobs
  reset
end

Instance Attribute Details

#enabledObject

Returns the value of attribute enabled.



23
24
25
# File 'lib/judoscale/config.rb', line 23

def enabled
  @enabled
end

#identifierObject

Returns the value of attribute identifier.



23
24
25
# File 'lib/judoscale/config.rb', line 23

def identifier
  @identifier
end

#max_queuesObject

Returns the value of attribute max_queues.



23
24
25
# File 'lib/judoscale/config.rb', line 23

def max_queues
  @max_queues
end

#queue_filterObject

Returns the value of attribute queue_filter.



23
24
25
# File 'lib/judoscale/config.rb', line 23

def queue_filter
  @queue_filter
end

#queuesObject

Returns the value of attribute queues.



23
24
25
# File 'lib/judoscale/config.rb', line 23

def queues
  @queues
end

#track_busy_jobsObject

Returns the value of attribute track_busy_jobs.



24
25
26
# File 'lib/judoscale/config.rb', line 24

def track_busy_jobs
  @track_busy_jobs
end

Instance Method Details

#as_jsonObject



50
51
52
53
54
55
56
57
58
59
# File 'lib/judoscale/config.rb', line 50

def as_json
  {
    identifier => {
      max_queues: max_queues,
      queues: queues,
      queue_filter: queue_filter != DEFAULT_QUEUE_FILTER,
      track_busy_jobs: track_busy_jobs
    }
  }
end

#resetObject



32
33
34
35
36
37
38
39
40
# File 'lib/judoscale/config.rb', line 32

def reset
  @enabled = true
  @queues = []
  @queue_filter = DEFAULT_QUEUE_FILTER

  # Support for deprecated legacy env var configs.
  @max_queues = (ENV["JUDOSCALE_MAX_QUEUES"] || ENV["RAILS_AUTOSCALE_MAX_QUEUES"] || 20).to_i
  self.track_busy_jobs = (ENV["JUDOSCALE_LONG_JOBS"] || ENV["RAILS_AUTOSCALE_LONG_JOBS"]) == "true"
end