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
- #group_watcher ⇒ Object
-
#initialize(watcher, path:, read_lines_limit:, read_bytes_limit_per_second:, log:, open_on_every_update:, from_encoding: nil, encoding: nil, metrics:, &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, metrics:, &receive_lines) ⇒ IOHandler
Returns a new instance of IOHandler.
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 |
# File 'lib/fluent/plugin/in_tail.rb', line 1033 def initialize(watcher, path:, read_lines_limit:, read_bytes_limit_per_second:, log:, open_on_every_update:, from_encoding: nil, encoding: nil, metrics:, &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 @metrics = metrics @log.info "following tail of #{@path}" end |
Instance Attribute Details
#shutdown_timeout ⇒ Object
Returns the value of attribute shutdown_timeout.
1031 1032 1033 |
# File 'lib/fluent/plugin/in_tail.rb', line 1031 def shutdown_timeout @shutdown_timeout end |
Instance Method Details
#close ⇒ Object
1072 1073 1074 1075 1076 1077 1078 |
# File 'lib/fluent/plugin/in_tail.rb', line 1072 def close if @io && !@io.closed? @io.close @io = nil @metrics.closed.inc end end |
#eof? ⇒ Boolean
1084 1085 1086 |
# File 'lib/fluent/plugin/in_tail.rb', line 1084 def eof? @eof end |
#group_watcher ⇒ Object
1057 1058 1059 |
# File 'lib/fluent/plugin/in_tail.rb', line 1057 def group_watcher @watcher.group_watcher end |
#on_notify ⇒ Object
1061 1062 1063 |
# File 'lib/fluent/plugin/in_tail.rb', line 1061 def on_notify @notify_mutex.synchronize { handle_notify } end |
#opened? ⇒ Boolean
1080 1081 1082 |
# File 'lib/fluent/plugin/in_tail.rb', line 1080 def opened? !!@io end |
#ready_to_shutdown(shutdown_start_time = nil) ⇒ Object
1065 1066 1067 1068 1069 1070 |
# File 'lib/fluent/plugin/in_tail.rb', line 1065 def ready_to_shutdown(shutdown_start_time = nil) @shutdown_mutex.synchronize { @shutdown_start_time = shutdown_start_time || Fluent::Clock.now } end |