From fd33f5b72f736c2ae43fab0beb375944e6141e76 Mon Sep 17 00:00:00 2001 From: YUE Daian Date: Thu, 7 Sep 2023 23:22:40 +0800 Subject: [PATCH] feat: add shutdown() function to provider trait --- README.md | 26 +++++++------------------- src/provider/feature_provider.rs | 10 ++++++---- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index e6bb623..2d0dd29 100644 --- a/README.md +++ b/README.md @@ -6,33 +6,21 @@ This is the rust implementation of [OpenFeature](https://openfeature.dev), a ven We support multiple data types for flags (numbers, strings, booleans, objects) as well as hooks, which can alter the lifecycle of a flag evaluation. - ## Installation -``` -rust-sdk = { git = "https://github.com/open-feature/rust-sdk", branch = "main" } +```toml +open-feature = { git = "https://github.com/open-feature/rust-sdk", branch = "main" } ``` ## Usage ### Initialization -```rust -use rust_sdk::OpenFeatureClient; -use rust_sdk::providers::NoopProvider; -use rust_sdk::providers::traits::FeatureProvider; -use rust_sdk::traits::Client; +TBD +## Roadmap -fn main() { - - let client = OpenFeatureClient::::new( - "client-name".to_string(), - NoopProvider::new(), - ); - let result = client.value::("flag-key-here".to_string(), - 0, client.evaluation_context() ); - println!("result: {}", result.unwrap()); -} +## Pending Feature List + +- [ ] Provider hooks (2.3.*) -``` diff --git a/src/provider/feature_provider.rs b/src/provider/feature_provider.rs index 32e97bc..22e08cf 100644 --- a/src/provider/feature_provider.rs +++ b/src/provider/feature_provider.rs @@ -32,16 +32,18 @@ pub trait FeatureProvider: Send + Sync + 'static { /// abnormally. /// * The provider SHOULD indicate an error if flag resolution is attempted before the provider /// is ready. - /// - /// Implement [`Drop`] trait for the "shutdown" functions. - fn initialize(&mut self, context: EvaluationContext) {} + async fn initialize(&mut self, context: EvaluationContext) {} + + /// The provider MAY define a shutdown function to perform whatever cleanup is necessary for + /// the implementation. + async fn shutdown(&mut self) {} /// The provider MAY define a status field/accessor which indicates the readiness of the /// provider, with possible values NOT_READY, READY, or ERROR. /// /// Providers without this field can be assumed to be ready immediately. fn status(&self) -> ProviderStatus { - ProviderStatus::default() + ProviderStatus::Ready } /// The provider interface MUST define a metadata member or accessor, containing a name field