Skip to content

Apache Kafka ​

Overview ​

Export evaluation data inside a Kafka topic.

NOTE

Apache Kafka is an exporter of type queue, it means that it send events as soon as he receives them it does not work in bulk but in near real time.

Configure the relay proxy ​

To configure your relay proxy to use the Apache Kafka exporter, you need to add the following configuration to your relay proxy configuration file:

yaml
# ...
exporters:
  - kind: kafka
    kafka:
      topic: "semaphore-events"
      addresses:
        - "localhost:9092"
# ...
Field nameMandatoryTypeDefaultDescription
kindYesstringnoneValue should be kafka.
This field is mandatory and describes which retriever you are using.
kafka.topicYesstringnoneKafka topic to bind to.
kafka.addressesYes[]stringnoneList of bootstrap addresses for the Kafka cluster.
kafka.configNoobjectsee descriptionThis field allows fine tuning of the Kafka reader. This object should contain the Sarama configuration that the reader will use. On empty, a sensible default is created using sarama.NewConfig()

How kafka.config is merged with the defaults ​

The configuration starts from the defaults of sarama.NewConfig() and the values you set in kafka.config replace them: a setting you provide always wins over the default (for example Net.DialTimeout, Producer.Retry.Max, ClientID or Version of the Sarama configuration). A setting you leave out keeps the default of Sarama. A zero value (0, "" or false) cannot be told from a setting that is not set, so it keeps the default too. Producer.Return.Successes and Producer.Return.Errors are always true, the exporter needs them.

Configure the GO Module ​

To configure your GO module to use the Apache Kafka exporter, you need to add the following configuration to your ffclient.Config{} object:

go
config := ffclient.Config{
   // ...
   DataExporter: ffclient.DataExporter{
        // ...
        Exporter: &kafkaexporter.Exporter{
           Settings: kafkaexporter.Settings{
              Topic: "semaphore-events",
              Addresses: []string{"localhost:9092", "cluster2:9092"},
           },
        },
    },
    // ...
}
client, err := ffclient.New(config)
defer client.Close()
FieldMandatoryDescription
Format NoThe format to produce in the topic (only JSON is supported for now).
Settings YesA extension of the *sarama.Config struct that holds additional settings for the producer, such as timeouts, TLS settings, etc. If not populated, a default will be used by calling sarama.NewConfig()

In the settings we have the following fields:

FieldMandatoryDescription
Topic YesName of the topic to publish messages
Addresses YesThe list of addresses for the Kafka boostrap servers

Released under the MIT License.