Skip to content

Commit 9c51a93

Browse files
author
Rafal Zukowski
committed
README on how to write a plugin
1 parent a6fb51f commit 9c51a93

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,40 @@ The arguments are:
4949
- **refresh** how often should the app refresh and store a point in the DB
5050
- **retain** how long should points be kept in the DB
5151
- **dbName** where to store the history (default 'offsetapp')
52+
- **pluginsArgs** additional arguments used by extensions (see below)
5253

54+
Writing and using plugins
55+
============================
56+
57+
Kafka Offset Monitor allows you to plug-in additional offset info reporters in case you want this information to be logged or stored somewhere. In order to write your own plugin,
58+
all you need to do is to implement OffsetInfoReporter trait:
59+
60+
```
61+
trait OffsetInfoReporter {
62+
def report(info: IndexedSeq[OffsetInfo])
63+
def cleanupOldData() = {}
64+
}
65+
```
66+
67+
It is also required, that implementation has a constructor with String as the only parameter, and this parameter will be set to pluginsArgs argument value.
68+
Its up to you how you want to utilize this argument and configure your plugin.
69+
70+
When building a plugin you may find it difficult to set up dependency to Kafka Offset Monitor classes, as currently artifacts are not published to public repos.
71+
As long as this is true you will need to use local maven repo and just publish Kafka Offset Monitor artifact with: ```sbt publishM2```
72+
73+
Assuming you have a custom implementation of OffsetInfoReporter in a jar file, running it is as simple as adding the jar to the classpath when running app:
74+
75+
```
76+
java -cp KafkaOffsetMonitor-assembly-0.3.0.jar:kafka-offset-monitor-another-db-reporter.jar \
77+
com.quantifind.kafka.offsetapp.OffsetGetterWeb \
78+
--zk zk-server1,zk-server2 \
79+
--port 8080 \
80+
--refresh 10.seconds \
81+
--retain 2.days
82+
--pluginsArgs anotherDbHost=host1,anotherDbPort=555
83+
```
84+
85+
For complete working example you can check [kafka-offset-monitor-graphite](https://github.com/allegro/kafka-offset-monitor-graphite), a plugin reporting offset information to Graphite.
5386

5487
Contributing
5588
============

src/main/scala/com/quantifind/kafka/offsetapp/OffsetGetterWeb.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.quantifind.kafka.offsetapp
22

33
import java.lang.reflect.Constructor
4-
import java.util
54
import java.util.{Timer, TimerTask}
65

76
import com.quantifind.kafka.offsetapp.sqlite.SQLiteOffsetInfoReporter
@@ -183,7 +182,7 @@ object OffsetGetterWeb extends UnfilteredWebApp[OWArgs] with Logging {
183182

184183
val reflections = new Reflections()
185184

186-
val reportersTypes: util.Set[Class[_ <: OffsetInfoReporter]] = reflections.getSubTypesOf(classOf[OffsetInfoReporter])
185+
val reportersTypes: java.util.Set[Class[_ <: OffsetInfoReporter]] = reflections.getSubTypesOf(classOf[OffsetInfoReporter])
187186

188187
val reportersSet: mutable.Set[Class[_ <: OffsetInfoReporter]] = scala.collection.JavaConversions.asScalaSet(reportersTypes)
189188

0 commit comments

Comments
 (0)