Sha256: 2b7a68814282dd4ddaed0d0d7b971cb3db690049eb9fb29a40afe793f4a6eaef

Contents?: true

Size: 945 Bytes

Versions: 1

Compression:

Stored size: 945 Bytes

Contents

require "norikra/listener"
require "norikra-client"

module Norikra
  module Listener
    class NorikraForwarder < Norikra::Listener::Base
      def self.label
        "NORIKRA"
      end

      def self.parse_argument(argument, query_name)
        addr, target = argument.split(',', 2)
        target = query_name unless target

        host, port_str = addr.split(':', 2)
        raise Norikra::ArgumentError, "host is not specified" if host.empty?
        port = port_str ? port_str.to_i : 26571

        [target, host, port]
      end

      def initialize(argument, query_name, query_group)
        super
        @target, host, port = NorikraForwarder::parse_argument(argument, query_name)
        @client = Norikra::Client.new(host, port)
      end

      def process_async(events)
        if events.respond_to?(:map)
          events = events.map{|t, e| e }
          @client.send(@target, events)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
norikra-listener-norikra-0.0.1-java lib/norikra/listener/norikra.rb