Git Product home page Git Product logo

minikafka's Introduction

MiniKafka in Go: Project Overview

This Go code implements a client-server message-queue system like Kafka but simpler.

  • The server stores Messages in topics.
  • Messages are just byte sequences; of arbitrary-length.
  • Clients can post messages to a topic using the Produce client library.
  • Other Clients can subscribe to messages as they arrive using the Consumer client library.
  • Messages are not removed from the server when they are consumed.
  • Thus, individual consuming clients can consume the stream at their own rate.
  • But Messages are removed from the server when they reach a configurable age; specified in anything from milliseconds to days.

Messages can either be stored to a file-system, or (volatile) memory.

Read the rationale for using the file-system for storage.

The underlying client/server communciations uses gRPC (unlike Kafka's custom tcp protocol). But the client libraries hide that away, and expose a few simple API methods you can call on proxy objects.

Status

  • It works
  • It has decent unit test coverage
  • The design, code and documentation is respectable, but has not been peer reviewed yet.
  • It is still a work in progress
  • It hasn't been benchmarked, tuned or stress-tested yet.

Getting and Running the Server

go get google.golang.org/grpc
go get github.com/peterhoward42/minikafka

cd $GOPATH/src/github.com/peterhoward42/minikafka
go install ./...

export MINIKAFKA_HOST=":9999"
export MINIKAFKA_RETENTIONTIME="10s"
export MINIKAFKA_ROOT_DIR="/tmp/minikafka"

mkfk-server

If you want to use the in-memory store instead of a file-system store:

export MINIKAFKA_ROOT_DIR=""

Running a Producer Client

You can try out a simple command line wrapper to the client library:

mkfk-producer -host localhost:9999 -topic topic_foo

This sends each line of text you enter to the server as a Produce message. See below for the more realistic option of embedding the producer (and consumer) client in your own code.

Running a Consumer Client

mkfk-consumer -host localhost:9999 -topic topic_foo

This polls the server every 3 seconds and tells you what it got back. Remember though, that the messages only live on the server with these settings for 10 seconds.

Using the Client Libraries in Your Own Code

The more realistic use-case is to incorporate a producer or consumer client library in your own app - as illustrated by the command line consumer wrapper code., or the producer wrapper code.

Launching the Server From Your Own Code

You can similarly wrap the server library in your own code, perhaps to obtain the configuration from something other than environment variables. See the server wrapper code.

Making Clients in Other Languages

The beauty of gRPC is that you can auto-generate client code in most languages using the protobuf file here, and the gRPC tools.

minikafka's People

Contributors

pete-dnae avatar peterhoward42 avatar

Stargazers

Sandalots avatar Nikhil George avatar Paul Kuruvilla avatar Mustafa Can AYDIN avatar  avatar John Owen Nixon avatar R. S. Doiel avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.