Class: LogStash::Outputs::LogstashAzureBlobOutput::FileRepository::PrefixedValue
- Inherits:
-
Object
- Object
- LogStash::Outputs::LogstashAzureBlobOutput::FileRepository::PrefixedValue
- Defined in:
- lib/logstash/outputs/blob/file_repository.rb
Overview
Ensure that all access or work done on a factory is threadsafe
Instance Method Summary collapse
-
#apply(_prefix) ⇒ Object
return this class.
-
#delete! ⇒ Object
delete the current factory.
-
#initialize(file_factory, stale_time) ⇒ PrefixedValue
constructor
initialize the factory.
-
#stale? ⇒ Boolean
boolean method.
-
#with_lock ⇒ Object
activate the lock.
Constructor Details
#initialize(file_factory, stale_time) ⇒ PrefixedValue
initialize the factory
21 22 23 24 25 |
# File 'lib/logstash/outputs/blob/file_repository.rb', line 21 def initialize(file_factory, stale_time) @file_factory = file_factory @lock = Mutex.new @stale_time = stale_time end |
Instance Method Details
#apply(_prefix) ⇒ Object
return this class
40 41 42 |
# File 'lib/logstash/outputs/blob/file_repository.rb', line 40 def apply(_prefix) self end |
#delete! ⇒ Object
delete the current factory
45 46 47 |
# File 'lib/logstash/outputs/blob/file_repository.rb', line 45 def delete! with_lock { |factory| factory.current.delete! } end |
#stale? ⇒ Boolean
boolean method
35 36 37 |
# File 'lib/logstash/outputs/blob/file_repository.rb', line 35 def stale? with_lock { |factory| factory.current.size.zero? && (Time.now - factory.current.ctime > @stale_time) } end |
#with_lock ⇒ Object
activate the lock
28 29 30 31 32 |
# File 'lib/logstash/outputs/blob/file_repository.rb', line 28 def with_lock @lock.synchronize do yield @file_factory end end |