Class: LogStash::Outputs::S3::FileRepository::PrefixedValue
- Inherits:
-
Object
- Object
- LogStash::Outputs::S3::FileRepository::PrefixedValue
- Defined in:
- lib/logstash/outputs/s3/file_repository.rb
Overview
Ensure that all access or work done on a factory is threadsafe
Instance Method Summary collapse
- #apply(prefix) ⇒ Object
- #delete! ⇒ Object
- #deleted? ⇒ Boolean
-
#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.
16 17 18 19 20 21 |
# File 'lib/logstash/outputs/s3/file_repository.rb', line 16 def initialize(file_factory, stale_time) @file_factory = file_factory @lock = Monitor.new @stale_time = stale_time @is_deleted = false end |
Instance Method Details
#apply(prefix) ⇒ Object
33 34 35 |
# File 'lib/logstash/outputs/s3/file_repository.rb', line 33 def apply(prefix) return self end |
#delete! ⇒ Object
37 38 39 40 41 42 |
# File 'lib/logstash/outputs/s3/file_repository.rb', line 37 def delete! with_lock do |factory| factory.current.delete! @is_deleted = true end end |
#deleted? ⇒ Boolean
44 45 46 |
# File 'lib/logstash/outputs/s3/file_repository.rb', line 44 def deleted? with_lock { |_| @is_deleted } end |
#stale? ⇒ Boolean
29 30 31 |
# File 'lib/logstash/outputs/s3/file_repository.rb', line 29 def stale? with_lock { |factory| factory.current.size == 0 && (Time.now - factory.current.ctime > @stale_time) } end |
#with_lock ⇒ Object
23 24 25 26 27 |
# File 'lib/logstash/outputs/s3/file_repository.rb', line 23 def with_lock @lock.synchronize { yield @file_factory } end |