GithubHelp home page GithubHelp logo

az-feature-manager's Introduction

Feature Toggles Management library

Table of Contents

Overview

Feature Toggles Management facade library intended to unify interaction model with possibly different implementation providers.

Current library module is designed to provide basic capabilities and a common conventions set for feature management to being able to express/prescribe feature toggle object to lookup and validate (current version is mainly biased to the AppConfiguration Feature Manager variation).

Every Feature Toggle description object should be equipped with required lookup metadata reflecting and revealing the following information:

  • featureLookupKey - feature manager key/alias in terms of underlying cache specific implementation to locate snapshot/cached instance in order for ensure that feature flags should be consistent across the entire request as configuration values can change in real-time;

  • name - name of evaluated Feature Toggle object/instance real data owner - do not confuse with above property - ownerId is key property and used as a partition key for the audit store Cosmos container;

  • userId - reflects user specific identifier attribute value;

  • groups - used to evaluate specified feature flag on user to belong to a certain group condition;

  • defaultValue - default evaluation value for specified feature flag.

In order to add Feature Toggles Management facade library to the project follow below steps:

  • add library dependency to the required project;

  • Turn on feature lookup functionality by placing below configuration properties set under bootstrap configuration file for specific project:

az-feature-management:
  configuration:
    enabled: true
    snapshot-enabled: true
    type: APP_CONFIGURATION

Servlet web-based application usage example:

private final FeatureLookup featureLookup;

@PostMapping("/resolve")
@PreAuthorize("@verifyAccess(authentication)")
public ExampleDTO resolveIdentity(@RequestBody @Validated ExampleRequest request) {
    FeatureLookup.FeatureOptionsBuilderProvider options = builder -> builder
            .featureLookupKey(FeatureManagementEnvironmentType.WEB_SERVLET_BLOCKING.getFeatureLookupKey(Stream::empty))
            .name("TestFeatureEnabled")
            .userId(request.getId())
            .defaultValue(true)
            .groups(Set.of());

    if (featureLookup.lookup(options)) {
        return exampleService.resolveExample(request);
    } else {
        throw new IllegalArgumentException();
    }
}

Reactive web-based application usage example:

private final FeatureLookup featureLookup;

public Mono<Example> fetchExample(String id, DataFetchingEnvironment env) {
    return authenticationRepository.getAuthentication(GraphQLUtils.getExchange(env))
            .transformDeferredContextual((auth, ctx) ->
                auth.flatMap(principal -> {
                    String exampleId = Optional.ofNullable(id).orElseGet(principal::getId);

                    FeatureLookup.FeatureOptionsBuilderProvider options = builder -> builder
                            .featureLookupKey(FeatureManagementEnvironmentType.WEB_REACTIVE
                                    .getFeatureLookupKey(ctx::stream))
                            .name("TestFeatureEnabled")
                            .userId(userId)
                            .defaultValue(true)
                            .groups(Set.of());

                    return featureLookup.lookupAsync(options)
                            .flatMap(isTestFeatureEnabled -> {
                                if (isTestFeatureEnabled) {
                                    return exampleCrudApi.findExampleByIdUsingGET(principal.getRunAsHeader(), exampleId);
                                } else {
                                    throw new IllegalArgumentException();
                                }
                            });
                }));
}

In order to override remote value of feature and use you own local value:

  • update service bootstrap-local.yaml/bootstrap.yaml
    az-feature-management:
        configuration:
            enabled: true
            type: LOCAL_CONFIGURATION
            features: ./path_to_features.json
  • add under app resources folder you own features like './sample_features.json'

az-feature-manager's People

Contributors

aliaksie avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.