Skip to content
Closed
Show file tree
Hide file tree
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
24 changes: 12 additions & 12 deletions lib/fluent/compat/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,14 @@ def start
end
end

def detach_process(&block)
def detach_process
log.warn "detach_process is not supported in this version. ignored."
block.call
yield
end

def detach_multi_process(&block)
def detach_multi_process
log.warn "detach_process is not supported in this version. ignored."
block.call
yield
end
end

Expand Down Expand Up @@ -541,14 +541,14 @@ def start
end
end

def detach_process(&block)
def detach_process
log.warn "detach_process is not supported in this version. ignored."
block.call
yield
end

def detach_multi_process(&block)
def detach_multi_process
log.warn "detach_process is not supported in this version. ignored."
block.call
yield
end
end

Expand Down Expand Up @@ -698,14 +698,14 @@ def start
end
end

def detach_process(&block)
def detach_process
log.warn "detach_process is not supported in this version. ignored."
block.call
yield
end

def detach_multi_process(&block)
def detach_multi_process
log.warn "detach_process is not supported in this version. ignored."
block.call
yield
end

# Original TimeSlicedOutput#emit doesn't call #format_stream
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/config/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ def [](key)
super
end

def check_not_fetched(&block)
def check_not_fetched
each_key { |key|
if @unused.include?(key)
block.call(key, self)
yield(key, self) if block_given?
end
}
@elements.each { |e|
Expand Down
12 changes: 6 additions & 6 deletions lib/fluent/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def slice(index, num)
end
end

def each(unpacker: nil, &block)
block.call(@time, @record)
def each(unpacker: nil)
yield(@time, @record)
nil
end
end
Expand Down Expand Up @@ -189,11 +189,11 @@ def slice(index, num)
MultiEventStream.new(@time_array.slice(index, num), @record_array.slice(index, num))
end

def each(unpacker: nil, &block)
def each(unpacker: nil)
time_array = @time_array
record_array = @record_array
for i in 0..time_array.length-1
block.call(time_array[i], record_array[i])
yield(time_array[i], record_array[i])
end
nil
end
Expand Down Expand Up @@ -253,10 +253,10 @@ def slice(index, num)
MultiEventStream.new(@unpacked_times.slice(index, num), @unpacked_records.slice(index, num))
end

def each(unpacker: nil, &block)
def each(unpacker: nil)
ensure_unpacked!(unpacker: unpacker)
@unpacked_times.each_with_index do |time, i|
block.call(time, @unpacked_records[i])
yield(time, @unpacked_records[i])
end
nil
end
Expand Down
24 changes: 12 additions & 12 deletions lib/fluent/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ def on_trace
yield
end

def trace(*args, &block)
def trace(*args)
return if @level > LEVEL_TRACE
type = log_type(args)
return if skipped_type?(type)
args << block.call if block
args << yield if block_given?
time, msg = event(:trace, args)
return if time.nil?
puts [@color_trace, @formatter.call(type, time, LEVEL_TRACE, msg), @color_reset].join
Expand All @@ -331,11 +331,11 @@ def on_debug
yield
end

def debug(*args, &block)
def debug(*args)
return if @level > LEVEL_DEBUG
type = log_type(args)
return if skipped_type?(type)
args << block.call if block
args << yield if block_given?
time, msg = event(:debug, args)
return if time.nil?
puts [@color_debug, @formatter.call(type, time, LEVEL_DEBUG, msg), @color_reset].join
Expand All @@ -352,11 +352,11 @@ def on_info
yield
end

def info(*args, &block)
def info(*args)
return if @level > LEVEL_INFO
type = log_type(args)
return if skipped_type?(type)
args << block.call if block
args << yield if block_given?
time, msg = event(:info, args)
return if time.nil?
puts [@color_info, @formatter.call(type, time, LEVEL_INFO, msg), @color_reset].join
Expand All @@ -373,11 +373,11 @@ def on_warn
yield
end

def warn(*args, &block)
def warn(*args)
return if @level > LEVEL_WARN
type = log_type(args)
return if skipped_type?(type)
args << block.call if block
args << yield if block_given?
time, msg = event(:warn, args)
return if time.nil?
puts [@color_warn, @formatter.call(type, time, LEVEL_WARN, msg), @color_reset].join
Expand All @@ -394,11 +394,11 @@ def on_error
yield
end

def error(*args, &block)
def error(*args)
return if @level > LEVEL_ERROR
type = log_type(args)
return if skipped_type?(type)
args << block.call if block
args << yield if block_given?
time, msg = event(:error, args)
return if time.nil?
puts [@color_error, @formatter.call(type, time, LEVEL_ERROR, msg), @color_reset].join
Expand All @@ -415,11 +415,11 @@ def on_fatal
yield
end

def fatal(*args, &block)
def fatal(*args)
return if @level > LEVEL_FATAL
type = log_type(args)
return if skipped_type?(type)
args << block.call if block
args << yield if block_given?
time, msg = event(:fatal, args)
return if time.nil?
puts [@color_fatal, @formatter.call(type, time, LEVEL_FATAL, msg), @color_reset].join
Expand Down
8 changes: 4 additions & 4 deletions lib/fluent/plugin/buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ class ShouldRetry < StandardError; end
# 3. enqueue existing chunk & retry whole method if chunk was not empty
# 4. go to step_by_step writing

def write_once(metadata, data, format: nil, size: nil, &block)
def write_once(metadata, data, format: nil, size: nil)
return if data.empty?

stored = false
Expand Down Expand Up @@ -701,7 +701,7 @@ def write_once(metadata, data, format: nil, size: nil, &block)
end

if stored
block.call(chunk, adding_bytesize)
yield(chunk, adding_bytesize)
end
end

Expand All @@ -726,7 +726,7 @@ def write_once(metadata, data, format: nil, size: nil, &block)
# 2. append splits into the staged chunks as much as possible
# 3. create unstaged chunk and append rest splits -> repeat it for all splits

def write_step_by_step(metadata, data, format, splits_count, &block)
def write_step_by_step(metadata, data, format, splits_count)
splits = []
if splits_count > data.size
splits_count = data.size
Expand Down Expand Up @@ -855,7 +855,7 @@ def write_step_by_step(metadata, data, format, splits_count, &block)
modified_chunks.last[:adding_bytesize] = chunk.bytesize - original_bytesize
end
modified_chunks.each do |data|
block.call(data[:chunk], data[:adding_bytesize], data[:errors])
yield(data[:chunk], data[:adding_bytesize], data[:errors])
end
rescue ShouldRetry
modified_chunks.each do |data|
Expand Down
6 changes: 3 additions & 3 deletions lib/fluent/plugin/in_forward.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def handle_connection(conn)
end
end

def read_messages(conn, &block)
def read_messages(conn)
feeder = nil
serializer = nil
bytes = 0
Expand All @@ -250,7 +250,7 @@ def read_messages(conn, &block)
if first == '{' || first == '[' # json
parser = Yajl::Parser.new
parser.on_parse_complete = ->(obj){
block.call(obj, bytes, serializer)
yield(obj, bytes, serializer)
bytes = 0
}
serializer = :to_json.to_proc
Expand All @@ -260,7 +260,7 @@ def read_messages(conn, &block)
serializer = :to_msgpack.to_proc
feeder = ->(d){
parser.feed_each(d){|obj|
block.call(obj, bytes, serializer)
yield(obj, bytes, serializer)
bytes = 0
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -972,9 +972,9 @@ def execute_chunking(tag, es, enqueue: false)
end
end

def write_guard(&block)
def write_guard
begin
block.call
yield
rescue Fluent::Plugin::Buffer::BufferOverflowError
log.warn "failed to write data into buffer by buffer overflow", action: @buffer_config.overflow_action
case @buffer_config.overflow_action
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/parser_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ def parser_type
:text
end

def parse_io(io, &block)
def parse_io(io)
y = Yajl::Parser.new
y.on_parse_complete = ->(record){
block.call(parse_time(record), record)
yield(parse_time(record), record)
}
y.parse(io, @stream_buffer_size)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin/storage_local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ def delete(key)
@store.delete(key.to_s)
end

def update(key, &block)
@store[key.to_s] = block.call(@store[key.to_s])
def update(key)
@store[key.to_s] = yield(@store[key.to_s])
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin_helper/compat_parameters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,13 @@ def compat_parameters_formatter(conf)
conf
end

def compat_parameters_copy_to_subsection_attributes(conf, params, &block)
def compat_parameters_copy_to_subsection_attributes(conf, params)
hash = {}
params.each do |compat, current|
next unless current
if conf.has_key?(compat)
if block_given?
hash[current] = block.call(compat, conf[compat])
hash[current] = yield(compat, conf[compat])
else
hash[current] = conf[compat]
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin_helper/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ def start
end
end

def formatter_operate(method_name, &block)
def formatter_operate(method_name)
@_formatters.each_pair do |usage, formatter|
begin
formatter.__send__(method_name)
block.call(formatter) if block_given?
yield(formatter) if block_given?
rescue => e
log.error "unexpected error while #{method_name}", usage: usage, formatter: formatter, error: e
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/plugin_helper/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ def start
end
end

def parser_operate(method_name, &block)
def parser_operate(method_name)
@_parsers.each_pair do |usage, parser|
begin
parser.__send__(method_name)
block.call(parser) if block_given?
yield(parser) if block_given?
rescue => e
log.error "unexpected error while #{method_name}", usage: usage, parser: parser, error: e
end
Expand Down
8 changes: 4 additions & 4 deletions lib/fluent/plugin_helper/storage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ def start
end
end

def storage_operate(method_name, &block)
def storage_operate(method_name)
@_storages.each_pair do |usage, s|
begin
block.call(s) if block_given?
yield(s) if block_given?
s.storage.__send__(method_name)
rescue => e
log.error "unexpected error while #{method_name}", usage: usage, storage: s.storage, error: e
Expand Down Expand Up @@ -275,7 +275,7 @@ def delete(key)
def update(key, &block)
@monitor.synchronize do
@storage.load
v = block.call(@storage.get(key))
v = yield(@storage.get(key))
@storage.put(key, v)
@storage.save
v
Expand Down Expand Up @@ -338,7 +338,7 @@ def delete(key)

def update(key, &block)
@monitor.synchronize do
v = block.call(@storage.get(key))
v = yield(@storage.get(key))
@storage.put(key, v)
v
end
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/rpc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def mount(path, servlet, *args)
@log.debug "register #{path} RPC servlet"
end

def mount_proc(path, &block)
def mount_proc(path)
@server.mount_proc(path) { |req, res|
begin
code, header, response = block.call(req, res)
code, header, response = yield(req, res)
rescue => e
@log.warn "failed to handle RPC request", path: path, error: e.to_s
@log.warn_backtrace e.backtrace
Expand Down
4 changes: 2 additions & 2 deletions lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ def logging_with_console_output
end
end

def main_process(&block)
def main_process
if @system_config.process_name
if @system_config.workers > 1
Process.setproctitle("worker:#{@system_config.process_name}#{ENV['SERVERENGINE_WORKER_ID']}")
Expand All @@ -1154,7 +1154,7 @@ def main_process(&block)
unrecoverable_error = false

begin
block.call
yield
rescue Fluent::ConfigError => e
logging_with_console_output do |log|
log.error "config error", file: @config_path, error: e
Expand Down
Loading
Loading