Class: SolidQueue::Queue

Inherits:
Object
  • Object
show all
Defined in:
app/models/solid_queue/queue.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Queue

Returns a new instance of Queue.



19
20
21
# File 'app/models/solid_queue/queue.rb', line 19

def initialize(name)
  @name = name
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



5
6
7
# File 'app/models/solid_queue/queue.rb', line 5

def name
  @name
end

Class Method Details

.allObject



8
9
10
11
12
# File 'app/models/solid_queue/queue.rb', line 8

def all
  Job.select(:queue_name).distinct.collect do |job|
    new(job.queue_name)
  end
end

.find_by_name(name) ⇒ Object



14
15
16
# File 'app/models/solid_queue/queue.rb', line 14

def find_by_name(name)
  new(name)
end

Instance Method Details

#==(queue) ⇒ Object Also known as: eql?



43
44
45
# File 'app/models/solid_queue/queue.rb', line 43

def ==(queue)
  name == queue.name
end

#clearObject



35
36
37
# File 'app/models/solid_queue/queue.rb', line 35

def clear
  ReadyExecution.queued_as(name).discard_all_in_batches
end

#hashObject



48
49
50
# File 'app/models/solid_queue/queue.rb', line 48

def hash
  name.hash
end

#pauseObject



27
28
29
# File 'app/models/solid_queue/queue.rb', line 27

def pause
  Pause.create_or_find_by!(queue_name: name)
end

#paused?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/models/solid_queue/queue.rb', line 23

def paused?
  Pause.exists?(queue_name: name)
end

#resumeObject



31
32
33
# File 'app/models/solid_queue/queue.rb', line 31

def resume
  Pause.where(queue_name: name).delete_all
end

#sizeObject



39
40
41
# File 'app/models/solid_queue/queue.rb', line 39

def size
  @size ||= ReadyExecution.queued_as(name).count
end