Class: Concurrent

Inherits:
Object
  • Object
show all
Defined in:
lib/concurrent/client.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.redis_pathObject

Returns the value of attribute redis_path.



6
7
8
# File 'lib/concurrent/client.rb', line 6

def redis_path
  @redis_path
end

.redis_portObject

Returns the value of attribute redis_port.



6
7
8
# File 'lib/concurrent/client.rb', line 6

def redis_port
  @redis_port
end

Class Method Details

.config {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Concurrent)

    the object that the method was called on



9
10
11
# File 'lib/concurrent/client.rb', line 9

def self.config
  yield self
end

.pull_ticket(uniq_tag) ⇒ Object



25
26
27
# File 'lib/concurrent/client.rb', line 25

def self.pull_ticket(uniq_tag)
  redis.brpop "client:#{uniq_tag}:list", 0
end

.redis(redis_host = '127.0.0.1', redis_port = 6379) ⇒ Object



29
30
31
# File 'lib/concurrent/client.rb', line 29

def self.redis(redis_host = '127.0.0.1', redis_port = 6379)
  @@redis ||= Redis.new :host => redis_host, :port => redis_port
end

.sync(uniq_tag) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/concurrent/client.rb', line 13

def self.sync(uniq_tag)
  ticket = Ticket.new(uniq_tag)

  ticket.dispatch

  pull_ticket(uniq_tag)

  yield

  ticket.notify
end