/karafka-rails-app

Karafka WaterDrop and Sidekiq backend Rails 7 Application

Primary LanguageRuby

Karafka 2.0 Ruby on Rails based example application

This is an example application which uses:

It allows you to see how Karafka integrates with Ruby on Rails. Each time you visit localhost:3000 an event will be dispatched to Kafka. This event will be then consumed and stored using Karafka consumer.

This app also includes ActiveJob job that creates a visitor instance via ActiveJob by using Karafka backend.

Note, that the consumer elevates the #insert_all from ActiveRecord to insert data efficiently.

Usage

  1. Install all the dependencies by running bundle install
  2. Install frontend dependencies by running yarn install
  3. Create your SQLite database by running: bundle exec rake db:create
  4. Setup your SQLite database structure by running: bundle exec rails db:migrate
  5. Setup your test database by running: bundle exec rake db:test:prepare
  6. Run bundle exec rails server to start the Rails web server
  7. Run bundle exec karafka server to start Karafka consumption server
  8. Visit localhost:3000 and refresh the page couple of times

You can also run RSpec specs to see how the testing RSpec library integrates with Rails:

bundle exec rspec spec