Skip to content

Commit

Permalink
out_forward: Support dns round robin
Browse files Browse the repository at this point in the history
  • Loading branch information
sonots committed Jul 1, 2015
1 parent 6002b9b commit 1c1a0fb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
7 changes: 7 additions & 0 deletions example/in_forward.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<source>
type forward
</source>

<match test>
type stdout
</match>
7 changes: 6 additions & 1 deletion example/out_forward.conf
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
<source>
type forward
type dummy
tag test
</source>

<match test>
type forward

<server>
# first server
host localhost
port 24224
</server>
<server>
# second server
host localhost
port 24225
</server>
<server>
# second server
host localhost
port 24226
standby
</server>

flush_interval 1
send_timeout 60
heartbeat_type udp
heartbeat_interval 1
Expand Down
1 change: 1 addition & 0 deletions lib/fluent/load.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'thread'
require 'socket'
require 'resolv'
require 'fcntl'
require 'time'
require 'monitor'
Expand Down
5 changes: 2 additions & 3 deletions lib/fluent/plugin/out_forward.rb
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,8 @@ def resolved_host
end

def resolve_dns!
@sockaddr = Socket.pack_sockaddr_in(@port, @host)
port, resolved_host = Socket.unpack_sockaddr_in(@sockaddr)
return resolved_host
# shuffle to support dns round robin
Resolv.getaddresses(@host).shuffle!.first
end
private :resolve_dns!

Expand Down

0 comments on commit 1c1a0fb

Please sign in to comment.