explaingit

ibm/sarama

12,481GoAudience · developerComplexity · 3/5LicenseSetup · moderate

TLDR

Sarama is a Go library maintained by IBM that lets Go applications send messages to, read from, and administer Apache Kafka, the high-speed messaging system used to stream data between services at scale.

Mindmap

mindmap
  root((Sarama))
    What it does
      Kafka client for Go
      Producer and consumer
      Cluster admin
    Use Cases
      Send messages
      Read event streams
      Write tests
    Tech Stack
      Go
      Apache Kafka
    Features
      Mocks for testing
      CLI diagnostic tools
      Versioned compatibility
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Send messages from a Go service to a Kafka topic so other services can consume them asynchronously.

USE CASE 2

Build a Go consumer group that reads events from Kafka and processes them in real time.

USE CASE 3

Write automated tests for Kafka-connected Go code using Sarama's built-in mock package without a real Kafka cluster.

USE CASE 4

Administer a Kafka cluster, create topics, check offsets, manage partitions, directly from a Go application.

Tech stack

GoApache Kafka

Getting it running

Difficulty · moderate Time to first run · 30min

Requires a running Apache Kafka cluster to connect to, supports the two most recent Kafka stable releases.

Use freely for any purpose including commercial use under the MIT license, as long as you keep the copyright notice.

In plain English

Apache Kafka is a messaging system designed to move large streams of data between applications reliably and at high speed. Rather than having systems communicate directly with each other, producers write messages to Kafka and consumers read from it on their own schedule. This decoupling allows many services to process data independently and makes it easier to scale each part of a system without affecting the others. Sarama is a Go programming language library that lets Go applications connect to Apache Kafka. Using Sarama, a Go program can send messages to Kafka (acting as a producer), read messages from it (acting as a consumer), or administer a Kafka cluster, without having to implement the underlying Kafka wire protocol from scratch. The library is maintained by IBM under an MIT open-source license. It follows a compatibility policy that supports the two most recent stable releases of both Kafka and Go at any time, with a two-month grace period for older versions. Older Kafka releases outside that window may still work even if they are not officially supported. The README is brief and directs readers to external resources for detail. Full API documentation and examples are hosted at pkg.go.dev. A FAQ covers common issues on the project wiki. The library includes a mocks subpackage for writing automated tests and a tools directory with command-line utilities for diagnosing Kafka connections. Version numbering follows standard Go module conventions, so breaking changes are signaled through major version bumps and the changelog tracks each release.

Copy-paste prompts

Prompt 1
Show me the minimal Go code using Sarama to produce a message to a Kafka topic called 'orders' on a local broker.
Prompt 2
Write a Sarama consumer group in Go that reads from the 'events' topic and prints each message to stdout, handling graceful shutdown.
Prompt 3
I want to unit-test my Kafka producer without a real broker using Sarama mocks. Show me how to set up the mock producer and assert messages were sent.
Prompt 4
How do I configure Sarama to connect to a Kafka cluster that requires SASL/TLS authentication? Give me the complete Config struct setup.
Open on GitHub → Explain another repo

← ibm on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.