gilmour 0.3.4 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/README.md +59 -4
- data/examples/composition.rb +98 -0
- data/examples/container.rb +19 -0
- data/examples/echoclient.rb +12 -8
- data/examples/fibonacci.rb +32 -0
- data/examples/forkechoclient.rb +23 -0
- data/examples/signal_slot.rb +35 -0
- data/examples/subscribers/echo.rb +22 -0
- data/lib/gilmour/backends/backend.rb +154 -29
- data/lib/gilmour/backends/redis.rb +45 -31
- data/lib/gilmour/base.rb +61 -30
- data/lib/gilmour/composers.rb +190 -0
- data/lib/gilmour/responder.rb +184 -138
- data/lib/gilmour/waiter.rb +6 -25
- data/test/spec/helpers/common.rb +2 -22
- data/test/spec/helpers/connection.rb +2 -3
- data/test/spec/test_pipelines.rb +207 -0
- data/test/spec/test_subscriber_redis.rb +1 -1
- data/test/spec/test_subscriber_redis_forked.rb +1 -2
- data/test/spec/test_subscriber_redis_reply_slot.rb +303 -0
- data/test/spec/test_subscriber_redis_reply_slot_fork.rb +274 -0
- data/test/spec/test_waiter.rb +114 -0
- data/test/testservice/subscribers/test_reply.rb +69 -0
- data/test/testservice/subscribers/test_subscriber.rb +1 -0
- data/version.rb +1 -1
- metadata +19 -5
- data/examples/fork_log_server.rb +0 -97
- data/examples/server.rb +0 -47
- data/examples/thread_example.rb +0 -40
data/examples/thread_example.rb
DELETED
@@ -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
|