class LogStash::Outputs::Qingstor::RotationPolicy

Public Class Methods

new(policy, file_size, file_time) click to toggle source
# File lib/logstash/outputs/qingstor/rotation_policy.rb, line 84
def initialize(policy, file_size, file_time)
  @policy = Policy(policy, to_bytes(file_size), to_seconds(file_time))
end

Public Instance Methods

Policy(policy, file_size, file_time) click to toggle source
# File lib/logstash/outputs/qingstor/rotation_policy.rb, line 75
def Policy(policy, file_size, file_time)
  case policy
  when Policy then policy
  else
    self.class.const_get(policy.to_s.split('_').map(&:capitalize).join)
        .new(file_size, file_time)
  end
end
needs_periodic?() click to toggle source
# File lib/logstash/outputs/qingstor/rotation_policy.rb, line 100
def needs_periodic?
  @policy.needs_periodic?
end
rotate?(file) click to toggle source
# File lib/logstash/outputs/qingstor/rotation_policy.rb, line 96
def rotate?(file)
  @policy.rotate?(file)
end
to_bytes(file_size) click to toggle source
# File lib/logstash/outputs/qingstor/rotation_policy.rb, line 92
def to_bytes(file_size)
  file_size * 1024 * 1024
end
to_s() click to toggle source
# File lib/logstash/outputs/qingstor/rotation_policy.rb, line 104
def to_s
  @policy.to_s
end
to_seconds(file_time) click to toggle source
# File lib/logstash/outputs/qingstor/rotation_policy.rb, line 88
def to_seconds(file_time)
  file_time * 60
end