Skip to content

Commit

Permalink
add method to create metadata for validating in #configure
Browse files Browse the repository at this point in the history
  • Loading branch information
tagomoris committed Oct 5, 2016
1 parent 61de85f commit a7813a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/fluent/plugin/buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ def metadata_list
end
end

# it's too dangerous, and use it so carefully to remove metadata for tests
def metadata_list_clear!
synchronize do
@metadata_list.clear
end
end

def new_metadata(timekey: nil, tag: nil, variables: nil)
Metadata.new(timekey, tag, variables)
end
Expand Down
7 changes: 7 additions & 0 deletions lib/fluent/plugin/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,13 @@ def metadata(tag, time, record)
end
end

def metadata_for_test(tag, time, record)
raise "BUG: #test_metadata is available only when no actual metadata exists" unless @buffer.metadata_list.empty?
m = metadata(tag, time, record)
@buffer.metadata_list_clear!
m
end

def execute_chunking(tag, es, enqueue: false)
if @simple_chunking
handle_stream_simple(tag, es, enqueue: enqueue)
Expand Down

0 comments on commit a7813a3

Please sign in to comment.