Class: LogStash::Outputs::TestSink

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/outputs/test_sink.rb

Overview

This output simply discards (but tracks) received events.

Defined Under Namespace

Classes: Queue

Constant Summary collapse

TRACKER =
java.util.WeakHashMap.new

Instance Method Summary collapse

Instance Method Details

#clear!Object

Clears the event store.



48
49
50
# File 'lib/logstash/outputs/test_sink.rb', line 48

def clear!
  event_store.clear
end

#closeObject



34
35
36
37
# File 'lib/logstash/outputs/test_sink.rb', line 34

def close
  TRACKER.delete(self)
  @_event_store = false if release_on_close?
end

#event_storeQueue

Returns (enumerable) event store.

Returns:

  • (Queue)

    (enumerable) event store



53
54
55
56
57
58
59
60
61
62
# File 'lib/logstash/outputs/test_sink.rb', line 53

def event_store
  if @_event_store.nil?
    warn("#{self} event store not initialized (call plugin.register to initialize)", caller_locations(2))
    return init_event_store
  elsif @_event_store.eql?(false)
    warn("#{self} closed - event store no longer available (release_on_close => false if you need to retain events)", caller_locations(2))
    return nil
  end
  @_event_store
end

#init_event_storeObject



64
65
66
# File 'lib/logstash/outputs/test_sink.rb', line 64

def init_event_store
  @_event_store = Queue.new(@event_poll_timeout.to_f * 1000)
end

#receive(event) ⇒ Object



29
30
31
# File 'lib/logstash/outputs/test_sink.rb', line 29

def receive(event)
  event_store << event if store_events?
end

#registerObject



24
25
26
# File 'lib/logstash/outputs/test_sink.rb', line 24

def register
  TRACKER[self] = @_event_store || init_event_store
end

#release_on_close?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/logstash/outputs/test_sink.rb', line 43

def release_on_close?
  !!@release_on_close
end

#store_events?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/logstash/outputs/test_sink.rb', line 39

def store_events?
  !!@store_events
end