File tree Expand file tree Collapse file tree 2 files changed +20
-24
lines changed Expand file tree Collapse file tree 2 files changed +20
-24
lines changed Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env ruby
2
- # encoding: utf-8
3
2
4
- require " bunny"
3
+ require ' bunny'
5
4
6
- conn = Bunny . new ( :automatically_recover => false )
7
- conn . start
5
+ connection = Bunny . new
6
+ connection . start
8
7
9
- ch = conn . create_channel
10
- x = ch . fanout ( " logs" )
8
+ channel = connection . create_channel
9
+ exchange = channel . fanout ( ' logs' )
11
10
12
- msg = ARGV . empty? ? " Hello World!" : ARGV . join ( " " )
11
+ message = ARGV . empty? ? ' Hello World!' : ARGV . join ( ' ' )
13
12
14
- x . publish ( msg )
15
- puts " [x] Sent #{ msg } "
13
+ exchange . publish ( message )
14
+ puts " [x] Sent #{ message } "
16
15
17
- conn . close
16
+ connection . close
Original file line number Diff line number Diff line change 1
1
#!/usr/bin/env ruby
2
- # encoding: utf-8
3
2
4
- require " bunny"
3
+ require ' bunny'
5
4
6
- conn = Bunny . new ( :automatically_recover => false )
7
- conn . start
5
+ connection = Bunny . new
6
+ connection . start
8
7
9
- ch = conn . create_channel
10
- x = ch . fanout ( " logs" )
11
- q = ch . queue ( "" , : exclusive => true )
8
+ channel = connection . create_channel
9
+ exchange = channel . fanout ( ' logs' )
10
+ queue = channel . queue ( '' , exclusive : true )
12
11
13
- q . bind ( x )
12
+ queue . bind ( exchange )
14
13
15
- puts " [*] Waiting for logs. To exit press CTRL+C"
14
+ puts ' [*] Waiting for logs. To exit press CTRL+C'
16
15
17
16
begin
18
- q . subscribe ( : block => true ) do |delivery_info , properties , body |
17
+ queue . subscribe ( block : true ) do |_delivery_info , _properties , body |
19
18
puts " [x] #{ body } "
20
19
end
21
20
rescue Interrupt => _
22
- ch . close
23
- conn . close
24
-
25
- exit ( 0 )
21
+ channel . close
22
+ connection . close
26
23
end
You can’t perform that action at this time.
0 commit comments