Coder Social home page Coder Social logo

sample-karafka-sinatra's Introduction

Sampa Karafka and Sinatra app

Karafka & Sinatra

Karafka is a framework used to simplify Apache Kafka based Ruby applications development.

Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort.

Goal

This repository was created for a sample application that uses a web api and also listens and writes to Apache Kafka topics.

Organization

Configuration

Defined on karafka.rb, this app assumes you have Kafka running on 127.0.0.1:9092. In this file, it's also defined a consumer group for the app named default_group with two topics (with consumers and responders) example and response.

Api configuration and a sample endpoint is defined on api.rb.

API

A simple GET endpoint /frank-says that is responsible for publising a message using a Responder.

Responders

Are the ones responsible for writing messages to a given Kafka topic. They are:

  • Responders::Foobar, used on the sinatra sample endpoint to send a message to the example topic.
  • Responders::Example, used by the Consumers::Example (defined on karafka config file), responding the consumer's message to the response topic.

Consumers

Are the ones responsable for listening to Kafka topics. They are:

  • Consumers::Example, that listens to the topic example (defined on karafka config file), logs the consumed message and responds to the response topic using Responders::Example (also defined on karafka config file).
  • Consumers::Response, that listens to the topic response (defined on karafka config file) and logs the consumed message.

Running the app

  • Run karafka server on your terminal to start the Karafka server.
  • Run bundle exec ruby api.rb on another tab of your terminal to start Sinatra.

sample-karafka-sinatra's People

Contributors

camilacampos avatar mensfeld avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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.