Class: LogStash::Outputs::Qingstor::RotationPolicy
- Inherits:
-
Object
- Object
- LogStash::Outputs::Qingstor::RotationPolicy
show all
- Defined in:
- lib/logstash/outputs/qingstor/rotation_policy.rb
Defined Under Namespace
Classes: Policy, Size, SizeAndTime, Time
Instance Method Summary
collapse
Constructor Details
#initialize(policy, file_size, file_time) ⇒ RotationPolicy
Returns a new instance of RotationPolicy.
84
85
86
|
# 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
|
Instance Method Details
#needs_periodic? ⇒ Boolean
100
101
102
|
# File 'lib/logstash/outputs/qingstor/rotation_policy.rb', line 100
def needs_periodic?
@policy.needs_periodic?
end
|
#Policy(policy, file_size, file_time) ⇒ Object
75
76
77
78
79
80
81
82
|
# 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
|
#rotate?(file) ⇒ Boolean
96
97
98
|
# File 'lib/logstash/outputs/qingstor/rotation_policy.rb', line 96
def rotate?(file)
@policy.rotate?(file)
end
|
#to_bytes(file_size) ⇒ Object
92
93
94
|
# File 'lib/logstash/outputs/qingstor/rotation_policy.rb', line 92
def to_bytes(file_size)
file_size * 1024 * 1024
end
|
#to_s ⇒ Object
104
105
106
|
# File 'lib/logstash/outputs/qingstor/rotation_policy.rb', line 104
def to_s
@policy.to_s
end
|
#to_seconds(file_time) ⇒ Object
88
89
90
|
# File 'lib/logstash/outputs/qingstor/rotation_policy.rb', line 88
def to_seconds(file_time)
file_time * 60
end
|