KafkaClient

public class KafkaClient

A class for clients that will connect to a Kafka server.
This can either be a KafkaConsumer or a KafkaProducer.

  • Connect as a client to the servers (Kafka broker) at the provided addresses.

    Usage Example:

    let producer = try? KafkaProducer()
    let connectionCount = producer?.connect(brokers: "localhost:9092, localhost:9093")
    guard connectionCount == 2 else {
       print("Failed to connect to brokers")
    }
    

    Declaration

    Swift

    public func connect(brokers: String) -> Int

    Return Value

    The number of brokers that were successfully connected.

  • Connect as a client to the servers (Kafka broker) at the provided addresses.

    Usage Example:

    let producer = try? KafkaProducer()
    let connectionCount = producer?.connect(brokers: ["localhost:9092", "localhost:9093"])
    guard connectionCount == 2 else {
       print("Failed to connect to brokers")
    }
    

    Declaration

    Swift

    public func connect(brokers: [String]) -> Int

    Return Value

    The number of brokers that were successfully connected.

  • Connect as a client to the servers (Kafka broker) at the provided addresses.

    Usage Example:

    let producer = try? KafkaProducer()
    let connectionCount = producer?.connect(brokers: ["localhost": 9092, "localhost": 9093])
    guard connectionCount == 2 else {
       print("Failed to connect to brokers")
    }
    

    Declaration

    Swift

    public func connect(brokers: [String: Int]) -> Int

    Return Value

    The number of brokers that were successfully connected.