Project

kril

0.0
No commit activity in last 3 years
No release in over 3 years
Makes producing and consuming topics simple. Useful when experimenting.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.16
~> 0.13.7
~> 10.0
~> 3.7
~> 0.3.0

Runtime

~> 0.8.0
>= 1.2.1, ~> 1.2
~> 0.5.3
 Project Readme

Kril 🦐

Kril is an easy to use command line interface (CLI) for interacting with Apache Kafka. It uses Apache Avro for serialization/deserialization.

Build Status Gem

Installation

Add this line to your application's Gemspec:

spec.add_dependency 'kril', '~> 0.1'

And then execute:

$ bundle

Or install it yourself as:

$ gem install kril

Usage

Assuming your schema is not registered with the schema registry, and doesn't exist in the repository, you can define a schema and commit a record like so:

$ kril --bootstrap-servers 'localhost:9092,localhost:9093,localhost:9094' \
--schema-registry 'http://localhost:8081' \
--schema '{"type":"record","name":"human","fields":[{"name":"age","type":"int"}]}' \
--record '{"age": 27}' \
human
🦐 human: {"age"=>27}

Now we can consume a single record:

$ kril --pretty-print human
🦐 human: 
{
  "key": null,
  "value": {
    "age": 27
  },
  "offset": 0,
  "create_time": "2018-03-04 00:29:47 -0700",
  "topic": "human",
  "partition": 4
}

Since the schema exists in our repository, we can produce records simply:

$ kril -r '{"age": 33}' human
🦐 human: {"age"=>33}

Consuming all records ever:

$ kril --consume-all human
🦐 human: {:key=>nil, :value=>{"age"=>27}, :offset=>0, :create_time=>2018-03-04 00:12:32 -0700, :topic=>"human", :partition=>2}
🦐 human: {:key=>nil, :value=>{"age"=>27}, :offset=>0, :create_time=>2018-03-04 00:29:47 -0700, :topic=>"human", :partition=>4}
🦐 human: {:key=>nil, :value=>{"age"=>27}, :offset=>0, :create_time=>2018-03-04 00:26:33 -0700, :topic=>"human", :partition=>1}
🦐 human: {:key=>nil, :value=>{"age"=>27}, :offset=>0, :create_time=>2018-03-04 00:25:54 -0700, :topic=>"human", :partition=>3}
🦐 human: {:key=>nil, :value=>{"age"=>33}, :offset=>1, :create_time=>2018-03-04 00:34:07 -0700, :topic=>"human", :partition=>3}
🦐 human: {:key=>nil, :value=>{"age"=>27}, :offset=>0, :create_time=>2018-03-04 00:13:13 -0700, :topic=>"human", :partition=>0}

The --schema option is flexible:

$ kril --schema /path/to/schema.avsc
$ kril --schema name_of_existing_schema
$ kril --schema '{"type":"record","name":"human","fields":[{"name":"age","type":"int"}]}'

If no topic is given, the topic will be inferred from the schema name:

$ kril -s human -r '{"age":99}'
🦐 human: {"age"=>99}

To see what schemas are saved in the repository:

$ kril --list-schemas
another_schema
human

Contributing

  1. Fork it ( https://github.com/ChadBowman/kril/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Obey 👮Rubocop! 🚨

License

The gem is available as open source under the terms of the MIT License.