You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+67-48Lines changed: 67 additions & 48 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ A minimalist Feature Flag engine for CFML apps
15
15
- Rules engine
16
16
- DSL (Domain Specific Language) for defining flags as data
17
17
- Methods for flag CRUD, and evaluation
18
-
-[](https://github.com/atuttle/semaphore/actions/workflows/main_tests.yml) Comprehensive test suite so that you know all of the above is trustworthy
18
+
-[](https://github.com/atuttle/semaphore/actions/workflows/main_tests.yml)👈🏻 Comprehensive test suite so that you know all of the above is trustworthy
19
19
20
20
### What's NOT included?
21
21
@@ -57,74 +57,101 @@ I recommend storing this in the user session to eliminate repetitive data lookup
57
57
58
58
## Flag Definitions
59
59
60
-
This is likely to change, but for now here's what they look like:
61
-
62
60
```js
63
61
{
64
62
'example_percentage_flag': {
65
63
name:'Example Percentage Flag',
66
-
description:'This flag is only true for ~50% of the user population',
64
+
description:'This flag is only active for ~50% of the user population',
67
65
active:true,
68
66
rules: [
69
-
{
70
-
type:'%',
71
-
percentage:50
72
-
}
67
+
[
68
+
{
69
+
type:'%',
70
+
percentage:50
71
+
}
72
+
]
73
73
]
74
74
}
75
75
,'example_userId_flag': {
76
76
name:'Example UserId Flag',
77
-
description:'This flag is only true for userId 42',
77
+
description:'This flag is only active for userId 42',
description:'This flag requires both rules to evaluate to TRUE',
107
+
description:'This flag is active only if both rules to evaluate to TRUE (user has role writer, and user has betaOptIn=true)',
108
+
active:true,
109
+
rules: [
110
+
[
111
+
112
+
{
113
+
type:'filter',
114
+
attribute:'role',
115
+
operator:'has',
116
+
comparator: ['writer']
117
+
},
118
+
{
119
+
type:'filter',
120
+
attribute:'betaOptIn',
121
+
operator:'==',
122
+
comparator:true
123
+
}
124
+
]
125
+
]
126
+
}
127
+
,'example_OR_flag': {
128
+
name:'Example AND Flag',
129
+
description:'This flag is active if either rule evaluates to TRUE (user has role writer, OR user has betaOptIn=true)',
105
130
active:true,
106
-
baseState:false,
107
-
matchRules:'all',
108
131
rules: [
109
-
{
110
-
type:'filter',
111
-
attribute:'role',
112
-
operator:'has',
113
-
comparator: ['writer']
114
-
},
115
-
{
116
-
type:'filter',
117
-
attribute:'betaOptIn',
118
-
operator:'==',
119
-
comparator:true
120
-
}
132
+
[
133
+
134
+
{
135
+
type:'filter',
136
+
attribute:'role',
137
+
operator:'has',
138
+
comparator: ['writer']
139
+
}
140
+
],
141
+
[
142
+
{
143
+
type:'filter',
144
+
attribute:'betaOptIn',
145
+
operator:'==',
146
+
comparator:true
147
+
}
148
+
]
121
149
]
122
150
}
123
151
,'example_inactive_flag': {
124
152
name:'Example Inactive Flag',
125
-
description:'This flag is false for everyone because it is inactive',
153
+
description:'This flag is inactive',
126
154
active:false,
127
-
baseState:false,
128
155
rules: []
129
156
}
130
157
}
@@ -138,14 +165,6 @@ This is likely to change, but for now here's what they look like:
138
165
-`everybody`: Flag is ON for all users
139
166
- More TBD? If you have ideas, [hit me up!](https://github.com/atuttle/semaphore/issues)
140
167
141
-
#### AND vs. OR
142
-
143
-
Flags can have multiple rules. At present, Semaphore only supports flag-wide AND/OR: You can require that `ALL` of the rules evaluate to TRUE, or that `ANY` of the rules evaluate to TRUE.
144
-
145
-
The default is `ANY`. If you want to require all rules match, set `matchRules: 'ALL'` on your flag.
146
-
147
-
> **Deprecation warning:** In version 1.x the `matchRules` property will be removed in support of [better and/or support](https://adamtuttle.codes/blog/2022/semaphore-0.3-and-1.0/).
148
-
149
168
# Why not just use config settings?
150
169
151
170
You could do that, sure. But the value proposition of feature flags is that they can be toggled independendtly of deploying code changes to your application, and often much more rapidly. They can take effect as quickly as you can update the flag state on your application. How you do that is left as an exercise for you.
0 commit comments