Class: LogStash::Outputs::Gcs::SynchronizedLogFile
- Inherits:
-
Object
- Object
- LogStash::Outputs::Gcs::SynchronizedLogFile
- Defined in:
- lib/logstash/outputs/gcs/temp_log_file.rb
Overview
SynchronizedLogFile wraps another log file and uses reentrant locks around its methods to prevent concurrent modification.
Instance Method Summary collapse
-
#initialize(child) ⇒ SynchronizedLogFile
constructor
A new instance of SynchronizedLogFile.
- #method_missing(method_name, *args, &block) ⇒ Object
- #path ⇒ Object
- #time_since_sync ⇒ Object
Constructor Details
#initialize(child) ⇒ SynchronizedLogFile
Returns a new instance of SynchronizedLogFile.
89 90 91 92 |
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 89 def initialize(child) @child = child @lock = Concurrent::ReentrantReadWriteLock.new end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
102 103 104 105 106 107 |
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 102 def method_missing(method_name, *args, &block) # unless otherwise specified, get a write lock @lock.with_write_lock do @child.send(method_name, *args, &block) end end |
Instance Method Details
#path ⇒ Object
98 99 100 |
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 98 def path @lock.with_read_lock { @child.path } end |
#time_since_sync ⇒ Object
94 95 96 |
# File 'lib/logstash/outputs/gcs/temp_log_file.rb', line 94 def time_since_sync @lock.with_read_lock { @child.time_since_sync } end |