Liiklus [li:klus] ("traffic" in Estonian) - RSocket/gRPC-based Gateway for the event-based systems from the ones who think that Kafka is too low-level.
The easiest (and recommended) way to run Liiklus is with Docker:
$ docker run \
-e kafka_bootstrapServers=some.kafka.host:9092 \
-e storage_positions_type=MEMORY \ # only for testing, DO NOT use in production
-p 6565:6565 \
bsideup/liiklus:$LATEST_VERSION
Now use LiiklusService.proto to generate your client.
The clients must implement the following algorithm:
stub.subscribe(SubscribeRequest(
topic="your-topic",
group="your-consumer-group",
[autoOffsetReset="earliest|latest"]
))
Subscribe, using the same channel, subscribe to the records:
stub.receive(ReceiveRequest(
assignment=reply.getAssignment()
))
stub.ack(AckRequest(
assignment=reply.getAssignment(),
offset=record.getOffset()
))
Example code using Project Reactor and reactive-grpc:
var stub = ReactorLiiklusServiceGrpc.newReactorStub(channel);
stub
.subscribe(
SubscribeRequest.newBuilder()
.setTopic("user-events")
.setGroup("analytics")
.setAutoOffsetReset(AutoOffsetReset.EARLIEST)
.build()
)
.flatMap(reply -> stub
.receive(ReceiveRequest.newBuilder().setAssignment(reply.getAssignment()).build())
.window(1000) // ACK every 1000th records
.concatMap(
batch -> batch
.map(ReceiveReply::getRecord)
// TODO process instead of Mono.delay(), i.e. by indexing to ElasticSearch
.concatMap(record -> Mono.delay(Duration.ofMillis(100)))
.sample(Duration.ofSeconds(5)) // ACK every 5 seconds
.onBackpressureLatest()
.delayUntil(record -> stub.ack(
AckRequest.newBuilder()
.setAssignment(reply.getAssignment())
.setOffset(record.getOffset())
.build()
)),
1
)
)
.blockLast()
Also check examples/java/ for a complete example
The project is based on Spring Boot and uses it's configuration system
Please check application.yml for the available configuration keys.
See LICENSE.
Content type
Image
Digest
Size
192.6 MB
Last updated
about 5 years ago
docker pull bsideup/liiklus