Sha256: 63b72383b339bb5975f6eb356c46bcc5e375dcb4d5a5b662f18b1e09022f804e

Contents?: true

Size: 769 Bytes

Versions: 5

Compression:

Stored size: 769 Bytes

Contents

#!/usr/bin/env ruby
require "readline"

# Parsing command line arguments for host and port
host = ARGV[0] || "localhost"
port = ARGV[1] || 4000

puts "Running on host: #{host} and port: #{port}"

begin
  require "kafkr"
rescue LoadError => e
  puts "Failed to load Kafkr: #{e.message}"
  exit(1)
end

begin
  Kafkr::Producer.configure do |config|
    config.host = host
    config.port = port
  end

  while line = Readline.readline("> ", true)
    break if line == "exit"

    if line.include? "<=>"
      puts Kafkr::Producer.send_message_and_wait(line)
    else
      Kafkr::Producer.send_message(line)
    end
  end
rescue => e
  puts "An error occurred: #{e.message}"
  exit(1)
rescue Interrupt
  puts "\nProducer server shutting down gracefully..."
  exit(0)
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kafkr-0.18.0 exe/kafkr-producer
kafkr-0.13.0 exe/kafkr-producer
kafkr-0.11.0 exe/kafkr-producer
kafkr-0.10.0 exe/kafkr-producer
kafkr-0.9.1 exe/kafkr-producer