Class: ProconBypassMan::Background::JobQueue

Inherits:
Object
  • Object
show all
Extended by:
CanOverProcess
Includes:
Singleton
Defined in:
lib/procon_bypass_man/background/job_queue.rb

Constant Summary

Constants included from CanOverProcess

CanOverProcess::PROTOCOL

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CanOverProcess

distributed_class, enable?, extended, shutdown_distributed_object, socket_file_path, socket_path, start_distributed_object!

Constructor Details

#initialize ⇒ JobQueue

Returns a new instance of JobQueue.



47
48
49
# File 'lib/procon_bypass_man/background/job_queue.rb', line 47

def initialize
  @distributed_queue = DRbObject.new_with_uri(self.class.socket_path)
end

Instance Attribute Details

#distributed_queue ⇒ Object (readonly)

Returns the value of attribute distributed_queue.



6
7
8
# File 'lib/procon_bypass_man/background/job_queue.rb', line 6

def distributed_queue
  @distributed_queue
end

Class Method Details

.clear ⇒ Object



41
42
43
44
45
# File 'lib/procon_bypass_man/background/job_queue.rb', line 41

def self.clear
  return unless enable?

  instance.distributed_queue.clear
end

.distributed_class ⇒ Object



14
15
16
# File 'lib/procon_bypass_man/background/job_queue.rb', line 14

def self.distributed_class
  Queue
end

.enable? ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/procon_bypass_man/background/job_queue.rb', line 9

def self.enable?
  true
end

.pop ⇒ Object



29
30
31
32
33
# File 'lib/procon_bypass_man/background/job_queue.rb', line 29

def self.pop
  return unless enable?

  instance.distributed_queue.pop
end

.push(value) ⇒ Object



23
24
25
26
27
# File 'lib/procon_bypass_man/background/job_queue.rb', line 23

def self.push(value)
  return unless enable?

  instance.distributed_queue.push(value)
end

.size ⇒ Object



35
36
37
38
39
# File 'lib/procon_bypass_man/background/job_queue.rb', line 35

def self.size
  return unless enable?

  instance.distributed_queue.size
end

.socket_file_path ⇒ Object



19
20
21
# File 'lib/procon_bypass_man/background/job_queue.rb', line 19

def self.socket_file_path
  "/tmp/procon_bypass_man_background_job_queue_queue".freeze
end