This plugin integrates openfeature with dropwizard and allows you to use openfeature feature
flags, provided by supported openfeature providers via a managed OpenFeatureAPI
instance.
Currently only flagd and the SDKs InMemoryProvider providers are supported
git clone https://github.com/sideshowcoder/dropwizard-openfeature
cd dropwizard-openfeature
./mvn install
After installing the plugin locally you can include it in your pom.xml
<dependency>
<groupId>io.github.sideshowcoder</groupId>
<artifactId>dropwizard-openfeature</artifactId>
<version>$VERSION</version>
</dependency>
The bundle currently supports both the SDK included InMemoryProvider
as well as flagd
, the provider can be selected
via the configuration. For details on the configuration options see FlagdConfiguration
as well the
flagd documentation.
The initialized OpenFeatureAPI
is managed via the dropwizard lifecycle.
By default the bundle registers a healthcheck on the state of the provider configured, this healthcheck can be further
configured via the OpenFeatureHealthCheckConfiguration
.
Your Dropwizard application configuration class must implement OpenFeatureBundleConfiguration
:
For a full overview see OpenFeatureConfiguration
, OpenFeatureHealthCheckConfiguration
, and FlagdConfiguration
a
minimal configuration for flagd runnining locally on the port 8013 would look as follows.
openfeature:
provider: flagd
flagd:
host: localhost
port: 8013
For the bundle to have access to the configuration, your application configuration needs to implement
OpenFeatureBundleConfiguration
.
import io.github.sideshowcoder.dropwizard_openfeature.OpenFeatureConfiguration;
public class ApplicationConfiguration implements OpenFeatureBundleConfiguration {
@Valid
@NotNull
@JsonProperty
private OpenFeatureConfiguration openfeature;
@Override
public OpenFeatureConfiguration getOpenFeatureConfiguration() {
return openfeature;
}
}
In your application's initialize
method, call bootstrap.addBundle(new OpenFeatureBundle())
:
import io.github.sideshowcoder.dropwizard_openfeature.OpenFeatureBundle;
@Override
public void initialize(Bootstrap<MyConfiguration> bootstrap) {
bootstrap.addBundle(new OpenFeatureBundle());
}