GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - sideshowcoder/dropwizard-openfeature: OpenFeature Bundle for Dropwizard

BranchesTags
Open more actions menu

Latest commit

 

History

206 Commits
206 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
.mvn/wrapper
.mvn/wrapper
 
 
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
compose.yaml
compose.yaml
 
 
flag-provider-requests.restclient
flag-provider-requests.restclient
 
 
mvnw
mvnw
 
 
mvnw.cmd
mvnw.cmd
 
 
pom.xml
pom.xml
 
 

Repository files navigation

Maven Central Maven Test & Build

Dropwizard Openfeature

This plugin integrates openfeature with dropwizard and allows you to use openfeature feature flags, provided by supported openfeature providers via a managed OpenFeatureAPI instance.

It implements support for

  • InMemoryProvider useful for testing
  • flagd
  • GO Feature Flag
  • OpenFeature Remote Evaluation Protocol (OFREP) to support any providers implementing it

Installing the bundle

Releases from maven central

io.github.sideshowcoder/dropwizard-openfeature

<dependency>
  <groupId>io.github.sideshowcoder</groupId>
  <artifactId>dropwizard-openfeature</artifactId>
  <version>2.1.0</version>
</dependency>

Snapshots form source

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>2.1.1-SNAPSHOT</version>
</dependency>

Included in the bundle

Supported providers

Currently the following providers, implemented in the open-feature/java-sdk-contrib are supported, and their respective most used configuration options are mapped to yaml configuration. Addtional configuration can be set by accessing the underlying provider as needed.

  • InMemoryProvider
  • flagd
  • GO Feature Flag
  • OpenFeature Remote Evaluation Protocol (OFREP) to support any providers implementing it

For the configuration see the respective configuration classes.

OpenFeatureAPI management

The initialized OpenFeatureAPI is managed via the dropwizard lifecycle and will be shutdown gracefully upon application shutdown, see OpenFeatureAPIManager.

Healthcheck

By default the bundle registers a healthcheck on the state of the provider configured, this healthcheck can be further configured via the OpenFeatureHealthCheckConfiguration.

Activating the bundle

Your Dropwizard application configuration class must implement OpenFeatureBundleConfiguration

Configuring dropwizard-openfeature in the dropwizard config file

For a full overview see OpenFeatureConfiguration, OpenFeatureHealthCheckConfiguration, and the respective provider specific configuration. 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.

public class Config extends Configuration implements OpenFeatureBundleConfiguration {

    @Valid
    @NotNull
    @JsonProperty
    private OpenFeatureConfiguration openfeature;

    @Override
    public OpenFeatureConfiguration getOpenFeatureConfiguration() {
        return openfeature;
    }
}

Initialization

In your application's initialize method, call bootstrap.addBundle(new OpenFeatureBundle()):

public class App extends Application<Config> {
    
    @Override
    public void initialize(Bootstrap<MyConfiguration> bootstrap) {
        bootstrap.addBundle(new OpenFeatureBundle());
    }

    @Override
    public void run(Config config, Environment environment) throws Exception {
        /* ... */
    }
}

Using the client

OpenFeature configures a global OpenFeatureAPI which grants access to a client, which can be injected as needed, it is common practise to provide a domain as an identifier, this is however not required, unless multiple clients are to be created.

public class App extends Application<Config> {

    @Override
    public void initialize(Bootstrap<MyConfiguration> bootstrap) {
        bootstrap.addBundle(new OpenFeatureBundle());
    }

    @Override
    public void run(Config config, Environment environment) throws Exception {
        /* ... */
        var client = OpenFeatureAPI.getInstance().getClient("my-application-domain");
        
        var myResource = new MyResource(client);
        environment.jersey().register(myResource);
        
        var myOtherResource = new MyOtherResource(client);
        environment.jersey().register(myResource);
        /* ... */
    }
}

Accessing the underlying feature provider

The bundle exposes access to the underlying feature provider. Useful for runtime configuration and introspection of the provider. For example when using the InMemoryProvider flags can be updated at runtime for example for testing.

public class App extends Application<Config> {

    private OpenFeatureBundle bundle;
    private InMemoryProvider provider;

    @Override
    public void initialize(Bootstrap<MyConfiguration> bootstrap) {
        bundle = new OpenFeatureBundle();
        bootstrap.addBundle(bundle);
    }

    @Override
    public void run(Config config, Environment environment) throws Exception {
        // ...
        provider = (InMemoryProvider) bundle.getFeatureProvider();
        provider.updateFlags(Map.of(/* ... */));
        // ...
    }
}

Contributors

  • Philipp Fehre

About

OpenFeature Bundle for Dropwizard

Resources

Readme
Apache-2.0 license
Activity

Stars

2 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.