Skip to content

Commit

Permalink
Skip nil record at input and engine. fixes #176
Browse files Browse the repository at this point in the history
  • Loading branch information
repeatedly committed Aug 29, 2013
1 parent b337d53 commit 9dab1d7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/fluent/engine.rb
Expand Up @@ -114,7 +114,9 @@ def load_plugin_dir(dir)
end

def emit(tag, time, record)
emit_stream tag, OneEventStream.new(time, record)
unless record.nil?
emit_stream tag, OneEventStream.new(time, record)
end
end

def emit_array(tag, array)
Expand Down
6 changes: 4 additions & 2 deletions lib/fluent/plugin/in_forward.rb
Expand Up @@ -124,18 +124,20 @@ def on_message(msg)
# Forward
es = MultiEventStream.new
entries.each {|e|
record = e[1]
next if record.nil?
time = e[0].to_i
time = (now ||= Engine.now) if time == 0
record = e[1]
es.add(time, record)
}
Engine.emit_stream(tag, es)

else
# Message
record = msg[2]
return if record.nil?
time = msg[1]
time = Engine.now if time == 0
record = msg[2]
Engine.emit(tag, time, record)
end
end
Expand Down
5 changes: 5 additions & 0 deletions lib/fluent/plugin/in_http.rb
Expand Up @@ -117,6 +117,11 @@ def on_request(path_info, params)
raise "'json' or 'msgpack' parameter is required"
end

# Skip nil record
if record.nil?
return ["200 OK", {'Content-type'=>'text/plain'}, ""]
end

time = params['time']
time = time.to_i
if time == 0
Expand Down
7 changes: 5 additions & 2 deletions lib/fluent/plugin/in_stream.rb
Expand Up @@ -84,18 +84,21 @@ def on_message(msg)
# Forward
es = MultiEventStream.new
entries.each {|e|
record = e[1]
next if record.nil?
time = e[0].to_i
time = (now ||= Engine.now) if time == 0
record = e[1]
es.add(time, record)
}
Engine.emit_stream(tag, es)

else
# Message
record = msg[2]
return if record.nil?

time = msg[1]
time = Engine.now if time == 0
record = msg[2]
Engine.emit(tag, time, record)
end
end
Expand Down

1 comment on commit 9dab1d7

@tagomoris
Copy link
Member

Choose a reason for hiding this comment

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

👍

Please sign in to comment.