Sha256: 0e70fde2c0d9cbc8f93202cb940ee738f14dbc579c405e2ff1ad113569ed2052

Contents?: true

Size: 1.89 KB

Versions: 8

Compression:

Stored size: 1.89 KB

Contents

# encoding: utf-8

require "logstash/namespace"
require "logstash/json"

# transient pipeline events for normal in-flow signaling as opposed to
# flow altering exceptions. for now having base classes is adequate and
# in the future it might be necessary to refactor using like a BaseEvent
# class to have a common interface for all pipeline events to support
# eventual queueing persistence for example, TBD.
module LogStash
  class SignalEvent
    def flush?; raise "abstract method"; end;
    def shutdown?; raise "abstract method"; end;
  end

  class ShutdownEvent < SignalEvent
    def flush?; false; end;
    def shutdown?; true; end;
  end

  class FlushEvent < SignalEvent
    def flush?; true; end;
    def shutdown?; false; end;
  end

  class NoSignal < SignalEvent
    def flush?; false; end;
    def shutdown?; false; end;
  end

  FLUSH = FlushEvent.new
  SHUTDOWN = ShutdownEvent.new
  NO_SIGNAL = NoSignal.new

  class Event
    MSG_BRACKETS_METHOD_MISSING = "Direct event field references (i.e. event['field']) have been disabled in favor of using event get and set methods (e.g. event.get('field')). Please consult the Logstash 5.0 breaking changes documentation for more details.".freeze
    MSG_BRACKETS_EQUALS_METHOD_MISSING = "Direct event field references (i.e. event['field'] = 'value') have been disabled in favor of using event get and set methods (e.g. event.set('field', 'value')). Please consult the Logstash 5.0 breaking changes documentation for more details.".freeze
    RE_BRACKETS_METHOD = /^\[\]$/.freeze
    RE_BRACKETS_EQUALS_METHOD = /^\[\]=$/.freeze

    def method_missing(method_name, *arguments, &block)
      if RE_BRACKETS_METHOD.match(method_name.to_s)
        raise NoMethodError.new(MSG_BRACKETS_METHOD_MISSING)
      end
      if RE_BRACKETS_EQUALS_METHOD.match(method_name.to_s)
        raise NoMethodError.new(MSG_BRACKETS_EQUALS_METHOD_MISSING)
      end
      super
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
logstash-core-6.3.2-java lib/logstash/event.rb
logstash-core-6.3.1-java lib/logstash/event.rb
logstash-core-6.3.0-java lib/logstash/event.rb
logstash-core-6.2.4-java lib/logstash/event.rb
logstash-core-6.2.3-java lib/logstash/event.rb
logstash-core-6.2.2-java lib/logstash/event.rb
logstash-core-6.2.1-java lib/logstash/event.rb
logstash-core-6.2.0-java lib/logstash/event.rb