Class: LogStash::Codecs::AutoFlush

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/codecs/auto_flush.rb

Instance Method Summary collapse

Constructor Details

#initialize(mc, interval) ⇒ AutoFlush

Returns a new instance of AutoFlush.



6
7
8
9
10
# File 'lib/logstash/codecs/auto_flush.rb', line 6

def initialize(mc, interval)
  @mc, @interval = mc, interval
  @stopped = Concurrent::AtomicBoolean.new # false by default
  @task = RetriggerableTask.new(@interval, self)
end

Instance Method Details

#startObject



16
17
18
19
20
21
# File 'lib/logstash/codecs/auto_flush.rb', line 16

def start
  # can't start if pipeline is stopping
  return self if stopped?
  @task.retrigger
  self
end

#stopObject



27
28
29
30
# File 'lib/logstash/codecs/auto_flush.rb', line 27

def stop
  @stopped.make_true
  @task.close
end

#stopped?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/logstash/codecs/auto_flush.rb', line 23

def stopped?
  @stopped.value
end

#timeoutObject



12
13
14
# File 'lib/logstash/codecs/auto_flush.rb', line 12

def timeout
  @mc.auto_flush
end