gilmour 0.3.4 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,40 +0,0 @@
1
- require 'securerandom'
2
- require 'gilmour/backends/redis'
3
-
4
- def redis_send_and_recv(message, key, ident)
5
- redis = Gilmour::RedisBackend.new({})
6
- redis.setup_subscribers({})
7
- #loop do
8
- waiter = Thread.new { loop { sleep 1 } }
9
- newkey = "#{key}.#{SecureRandom.hex(2)}"
10
- puts "Process: #{ident} Sending: #{newkey}"
11
- redis.publish(ident, newkey) do |data, code|
12
- puts "Process: #{ident} Received: #{data}"
13
- waiter.kill
14
- end
15
- waiter.join
16
- #end
17
- end
18
-
19
- def fork_and_run(num)
20
- pid_array = []
21
-
22
- num.times do |i|
23
- pid = Process.fork do
24
- puts "Process #{i}"
25
- yield i
26
- end
27
-
28
- pid_array.push(pid)
29
- end
30
-
31
- pid_array.each do |pid|
32
- Process.waitpid(pid)
33
- end
34
-
35
- end
36
-
37
- fork_and_run(5) do |i|
38
- # Start echo server first
39
- redis_send_and_recv('Ping', 'echo', i)
40
- end