From 198fa905186eca5d18064ccc2db30718ec444efc Mon Sep 17 00:00:00 2001 From: Max VelDink Date: Mon, 8 Apr 2024 17:44:25 -0400 Subject: [PATCH] docs: Add basic usage to README Signed-off-by: Max VelDink --- .../openfeature-sdk-meta_provider/README.md | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/providers/openfeature-sdk-meta_provider/README.md b/providers/openfeature-sdk-meta_provider/README.md index 186f2c6..a66dd64 100644 --- a/providers/openfeature-sdk-meta_provider/README.md +++ b/providers/openfeature-sdk-meta_provider/README.md @@ -24,7 +24,30 @@ gem install openfeature-meta-provider ## Usage -Coming soon +The `MetaProvider` is initialized with a collection of `Provider`s and a strategy for fetching flags from them. + +```ruby +# Create a MetaProvider +meta_provider = OpenFeature::SDK::Provider::MetaProvider.new( + providers: [ + OpenFeature::SDK::ProviderInMemoryProvider.new, + MyCustomProvider.new + ], + strategy: :first_match +) + +# Use it as the default provider +OpenFeature.configure do |c| + c.set_provider(meta_provider) +end +``` + +### Strategies + +#### :first_match + +When `:first_match` is given as the strategy, each provider will be evaluated, in the order they were passed in, for the requested `flag_key`. The first provider where the `flag_key` is found will be returned, short-circuiting flag evaluation with the remaining providers. In the case of a provider error, or no matching flags, returns the default value. + ## Contributing