GithubHelp home page GithubHelp logo

logstash-input-nats's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

visheyra kingkorf

logstash-input-nats's Issues

plugin should avoid using global `NATS#subscribe` helper.

NATS.subscribe(subject, :queue => @queue_group ) do |msg, _, sub|

It looks like NATS#start will yield the started client to the given block, so we can use it directly with NATS::Client#subscribe instead of the global NATS::subscribe, which would enable multiple instances of this plugin to be able to run in the same Logstash process:

    NATS.start(@nats_config) do |nats_client|
      nats_client.on_error do |error|
        logger.error(error)
      end
      @subjects.each do |subject|
        logger.debug("Listening on [#{subject}]")
        nats_client.subscribe(subject, :queue => @queue_group ) do |msg, _, sub|
          @codec.decode(msg) do |event|
            decorate(event)
            event.set("nats_subject", sub)
            queue << event
          end
        end
      end
    end

Note: I also used the logger that is available on all Logstash plugins instead of Kernel#puts ๐Ÿ˜„

logstash plugins should not trap signals

['TERM', 'INT'].each { |s| trap(s) { puts; exit! } }

trapping TERM and INT in a Logstash plugin is considered bad-form, because these signals are used by Logstash for graceful shutdown. Binding them to a proc that calls Kernel#exit! is especially troublesome because that means inclusion of this plugin in one pipeline causes all pipelines to immediately and unsafely abort when receiving a signal that ordinarily would initiate a safe shutdown.

Clustered usage

Hi,

Can this plugin be used with multiple servers? Like the nats-ruby client:

NATS.start(:servers => ['nats://127.0.0.1:4222', 'nats://127.0.0.1:4223']) do |nc|
  puts "NATS is connected to #{nc.connected_server}"

  nc.on_reconnect do
    puts "Reconnected to server at #{nc.connected_server}"
  end

  nc.on_disconnect do |reason|
    puts "Disconnected: #{reason}"
  end

  nc.on_close do
    puts "Connection to NATS closed"
  end
end

Hope to hear from you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.