Skip to content

lhmzhou/hairy-lemon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hairy-lemon

hairy-lemon is an implementation of a Kafka producer application.

Goals

  1. Exposes API to some values to the user by taking unique id as an input value
  2. DB mockup for storing and returning values to the user when queried with a unique id
  3. Implements a Kafka producer to publish a successful query

To run the full capability, you'll need both the producer hairy-lemon and the consumer copper-face-jacks. hairy-lemon is only 50% of the capability.

System Architecture

Below is the bird's eye view of the e2e initiative. The red enclosure represents hairy-lemon.

alt diagram

Prerequisites

Build

  1. Clone hairy-lemon.

  2. Navigate to the hairy-lemon folder and run the program in your terminal by executing:

    go run hairy-lemon

  3. To initialize a kafka instance:

    a). Copy the yaml file to desktop. Open yaml file, and delete everything apart from zookeeper and broker configs. Save the file. Next, execute below commands in cli:

     $ docker-compose up
     $ docker ps
    

    b). Run below command to enter the container:

     $ docker exec -it testdocker /bin/bash
    

    c). To get into the kafka consumer and initialize it, run the following:

     $ cd /opt/kafka_2.11-0.10.1.0/bin/
     $ ./kafka-console-consumer.sh --bootstrap-server
     $ localhost:9092 --topic newtopic --from-beginning
    

    Note: Running Step 3c will display the messages in kafka and test.

  4. hairy-lemon is launched and the kafka consumer is initialized. Proceed to open browser and hit the url at http://localhost:8081/score/1

You will see a json response on the webpage. The same response can be seen in the kafka container. Effectively, UniqueId = 1 is queried on the DB via API. The corresponding values are given in the response. These values are then published to the kafka topic, and you can view them on the kafka consumer terminal accordingly.

h/t

Maximum respect and many thanks to the developers on these open-source projects for making hairy-lemon possible:

rcrowley/go-metrics
jcmturner/gofork
klauspost/compress
go-redis/redis
golang/snappy
hashicorp/go-uuid
pierrec/lz4
eapache @ Shopify
davecgh/go-spew

About

kafka producer implementation

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages