Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

feat(flags): Add basic property matching #47

Merged
merged 22 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions feature-flags/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ redis = { version = "0.23.3", features = [
] }
serde = { workspace = true }
serde_json = { workspace = true }
sqlx = { workspace = true }
thiserror = { workspace = true }
serde-pickle = { version = "1.1.1"}
hex = "0.4.3"
sha1 = "0.10.6"
regex = "1.10.4"

[lints]
workspace = true
Expand Down
36 changes: 36 additions & 0 deletions feature-flags/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

# Testing

```
cargo test --package feature-flags
```

### To watch changes

```
brew install cargo-watch
```

and then run:

```
cargo watch -x test --package feature-flags
```

To run a specific test:

```
cargo watch -x "test --package feature-flags --lib -- property_matching::tests::test_match_properties_math_operators --exact --show-output"
```

# Running

```
RUST_LOG=debug cargo run --bin feature-flags
```

# Format code

```
cargo fmt --package feature-flags
```
3 changes: 3 additions & 0 deletions feature-flags/src/flag_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ pub enum OperatorType {
#[derive(Debug, Clone, Deserialize)]
pub struct PropertyFilter {
pub key: String,
// TODO: Probably need a default for value?
// incase operators like is_set, is_not_set are used
// not guaranteed to have a value, if say created via api
pub value: serde_json::Value,
pub operator: Option<OperatorType>,
#[serde(rename = "type")]
Expand Down
1 change: 0 additions & 1 deletion feature-flags/src/flag_matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ impl FeatureFlagMatcher {
hasher.update(hash_key.as_bytes());
let result = hasher.finalize();
// :TRICKY: Convert the first 15 characters of the digest to a hexadecimal string
// not sure if this is correct, padding each byte as 2 characters
let hex_str: String = result.iter().fold(String::new(), |mut acc, byte| {
let _ = write!(acc, "{:02x}", byte);
acc
Expand Down
1 change: 1 addition & 0 deletions feature-flags/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod api;
pub mod config;
pub mod flag_definitions;
pub mod flag_matching;
pub mod property_matching;
pub mod redis;
pub mod router;
pub mod server;
Expand Down
Loading
Loading