Class: Fluent::Plugin::TailInput::TailWatcher::IOHandler
- Inherits:
-
Object
- Object
- Fluent::Plugin::TailInput::TailWatcher::IOHandler
- Defined in:
- lib/fluent/plugin/in_tail.rb
Constant Summary collapse
- BYTES_TO_READ =
8192
- SHUTDOWN_TIMEOUT =
5
Instance Attribute Summary collapse
-
#shutdown_timeout ⇒ Object
Returns the value of attribute shutdown_timeout.
Instance Method Summary collapse
- #close ⇒ Object
- #eof? ⇒ Boolean
-
#initialize(watcher, path:, read_lines_limit:, read_bytes_limit_per_second:, log:, open_on_every_update:, from_encoding: nil, encoding: nil, &receive_lines) ⇒ IOHandler
constructor
A new instance of IOHandler.
- #on_notify ⇒ Object
- #opened? ⇒ Boolean
- #ready_to_shutdown(shutdown_start_time = nil) ⇒ Object
Constructor Details
#initialize(watcher, path:, read_lines_limit:, read_bytes_limit_per_second:, log:, open_on_every_update:, from_encoding: nil, encoding: nil, &receive_lines) ⇒ IOHandler
Returns a new instance of IOHandler.
929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 |
# File 'lib/fluent/plugin/in_tail.rb', line 929 def initialize(watcher, path:, read_lines_limit:, read_bytes_limit_per_second:, log:, open_on_every_update:, from_encoding: nil, encoding: nil, &receive_lines) @watcher = watcher @path = path @read_lines_limit = read_lines_limit @read_bytes_limit_per_second = read_bytes_limit_per_second @receive_lines = receive_lines @open_on_every_update = open_on_every_update @fifo = FIFO.new(from_encoding || Encoding::ASCII_8BIT, encoding || Encoding::ASCII_8BIT) @iobuf = ''.force_encoding('ASCII-8BIT') @lines = [] @io = nil @notify_mutex = Mutex.new @log = log @start_reading_time = nil @number_bytes_read = 0 @shutdown_start_time = nil @shutdown_timeout = SHUTDOWN_TIMEOUT @shutdown_mutex = Mutex.new @eof = false @log.info "following tail of #{@path}" end |
Instance Attribute Details
#shutdown_timeout ⇒ Object
Returns the value of attribute shutdown_timeout.
927 928 929 |
# File 'lib/fluent/plugin/in_tail.rb', line 927 def shutdown_timeout @shutdown_timeout end |
Instance Method Details
#close ⇒ Object
963 964 965 966 967 968 |
# File 'lib/fluent/plugin/in_tail.rb', line 963 def close if @io && !@io.closed? @io.close @io = nil end end |
#eof? ⇒ Boolean
974 975 976 |
# File 'lib/fluent/plugin/in_tail.rb', line 974 def eof? @eof end |
#on_notify ⇒ Object
952 953 954 |
# File 'lib/fluent/plugin/in_tail.rb', line 952 def on_notify @notify_mutex.synchronize { handle_notify } end |
#opened? ⇒ Boolean
970 971 972 |
# File 'lib/fluent/plugin/in_tail.rb', line 970 def opened? !!@io end |