Add unique label on flags#148
Conversation
For now we only have one way to find a Flag: the description. But description are not unique and very volatile and should not be used to find a precise Flag imo. ID aren't good enough too since they're linked to the database and they change accross Flagr instances (e.g staging/production) An unique label fixes all of these issues.
Codecov Report
@@ Coverage Diff @@
## master #148 +/- ##
==========================================
+ Coverage 93.46% 93.49% +0.03%
==========================================
Files 23 23
Lines 1178 1184 +6
==========================================
+ Hits 1101 1107 +6
Misses 54 54
Partials 23 23
Continue to review full report at Codecov.
|
|
Unique lable or more precisely - unique
The downside of IDs is that they are sequential, which makes it hard to link across multiple environments. Although it's addressable, for example, use a read-replica db for staging, or leverage a prod/staging manifests in code that map the features into flag ids - it's possible that you may already have that configuraiton file (mapping features to flag_ids) in code. |
|
Thanks for the answer! I opened the PR to start the discussions I appreciate the insights. I agree on all your points except that I still think that another non-db-sequential immutable key is still needed. I’m not sure I understand your last point, for now I’m mapping features to flag descriptions since I can’t know for sure the ID of the flag. Hope we can find a solution 😊 Anyway thanks for project! |
|
That would be useful! |
Thanks for the discussion @vayan! I'm interested in why you don't know the flag ID before implementing the feature. It's possible something I didn't consider before, but for us, it's very common that we just go ahead create the flag first, and then implement the feature and refer the flag ID created before. |
It's mostly because I don't know on which database my code will be run against so I have no control over the IDs. If when I create a flag I could set an unique identifier I would not have to care about databases id increments and stuff 😄 |
|
@vayan we had the same issue and one of the ideas at the time was to just use the |
|
@marceloboeira That's what I'm doing right now too 😄 but the description is so easily editable and not unique, it's kind of flaky |
|
Related to #154 I know it won't address all the cons of not having unique string based IDs, hopefully it will make setting up Flagr in tests or staging easier. Back to the story of unique labels. If your code doesn't know which database is running, it requires not only CRUD endpoints to support unique lables, but also the evaluation endpoints, right? That requires a change for example, Also, this applies to not only flags, but also all the modes. May be we can change the base gorm model for all the entities later, for example, adding a unique |
Right! I didn't want to change everything in the same PR 😄
Sure, but adding one to the Flag can be a start, that way we'd be able to evaluate them without the DB ID. |
|
Hi @vayan Yesterday, I was just about to approve this pr, but figured out there are so many moving parts for this change, thus I created another pr that adds the same thing (including all endpoints affected by flagKey), just the naming will be |
|
Awesome! Thanks @zhouzhuojie. Your PR is much more complete than mine np 😄 |
Description
For now we only have one way to find a Flag: the description.
But description are not unique and very volatile and should not be used to find a precise Flag imo.
ID aren't good enough too since they're linked to the database and they change accross Flagr instances (e.g staging/production). An unique label fixes all of these issues.
I'm not good with the Vue frontend don't hesitate to push a commit on this PR to improve it.
Types of changes
Checklist: