Last active
June 24, 2016 13:31
-
-
Save meetme2meat/352b1a33306d9a8f157f2d61cbd101f4 to your computer and use it in GitHub Desktop.
The following is the logstash-zeromq server for zeromq filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
## Please compile and install zeromq before running this script. | |
require 'rubygems' | |
require 'ffi-rzmq' | |
require 'json' | |
context = ZMQ::Context.new(1) | |
# socket to listen for clients | |
socket = context.socket(ZMQ::REP) | |
socket.bind("tcp://*:8080") | |
while true do | |
# Wait for next request from client | |
request = '' | |
rc = socket.recv_string(request) | |
puts "Received request. Data: #{request.inspect}" | |
data = JSON.parse(request) | |
# Do some 'processing' | |
# Send reply back to client | |
if data['message'].match(/logstash/) | |
data['zeromq'] = true | |
end | |
socket.send_string(data.to_json) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment