lib/logstash/outputs/redis.rb in logstash-output-redis-3.0.5 vs lib/logstash/outputs/redis.rb in logstash-output-redis-4.0.0
- old
+ new
@@ -19,12 +19,11 @@
config_name "redis"
default :codec, "json"
# Name is used for logging in case there are multiple instances.
- config :name, :validate => :string, :default => 'default',
- :deprecated => true
+ config :name, :validate => :string, :obsolete => "This option is obsolete"
# The hostname(s) of your Redis server(s). Ports may be specified on any
# hostname, which will override the global port config.
# If the hosts list is an array, Logstash will pick one random host to connect to,
# if that host is disconnected it will then pick another.
@@ -49,21 +48,19 @@
config :timeout, :validate => :number, :default => 5
# Password to authenticate with. There is no authentication by default.
config :password, :validate => :password
- # The name of the Redis queue (we'll use RPUSH on this). Dynamic names are
- # valid here, for example `logstash-%{type}`
- config :queue, :validate => :string, :deprecated => true
+ config :queue, :validate => :string, :obsolete => "This option is obsolete. Use `key` and `data_type`."
# The name of a Redis list or channel. Dynamic names are
# valid here, for example `logstash-%{type}`.
- config :key, :validate => :string, :required => false
+ config :key, :validate => :string, :required => true
# Either list or channel. If `redis_type` is list, then we will set
# RPUSH to key. If `redis_type` is channel, then we will PUBLISH to `key`.
- config :data_type, :validate => [ "list", "channel" ], :required => false
+ config :data_type, :validate => [ "list", "channel" ], :required => true
# Set to true if you want Redis to batch up values and send 1 RPUSH command
# instead of one command per value to push on the list. Note that this only
# works with `data_type="list"` mode right now.
#
@@ -96,29 +93,10 @@
config :congestion_interval, :validate => :number, :default => 1
def register
require 'redis'
- # TODO remove after setting key and data_type to true
- if @queue
- if @key or @data_type
- raise RuntimeError.new(
- "Cannot specify queue parameter and key or data_type"
- )
- end
- @key = @queue
- @data_type = 'list'
- end
-
- if not @key or not @data_type
- raise RuntimeError.new(
- "Must define queue, or key and data_type parameters"
- )
- end
- # end TODO
-
-
if @batch
if @data_type != "list"
raise RuntimeError.new(
"batch is not supported with data_type #{@data_type}"
)
@@ -222,10 +200,10 @@
Redis.new(params)
end # def connect
# A string used to identify a Redis instance in log messages
def identity
- @name || "redis://#{@password}@#{@current_host}:#{@current_port}/#{@db} #{@data_type}:#{@key}"
+ "redis://#{@password}@#{@current_host}:#{@current_port}/#{@db} #{@data_type}:#{@key}"
end
def send_to_redis(event, payload)
# How can I do this sort of thing with codecs?
key = event.sprintf(@key)