Skip to content

Update redis.rb #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions lib/logstash/outputs/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class LogStash::Outputs::Redis < LogStash::Outputs::Base

# 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 => true
config :data_type, :validate => [ "list", "channel","set"], :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
Expand Down Expand Up @@ -211,13 +211,17 @@ def send_to_redis(event, payload)
end

begin
@redis ||= connect
if @data_type == 'list'
congestion_check(key)
@redis.rpush(key, payload)
else
@redis.publish(key, payload)
end
# gestion du set
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this comment means

@redis ||= connect
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation has gone awry here.

if @data_type == 'list'
congestion_check(key)
@redis.rpush(key, payload)
else
if @data_type == 'channel'
@redis.publish(key, payload)
else
@redis.set(key, payload)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it stands, this PR does not compile, due to a missing end

rescue => e
@logger.warn("Failed to send event to Redis", :event => event,
:identity => identity, :exception => e,
Expand Down