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.