Skip to content

Commit 55ec570

Browse files
SSebosebo
authored andcommitted
chore: doc
1 parent 5647360 commit 55ec570

File tree

2 files changed

+4
-116
lines changed

2 files changed

+4
-116
lines changed

README.md

Lines changed: 3 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -14,121 +14,10 @@ Reading the short [Basic Terms](https://github.com/FeatureProbe/FeatureProbe/blo
1414

1515
## Core Data Structures
1616

17-
Reading the short [Doc](https://github.com/FeatureProbe/feature-probe-docs/blob/b8c55a35c771e4223469f1b121f8b78ab3d9bc22/docs/sdk/sdk-introduction.md?plain=1#L13-L34) about core data sturtures. [中文](https://github.com/FeatureProbe/feature-probe-docs/blob/b8c55a35c771e4223469f1b121f8b78ab3d9bc22/i18n/zh-CN/docusaurus-plugin-content-docs/current/sdk/sdk-introduction.md?plain=1#L14-L35)
17+
Reading the short [Doc](https://docs.featureprobe.io/sdk/sdk-introduction) about core data sturtures. [中文](https://docs.featureprobe.io/zh-CN/sdk/sdk-introduction/)
1818

19-
## Try Out Demo Code
20-
21-
We provide a runnable [demo](https://github.com/FeatureProbe/server-sdk-rust/tree/main/examples) for you to understand how FeatureProbe SDK is used.
22-
23-
1. Use featureprobe.io online service. [Go to](https://featureprobe.io/login)
24-
25-
Or setup FeatureProbe service with docker composer. [How to](https://github.com/FeatureProbe/FeatureProbe#1-starting-featureprobe-service-with-docker-compose)
26-
2. Download this repo and run the demo program:
27-
```bash
28-
git clone https://github.com/FeatureProbe/server-sdk-rust.git
29-
cd server-sdk-rust
30-
cargo run --example demo
31-
```
32-
3. Find the Demo code [here](https://github.com/FeatureProbe/server-sdk-rust/tree/main/examples),
33-
do some change and run the program again.
34-
```bash
35-
cargo run --example demo
36-
```
37-
38-
## Step-by-Step Guide
39-
40-
In this guide we explain how to use feature toggles in a Rust application using FeatureProbe.
41-
42-
### Step 1. Install the Rust SDK
43-
44-
First, install the FeatureProbe SDK as a dependency in your application.
45-
46-
```shell
47-
cargo install cargo-edit
48-
cargo add feature-probe-server-sdk-rs --allow-prerelease
49-
```
50-
51-
Next, import the FeatureProbe SDK in your application code:
52-
53-
```rust
54-
use feature_probe_server_sdk::{FPConfig, FPUser, FeatureProbe};
55-
```
56-
57-
### Step 2. Create a FeatureProbe instance
58-
59-
After you install and import the SDK, create a single, shared instance of the FeatureProbe sdk.
60-
61-
```rust
62-
fn main() {
63-
let remote_url = "https://featureprobe.io/server";
64-
// let remote_url = "http://localhost:4007"; // for local docker
65-
66-
let config = FPConfig {
67-
remote_url: remote_url.to_owned(),
68-
server_sdk_key: args.server_sdk_key.to_owned(),
69-
refresh_interval: Duration::from_secs(5),
70-
wait_first_resp: true,
71-
};
72-
73-
let fp = match FeatureProbe::new(config) {
74-
Ok(fp) => fp,
75-
Err(e) => {
76-
tracing::error!("{:?}", e);
77-
return;
78-
}
79-
};
80-
}
81-
```
82-
83-
### Step 3. Use the feature toggle
84-
85-
You can use sdk to check which variation a particular user will receive for a given feature flag.
86-
87-
```rust
88-
let user = FPUser::new().with("name", "bob");
89-
let show_feature = fp.bool_value("bool_toggle", &user, false);
90-
91-
if show_feature {
92-
// application code to show the feature
93-
} else {
94-
// the code to run if the feature is off
95-
}
96-
```
97-
98-
### Step 4. Unit Testing (Optional)
99-
100-
You could do unit testing for each variation:
101-
102-
```rust
103-
let fp = FeatureProbe::new_for_test("toggle_1", Value::Bool(false));
104-
let u = FPUser::new();
105-
assert_eq!(fp.bool_value("toggle_1", &u, true), false);
106-
107-
let mut toggles: HashMap<String, Value> = HashMap::new();
108-
toggles.insert("toggle_2".to_owned(), json!(12.5));
109-
toggles.insert("toggle_3".to_owned(), json!("value"));
110-
let fp = FeatureProbe::new_for_tests(toggles);
111-
assert_eq!(fp.number_value("toggle_2", &u, 20.0), 12.5);
112-
assert_eq!(fp.string_value("toggle_3", &u, "val".to_owned()), "value");
113-
```
114-
115-
[Here is an example](https://github.com/FeatureProbe/server-sdk-rust/tree/main/examples)
116-
117-
## Rust Docs
118-
119-
[Docs home](https://docs.rs/feature-probe-server-sdk/)
120-
121-
[Main functions](https://docs.rs/feature-probe-server-sdk/latest/feature_probe_server_sdk/struct.FeatureProbe.html)
122-
123-
## Testing SDK
124-
125-
We have unified integration tests for all our SDKs. Integration test cases are added as submodules for each SDK repo. So
126-
be sure to pull submodules first to get the latest integration tests before running tests.
127-
128-
```shell
129-
git pull --recurse-submodules
130-
cargo test
131-
```
19+
## How to use this SDK
20+
See [SDK Doc](https://docs.featureprobe.io/sdk/Server-Side%20SDKs/rust-sdk) for detail. [中文](https://docs.featureprobe.io/zh-CN/sdk/Server-Side%20SDKs/rust-sdk/)
13221

13322
## Contributing
13423

src/feature_probe.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,12 @@ impl FeatureProbe {
121121
}
122122

123123
pub fn close(&self) {
124+
info!("closing featureprobe client");
124125
if let Some(recorder) = &self.event_recorder {
125126
recorder.flush();
126127
}
127128
let mut should_stop = self.should_stop.write();
128129
*should_stop = true;
129-
130-
info!("featureprobe client closed");
131130
}
132131

133132
fn generic_detail<T: Default + Debug>(

0 commit comments

Comments
 (0)