Initial implementation of events-nats plugin

- use NATS JetStream [1] to enable persistent streams to avoid loosing
messages if e.g. a Gerrit instance is restarted
- support synchronous and asynchronous publishing
- use durable push subscription [2] per Gerrit instanceId, in a cluster
setup we want messages to be delivered to each Gerrit instance

[1] https://docs.nats.io/nats-concepts/jetstream
[2] https://docs.nats.io/nats-concepts/jetstream/consumers
18 files changed
tree: 7f6ea378bb9525bfcc0798e36e32c29f3664c3a5
  1. src/
  2. .gitignore
  3. BUILD
  4. external_plugin_deps.bzl
  5. Jenkinsfile
  6. LICENSE
  7. README.md
README.md

events-nats: Gerrit event producer for NATS

Build Status

Synopsis

This plugins allows to define a distributed stream of events published by Gerrit.

Events can be anything, from the traditional stream events to the Gerrit metrics.

This plugin requires Gerrit 3.6 or later.

Environments

  • linux
  • java-11
  • Bazel

Build

events-nats plugin can be build as a regular ‘in-tree’ plugin. That means that is required to clone a Gerrit source tree first and then to have the events-nats plugin source directory into the /plugins path. Additionally, the plugins/external_plugin_deps.bzl file needs to be updated to match the events-nats plugin one.

git clone --recursive https://gerrit.googlesource.com/gerrit
git clone https://gerrit.googlesource.com/plugins/events-nats gerrit/plugins/events-nats
cd gerrit
rm plugins/external_plugin_deps.bzl
ln -s ./events-nats/external_plugin_deps.bzl plugins/.

To build the events-nats plugins, issue the command from the Gerrit source path:

bazel build plugins/events-nats

The output is created in

bazel-genfiles/plugins/events-nats/events-nats.jar

Minimum Configuration

Assuming a running NATS JetStream broker on the same Gerrit host, add the following settings to gerrit.config:

    [plugin "events-nats"]
        server = nats://localhost:4222

Testing

Starting a local NATS JetStream server for testing:

    docker run -d --name nats-main -p 4222:4222 -p 6222:6222 -p 8222:8222 nats -js

You can use the NATS command line client to inspect and manage NATS.