Skip to content

fabiojose/klay

Repository files navigation

Kattlo

🕹️ Klay

Play with Apache Kafka®. Good for proof-of-concept, labs, fast development and study.

🔋 Batteries included 🔋

  • run Kafka Streams with steps written in Groovy or Java
    • 😃 with live (hot) reloading
  • Rest API to interact with state stores and streams
  • start an Apache Kafka® embedded

Features

  • Start Apache Kafka® Server
    • Broker 3.1.0 + Zookeeper
    • Raft (aka Kraft)
    • Redpanda
    • Choose version
  • Start Cluster
  • Start Kafka Streams written in Groovy
  • Start Kafka Streams written in Java
  • Hot reloading of Kafka Streams
  • Rest API for Kafka Streams State Stores
  • Wrappers
    • kafka-topics
    • kafka-console-consumer
    • kafka-console-producer
    • kafka-consumer-perf-test
    • kafka-producer-perf-test
  • Operational commands
    • klay ps: list running processes
    • klay logs: get logs
    • klay stop: stop running process
    • klay describe: show details about process
    • klay prune: remove unused data

Installation

To install or update Klay you need JDK 17.

bash -c "$(curl -fsSL https://raw.githubusercontent.com/fabiojose/klay/main/install.sh)"

If you get the following message, everying is ok:

🕹️ Klay version <version> installed and configured with success.
   ✅ Installation
   ✅ Configuration

Open another terminal and type:

klay --help

Manual Installation

To perform the installation manually, follow these steps.

TODO:

Kafka Streams

Run Kafka Streams applications with the easiness and flexibility of scripting.

Default imports:

  • org.apache.kafka.streams.*
  • org.apache.kafka.streams.kstream.*
  • org.apache.kafka.streams.state.*

But you can import any class available in the classpath

Available objects:

  • fromStream: it's null when --from option has no value
  • builder

Default Serdes:

  • key: String
  • value: JsonSerde

Groovy

The script must return an instance of KStream. Example:

// TODO:

Java

// TODO:

Rest API

TODO

Starting the Apache Kafka®

TODO

Running the application in dev mode

You can run your application in dev mode that enables live coding using:

./gradlew quarkusDev

NOTE: Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.

Packaging and running the application

The application can be packaged using:

./gradlew build

It produces the quarkus-run.jar file in the build/quarkus-app/ directory. Be aware that it’s not an über-jar as the dependencies are copied into the build/quarkus-app/lib/ directory.

The application is now runnable using java -jar build/quarkus-app/quarkus-run.jar.

If you want to build an über-jar, execute the following command:

./gradlew build -Dquarkus.package.type=uber-jar

The application, packaged as an über-jar, is now runnable using java -jar build/*-runner.jar.

Thanks