Skip to content

Instantly share code, notes, and snippets.

@lusis
Created February 7, 2012 07:15
Show Gist options
  • Save lusis/1757907 to your computer and use it in GitHub Desktop.
Save lusis/1757907 to your computer and use it in GitHub Desktop.
zeromq filter support examples
require 'rubygems'
require 'ffi-rzmq'
require "json"
context = ZMQ::Context.new
socket = context.socket(ZMQ::REP)
socket.bind("tcp://*:2121")
msg = ''
puts "starting up"
while true do
socket.recv_string(msg)
puts "Recieved message: #{msg}"
modified_message = JSON.parse(msg)
modified_message["@message"] = "changed externally"
modified_message["@source_path"] = "fuck you"
puts "Modified message: #{modified_message.to_json}"
socket.send_string(modified_message.to_json)
end
input { stdin { type => "stdin-test" } }
filter { zeromq { } }
output { stdout { debug => true }}
require 'rubygems'
require 'ffi-rzmq'
require "json"
context = ZMQ::Context.new
socket = context.socket(ZMQ::REP)
socket.bind("tcp://*:2121")
msg = ''
puts "starting up"
while true do
socket.recv_string(msg)
puts "Recieved message: #{msg}"
modified_message = "this field was changed externally"
puts "Modified message: #{modified_message}"
socket.send_string(modified_message)
end
input { stdin { type => "stdin-test" } }
filter { zeromq { field => "@source_path" } }
output { stdout { debug => true }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment