module Fluent::Compat::AddTimeSliceKeyToChunkMixin

Public Instance Methods

assume_timekey!() click to toggle source
# File lib/fluent/compat/output.rb, line 85
def assume_timekey!
  @_formatter = Fluent::TimeFormatter.new(@_time_slice_format, nil, @_timezone)

  return if self.metadata.timekey
  if self.respond_to?(:path) && self.path =~ /\.(\d+)\.(?:b|q)(?:[a-z0-9]+)/
    begin
      self.metadata.timekey = Time.parse($1, @_time_slice_format).to_i
    rescue ArgumentError
      # unknown format / value as timekey
    end
  end
  unless self.metadata.timekey
    # file creation time is assumed in the time range of that time slice
    # because the first record should be in that range.
    time_int = self.created_at.to_i
    self.metadata.timekey = time_int - (time_int % @_timekey)
  end
end
key() click to toggle source
# File lib/fluent/compat/output.rb, line 104
def key
  @_formatter.call(self.metadata.timekey)
end
time_slice_format=(format) click to toggle source
# File lib/fluent/compat/output.rb, line 73
def time_slice_format=(format)
  @_time_slice_format = format
end
timekey=(unit) click to toggle source
# File lib/fluent/compat/output.rb, line 77
def timekey=(unit)
  @_timekey = unit
end
timezone=(tz) click to toggle source
# File lib/fluent/compat/output.rb, line 81
def timezone=(tz)
  @_timezone = tz
end