class Kafka::Producer

Overview

represents a kafka producer

Defined in:

kafka/producer.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(conf : Config) #

creates a new kafka handle using provided config. Throws exception on error


[View source]

Instance Method Detail

def flush(timeout_ms : Int32) #

[View source]
def polling : Bool #

returns true if polling fiber is running


[View source]
def produce(msg : String, partition : Int32 = LibKafkaC::PARTITION_UNASSIGNED, key : String | Nil = nil, flags : Int32 = LibKafkaC::MSG_FLAG_COPY) #

enqueues msg Will start internal polling fiber, if not already started. returns true on success. Raises exception otherwise


[View source]
def set_topic(name : String) #

Set the topic to use for produce() calls. Raises exception on error.


[View source]
def stop #

Calls flush(1000) and will stop polling fiber, if running.


[View source]