commit | 6ad7192d1ee2ef17cf1d27370605d8a2f48e61d3 | [log] [tgz] |
---|---|---|
author | Marcin Czech <maczech@gmail.com> | Wed Aug 04 15:30:24 2021 +0200 |
committer | Marcin Czech <maczech@gmail.com> | Mon Aug 09 10:34:31 2021 +0000 |
tree | 0237315bd65248cf875b2488b841afdaff66001e | |
parent | 689ea2854612ebcf0599084276d1d28e40253127 [diff] |
Set version to 3.5.0-alpha-202108041529 Change-Id: If9f900e44fdd0dea55f5eba5dba7144e69d72275
API of a generic events broker for use with Gerrit Code Review.
Enables the de-coupling between Gerrit, plugins and the different implementations of a generic events broker.
It is a quite common use case for consumers of this library to listen for Gerrit events and to stream them on a specific topic.
Since the implementation of such logic is always the same, this library provides a generic stream events publisher which will perform the relevant operations.
In order to listen and stream gerrit events, consumers of this API just need to provide a named annotation with the name of the stream events topic and then explicitly bind the Stream Events Publisher, as such:
import com.gerritforge.gerrit.eventbroker.StreamEventPublisher; import com.google.gerrit.extensions.registration.DynamicSet; import com.google.gerrit.server.events.EventListener; import com.google.inject.AbstractModule; import com.google.inject.TypeLiteral; import com.google.inject.name.Names; public class SomeModule extends AbstractModule { @Override protected void configure() { bind(new TypeLiteral<String>() { }) .annotatedWith(Names.named(StreamEventPublisher.STREAM_EVENTS_TOPIC)) .toInstance("name_of_the_stream_events_topic"); DynamicSet.bind(binder(), EventListener.class).to(StreamEventPublisher.class); } }
Note: To avoid message duplication Stream Events Publisher uses gerrit.instanceId and Event.instanceId to filter out forwarded events.