Skip to content

Commit

Permalink
defining new syntax for flagfile
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhibas committed Feb 20, 2024
1 parent b29d771 commit 2ae1020
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 50 deletions.
41 changes: 41 additions & 0 deletions Flagfile.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
feature-complex-ticket-234234 {
// this is yet another
a = b and c=d and (dd not in (1,2,3) or z == "demo car"): true

// this is other
z == "demo car": false

// demo this
g in (4,5,6) and z == "demo car": true

// demo comment
model in (ms,mx,m3,my) and created >= 2024-01-01
and demo == false: true

false
}

// once you dont have rules you can use short notation to return boolean
feature-flat-on-off -> true

// you can return non-boolean in this example json
feature-json-variant -> json({success: true})

// feature with one rule
// returns true for NL country, else false
feature-y {
countryCode == NL: true
false
}

// feature with inside commments and works like scheduler
testing {
// NOW actually should be Atom variable without value till its evaluated
NOW() >= 2024-02-18: true // this is basically scheduling something
false
}

// simple flat on-off flags still can be written as a functions
feature1 {
true
}
30 changes: 1 addition & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,4 @@ eventually this lib compiles into wasm and used in UI to validate and parse rule

### Vision for Flagfile example

scheduling of the flag:
```
demo-flag ->
NOW > 2024-02-02: true
false
```

Flagfile example with multiple flags:
```
// flag with default false
feature1 ->
created > 2024-01-01 and userId in (12,3,4): true
false
// flag where default is true
feature2 ->
country in (LT, NL) and role not in (Admin, Viewer): false
true
// flag with variation of json
feature3->
country in (NL, LT, DE): json({success: true})
json({success: false})
// simplest flag which is turned off
feature4->
false
```

Please take a look at format and supported features in [Flagfile.example]
21 changes: 0 additions & 21 deletions example-feature.rule

This file was deleted.

0 comments on commit 2ae1020

Please sign in to comment.