@PLUGIN@ extension points

The replication plugin exposes an extension point to allow influencing its behaviour from another plugin or a script. Extension points can be defined from the replication plugin only when it is loaded as libModule and implemented by another plugin by declaring a provided dependency from the replication plugin.

Install extension libModule

The replication plugin's extension points are defined in the c.g.g.p.r.ReplicationExtensionPointModule that needs to be configured as libModule.

Create a symbolic link from $GERRIT_SITE/plugins/replication.jar into $GERRIT_SITE/lib and then add the replication extension module to the gerrit.config.

Example:

[gerrit]
  installModule = com.googlesource.gerrit.plugins.replication.ReplicationExtensionPointModule

NOTE: Use and configuration of the replication plugin as library module requires a Gerrit server restart and does not support hot plugin install or upgrade.

Extension points

  • com.googlesource.gerrit.plugins.replication.AdminApiFactory

    Create an instance of AdminApi for a given remote URL. The default implementation provides API instances for local FS, remote SSH, and remote Gerrit.

    Only one factory at a time is supported. The implementation needs to be bound as a DynamicItem.

    Example:

    DynamicItem.bind(binder(), AdminApiFactory.class).to(AdminApiFactoryImpl.class);
    

@PLUGIN@ Cross Plugin Communication

The @PLUGIN@ plugin exposes ApiModule that allows to provide Cross Plugin Communication. Extension points can be defined from the replication plugin when it is loaded as ApiModule and implemented by another plugin by declaring a provided dependency from the replication plugin api.

Build the @plugin@'s API jar

The replication plugin's extension points are defined in the c.g.g.p.r.a.ApiModule that needs to be built from source and loaded in Gerrit as ApiModule.

$ bazelisk build plugins/replication:replication-api
$ cp bazel-bin/plugins/replication/replication-api.jar $GERRIT_SITE/plugins

NOTE: Use and configuration of the replication-api as ApiModule is compatible with Gerrit v3.9 onwards and requires a Gerrit server restart; it does not support hot plugin install or upgrade.

Setup

Check the official documentation on how to setup your project.

Working with Extension Points

In order to use both, the Cross Plugin Communication and replication Extension Points, follow the Install extension libModule steps and make sure that replication.jar is only present in lib/ directory.

Exposed API

  • com.googlesource.gerrit.plugins.replication.api.ReplicationConfigOverrides

    Override current replication configuration from external source (eg. git repository, ZooKeeper).

    Replication plugin will still use configuration from $gerrit_site/etc/, but with overrides it can be modified dynamically from external source, similarly to how git config uses user and repository configuration files.

    Only one override at a time is supported. The implementation needs to bind a DynamicItem.

    DynamicItem.bind(binder(), ReplicationConfigOverrides.class).to(ReplicationConfigOverridesImpl.class);
    
  • com.googlesource.gerrit.plugins.replication.api.ReplicationPushFilter

    Filter out the ref updates pushed to a remote instance. Only one filter at a time is supported. Filter implementation needs to bind a DynamicItem.

    Default: no filtering

    Example:

    DynamicItem.bind(binder(), ReplicationPushFilter.class).to(ReplicationPushFilterImpl.class);