Skip to content

Commit

Permalink
feat: add shutdown() function to provider trait
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepduke committed Sep 7, 2023
1 parent 9cc5af2 commit fd33f5b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
26 changes: 7 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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::<NoopProvider>::new(
"client-name".to_string(),
NoopProvider::new(),
);
let result = client.value::<i64>("flag-key-here".to_string(),
0, client.evaluation_context() );
println!("result: {}", result.unwrap());
}
## Pending Feature List

- [ ] Provider hooks (2.3.*)

```
10 changes: 6 additions & 4 deletions src/provider/feature_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fd33f5b

Please sign in to comment.