GithubHelp home page GithubHelp logo

openfeature-go-provider's Introduction

Openfeature GO Provider for Harness Feature Flags

This repository contains all the details that'll help you to develop OpenFeature GO client for Harness Feature Flags!

Quick Links

Join us on Slack

How to Get Involved

Make sure you join the Hacktoberfest discussion on our community slack, as well as share your ideas or ask any questions on our discourse. Don't forget to use @harnessio & #hacktoberfest on Twitter!

Contributor License Agreement

By Submitting code to this repo, contributors agree to the Contributor License Agreement, which can be viewed here.

Code of Conduct

All users and contributors of the Harness community should adhere to the following Code of Conduct!

Communication

Refer Harness Community Communications Guide to interact with the wider community users/contributors, join slack workgroups to get help/help other users and create topics in community.harness.io

License

Apache License 2.0 License.

See COPYING for more information.

openfeature-go-provider's People

Contributors

marierere avatar ompragash avatar

Watchers

Dave Nielsen avatar  avatar

openfeature-go-provider's Issues

OF Requirement 1.1.5 & 1.1.6

https://docs.openfeature.dev/docs/specification/sections/flag-evaluation

Requirement 1.1.5
The API MUST provide a function for creating a client which accepts the following options:

name (optional): A logical string identifier for the client.

// example client creation and retrieval
OpenFeature.getClient({
  name: "my-openfeature-client",
});

The name is a logical identifier for the client.

Requirement 1.1.6
The client creation function MUST NOT throw, or otherwise abnormally terminate.

Clients may be created in critical code paths, and even per-request in server-side HTTP contexts. Therefore, in keeping with the principle that OpenFeature should never cause abnormal execution of the first party application, this function should never throw. Abnormal execution in initialization should instead occur during provider registration.

OF Provider 2.6

https://docs.openfeature.dev/docs/specification/sections/providers#requirement-26

Requirement 2.6
The provider SHOULD populate the flag resolution structure's reason field with "DEFAULT", "TARGETING_MATCH", "SPLIT", "DISABLED", "UNKNOWN", "ERROR" or some other string indicating the semantic reason for the returned flag value.

As indicated in the definition of the flag resolution structure, the reason should be a string. This allows providers to reflect accurately why a flag was resolved to a particular value.


Reference Provider (JAVA): https://github.com/splitio/split-openfeature-provider-java/blob/main/src/main/java/io/split/openfeature/SplitProvider.java

Conventions Checklist: https://docs.openfeature.dev/docs/reference/concepts/provider/#checklist

OF Provider 2.7

https://docs.openfeature.dev/docs/specification/sections/providers#requirement-27

Requirement 2.7
In cases of normal execution, the provider MUST NOT populate the flag resolution structure's error code field, or otherwise must populate it with a null or falsy value.


Reference Provider (JAVA): https://github.com/splitio/split-openfeature-provider-java/blob/main/src/main/java/io/split/openfeature/SplitProvider.java

Conventions Checklist: https://docs.openfeature.dev/docs/reference/concepts/provider/#checklist

OF Provider 2.9

https://docs.openfeature.dev/docs/specification/sections/providers#condition-29

Condition 2.9
The implementation language supports generics (or an equivalent feature).

Conditional Requirement 2.9.1
The flag resolution structure SHOULD accept a generic argument (or use an equivalent language feature) which indicates the type of the wrapped value field.

// example boolean flag value resolution with generic argument
ResolutionDetails<boolean> resolveBooleanValue(string flagKey, boolean defaultValue, context: EvaluationContext);

// example string flag value resolution with generic argument
ResolutionDetails<string> resolveStringValue(string flagKey, string defaultValue, context: EvaluationContext);

// example number flag value resolution with generic argument
ResolutionDetails<number> resolveNumberValue(string flagKey, number defaultValue, context: EvaluationContext);

// example structure flag value resolution with generic argument
ResolutionDetails<MyStruct> resolveStructureValue(string flagKey, MyStruct defaultValue, context: EvaluationContext);

Reference Provider (JAVA): https://github.com/splitio/split-openfeature-provider-java/blob/main/src/main/java/io/split/openfeature/SplitProvider.java

Conventions Checklist: https://docs.openfeature.dev/docs/reference/concepts/provider/#checklist

OF Provider 2.10

https://docs.openfeature.dev/docs/specification/sections/providers#provider-hooks

Provider hooks
A provider hook exposes a mechanism for provider authors to register hooks to tap into various stages of the flag evaluation lifecycle. These hooks can be used to perform side effects and mutate the context for purposes of the provider. Provider hooks are not configured or controlled by the application author.

Requirement 2.10
The provider interface MUST define a provider hook mechanism which can be optionally implemented in order to add hook instances to the evaluation life-cycle.

class MyProvider implements Provider {
  //...

  readonly hooks: Hook[] = [new MyProviderHook()];

  // ..or alternatively..
  getProviderHooks(): Hook[]  {
    return [new MyProviderHook()];
  }

  //...
}

Reference Provider (JAVA): https://github.com/splitio/split-openfeature-provider-java/blob/main/src/main/java/io/split/openfeature/SplitProvider.java

Conventions Checklist: https://docs.openfeature.dev/docs/reference/concepts/provider/#checklist

OF Provider 2.11

https://docs.openfeature.dev/docs/specification/sections/providers#requirement-211

Requirement 2.11
In cases of normal execution, the provider MUST NOT populate the flag resolution structure's error message field, or otherwise must populate it with a null or falsy value.


Reference Provider (JAVA): https://github.com/splitio/split-openfeature-provider-java/blob/main/src/main/java/io/split/openfeature/SplitProvider.java

Conventions Checklist: https://docs.openfeature.dev/docs/reference/concepts/provider/#checklist

OF Provider 2.1

https://docs.openfeature.dev/docs/specification/sections/providers#requirement-21

The provider interface MUST define a metadata member or accessor, containing a name field or accessor of type string, which identifies the provider implementation.

provider.getMetadata().getName(); // "my-custom-provider"


Reference Provider (JAVA): https://github.com/splitio/split-openfeature-provider-java/blob/main/src/main/java/io/split/openfeature/SplitProvider.java

Conventions Checklist: https://docs.openfeature.dev/docs/reference/concepts/provider/#checklist

OF Provider 2.5

https://docs.openfeature.dev/docs/specification/sections/providers#requirement-25

Requirement 2.5
In cases of normal execution, the provider SHOULD populate the flag resolution structure's variant field with a string identifier corresponding to the returned flag value.

For example, the flag value might be 3.14159265359, and the variant field's value might be "pi".

The value of the variant field might only be meaningful in the context of the flag management system associated with the provider. For example, the variant may be a UUID corresponding to the variant in the flag management system, or an index corresponding to the variant in the flag management system.


Reference Provider (JAVA): https://github.com/splitio/split-openfeature-provider-java/blob/main/src/main/java/io/split/openfeature/SplitProvider.java

Conventions Checklist: https://docs.openfeature.dev/docs/reference/concepts/provider/#checklist

OF Provider 2.12

https://docs.openfeature.dev/docs/specification/sections/providers#requirement-212

Requirement 2.12
In cases of abnormal execution, the evaluation details structure's error message field MAY contain a string containing additional detail about the nature of the error.


Reference Provider (JAVA): https://github.com/splitio/split-openfeature-provider-java/blob/main/src/main/java/io/split/openfeature/SplitProvider.java

Conventions Checklist: https://docs.openfeature.dev/docs/reference/concepts/provider/#checklist

OF Requirement 1.1.1 & 1.1.2

https://docs.openfeature.dev/docs/specification/sections/flag-evaluation

Requirement 1.1.1
The API, and any state it maintains SHOULD exist as a global singleton, even in cases wherein multiple versions of the API are present at runtime.

It's important that multiple instances of the API not be active, so that state stored therein, such as the registered provider, static global evaluation context, and globally configured hooks allow the API to behave predictably. This can be difficult in some runtimes or languages, but implementors should make their best effort to ensure that only a single instance of the API is used.

Requirement 1.1.2
The API MUST provide a function to set the global provider singleton, which accepts an API-conformant provider implementation.

// example provider mutator
OpenFeature.setProvider(new MyProvider());

Pseudo:
OpenFeature.setProvider(new HarnessFF());

OF Provider 2.2

https://docs.openfeature.dev/docs/specification/sections/providers#flag-value-resolution

Flag Value Resolution
Providers are implementations of the feature provider interface, which may wrap vendor SDKs, REST API clients, or otherwise resolve flag values from the runtime environment.

Requirement 2.2
The feature provider interface MUST define methods to resolve flag values, with parameters flag key (string, required), default value (boolean | number | string | structure, required) and evaluation context (optional), which returns a flag resolution structure.

resolveBooleanValue(flagKey, defaultValue, context);```

see: [flag resolution structure](https://docs.openfeature.dev/docs/specification/types#flag-resolution), [flag value resolution](https://docs.openfeature.dev/docs/specification/glossary#flag-value-resolution)

---

Reference Provider (JAVA): https://github.com/splitio/split-openfeature-provider-java/blob/main/src/main/java/io/split/openfeature/SplitProvider.java
 
Conventions Checklist: https://docs.openfeature.dev/docs/reference/concepts/provider/#checklist

OF Provider 2.3

https://docs.openfeature.dev/docs/specification/sections/providers#flag-value-resolution

Condition 2.3
The implementing language type system differentiates between strings, numbers, booleans and structures.

Conditional Requirement 2.3.1
The feature provider interface MUST define methods for typed flag resolution, including boolean, numeric, string, and structure.

ResolutionDetails resolveBooleanValue(string flagKey, boolean defaultValue, context: EvaluationContext);

// example string flag value resolution
ResolutionDetails resolveStringValue(string flagKey, string defaultValue, context: EvaluationContext);

// example number flag value resolution
ResolutionDetails resolveNumberValue(string flagKey, number defaultValue, context: EvaluationContext);

// example structure flag value resolution
ResolutionDetails resolveStructureValue(string flagKey, JsonObject defaultValue, context: EvaluationContext);

Reference Provider (JAVA): https://github.com/splitio/split-openfeature-provider-java/blob/main/src/main/java/io/split/openfeature/SplitProvider.java

Conventions Checklist: https://docs.openfeature.dev/docs/reference/concepts/provider/#checklist

OF Provider 2.8

https://docs.openfeature.dev/docs/specification/sections/providers#requirement-28

Requirement 2.8
In cases of abnormal execution, the provider MUST indicate an error using the idioms of the implementation language, with an associated error code and optional associated error message.

The provider might throw an exception, return an error, or populate the error code object on the returned flag resolution structure to indicate a problem during flag value resolution.

See error code for details.

// example throwing an exception with an error code and optional error message.
throw new ProviderError(ErrorCode.INVALID_CONTEXT, "The 'foo' attribute must be a string.");

Reference Provider (JAVA): https://github.com/splitio/split-openfeature-provider-java/blob/main/src/main/java/io/split/openfeature/SplitProvider.java

Conventions Checklist: https://docs.openfeature.dev/docs/reference/concepts/provider/#checklist

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.