diff --git a/README.md b/README.md index 73a5bc71..9ba8af4e 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,13 @@ for example: Assuming the messages that get printed are JSON, this print the sum of all age fields from each message in the partition. +### Custom Decoder +If your kafka messages are encoded in some way you can provide a custom decoder +in the form of a plugin. See plugins/protobuf for an example. Once you have +compiled the plugin you use it as the default decoder by starting kcli like so: + + kcli -d /path/to/your/decoder.so + ### Screen Colors If you don't like the defaul colors you can set KCLI_COLOR[0,1,2,3] to one of: diff --git a/plugins/protobuf/protobuf.go b/plugins/protobuf/protobuf.go index de6cd1af..c4640ca7 100644 --- a/plugins/protobuf/protobuf.go +++ b/plugins/protobuf/protobuf.go @@ -5,7 +5,12 @@ import ( "github.com/golang/protobuf/proto" ) -// Example of how to create a protobuf plugin for your data structure +// Protobuf is an example of how to create a plugin +// to decode protobuf encoded kafka messages. +// To compile: +// go build -buildmode=plugin -o protobuf.so protobuf.go +// Then start kcli like: +// kcli -d ./protobuf.so type Protobuf struct{} func (p Protobuf) Decode(b []byte) ([]byte, error) {