Class: LogStash::Outputs::Qingstor::FileRepository::PrefixedValue
- Inherits:
-
Object
- Object
- LogStash::Outputs::Qingstor::FileRepository::PrefixedValue
- Defined in:
- lib/logstash/outputs/qingstor/file_repository.rb
Instance Method Summary collapse
- #apply(_prefix) ⇒ Object
- #delete! ⇒ Object
-
#initialize(file_factory, stale_time) ⇒ PrefixedValue
constructor
A new instance of PrefixedValue.
- #stale? ⇒ Boolean
- #with_lock ⇒ Object
Constructor Details
#initialize(file_factory, stale_time) ⇒ PrefixedValue
Returns a new instance of PrefixedValue.
18 19 20 21 22 |
# File 'lib/logstash/outputs/qingstor/file_repository.rb', line 18 def initialize(file_factory, stale_time) @file_factory = file_factory @lock = Mutex.new @stale_time = stale_time end |
Instance Method Details
#apply(_prefix) ⇒ Object
37 38 39 |
# File 'lib/logstash/outputs/qingstor/file_repository.rb', line 37 def apply(_prefix) self end |
#delete! ⇒ Object
41 42 43 |
# File 'lib/logstash/outputs/qingstor/file_repository.rb', line 41 def delete! with_lock { |factory| factory.current.delete! } end |
#stale? ⇒ Boolean
30 31 32 33 34 35 |
# File 'lib/logstash/outputs/qingstor/file_repository.rb', line 30 def stale? with_lock do |factory| factory.current.empty? && (Time.now - factory.current.ctime > @stale_time) end end |
#with_lock ⇒ Object
24 25 26 27 28 |
# File 'lib/logstash/outputs/qingstor/file_repository.rb', line 24 def with_lock @lock.synchronize do yield @file_factory end end |