Skip to content

Commit

Permalink
Basic TLS/SLL suppport
Browse files Browse the repository at this point in the history
  • Loading branch information
u-ichi committed Feb 25, 2013
1 parent 0f5c79d commit 234852f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/fluent/plugin/in_nats.rb
Expand Up @@ -8,6 +8,9 @@ class NATSInput < Input
config_param :port, :integer, :default => 4222
config_param :queue, :string, :default => "fluent.>"
config_param :tag, :string, :default => "nats"
config_param :ssl, :bool, :default => false
config_param :max_reconnect_attempts, :integer, :default => 150
config_param :reconnect_time_wait, :integer, :default => 2

def initialize
require "nats/client"
Expand All @@ -19,10 +22,18 @@ def initialize
def configure(conf)
super
@conf = conf
@uri = "nats://#{@user}:#{@password}@#{@host}:#{@port}"
unless @host && @queue
raise ConfigError, "'host' and 'queue' must be all specified."
end

@nats_config = {
:uri => "nats://#{@host}:#{@port}",
:ssl => @ssl,
:user => @user,
:pass => @password,
:reconnect_time_wait => @reconnect_time_wait,
:max_reconnect_attempts => @max_reconnect_attempts,
}
end

def start
Expand All @@ -42,7 +53,7 @@ def shutdown

def run
EM.next_tick {
@nats_conn = NATS.connect(:uri => @uri) {
@nats_conn = NATS.connect(@nats_config) {
@nats_conn.subscribe(@queue) do |msg, reply, sub|
tag = "#{@tag}.#{sub}"
begin
Expand Down

0 comments on commit 234852f

Please sign in to comment.