Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: serve sync.proto on port 8015 #1237

Merged
merged 24 commits into from
Mar 12, 2024

Conversation

Kavindu-Dodan
Copy link
Contributor

@Kavindu-Dodan Kavindu-Dodan commented Mar 4, 2024

This PR

Introduce flag sync capability to flagd as discussed at [1] and fixes #1230 .

What's changed ?

The change included with this PR introduces the gRPC sync contract [2]. This allows flagd to expose its store to in-process provider which consumes gRPC flag stream.

image

How to use ?

flagd will start sync service on port 8015. You can alter the default sync port by providing desired port to the startup flag syncPort (--sync-port=8686)

Implementation details

  • Sync service startup is delayed to allow configured flag sources to complete their initial loading (dealy is 5 seconds)
  • Sync request's selector can be used to specify the specific flag source. If unset, all flags will be sent
  • A new stream response will be created whenever there are updates from flag sources

[1] - #1153
[2] - https://github.com/open-feature/flagd-schemas/blob/main/protobuf/flagd/sync/v1/sync.proto

Copy link

netlify bot commented Mar 4, 2024

Deploy Preview for polite-licorice-3db33c canceled.

Name Link
🔨 Latest commit ae6a547
🔍 Latest deploy log https://app.netlify.com/sites/polite-licorice-3db33c/deploys/65f064a03490f600086e7f96

Copy link

codecov bot commented Mar 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.11%. Comparing base (1c530ab) to head (ae6a547).
Report is 33 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1237      +/-   ##
==========================================
+ Coverage   73.69%   77.11%   +3.42%     
==========================================
  Files          32       19      -13     
  Lines        3140     1547    -1593     
==========================================
- Hits         2314     1193    -1121     
+ Misses        717      273     -444     
+ Partials      109       81      -28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/serve-flag-syncs branch 2 times, most recently from 8b0323e to a909e87 Compare March 5, 2024 23:08
@Kavindu-Dodan Kavindu-Dodan changed the title feat: [WIP]serve flag syncs feat: serve flag syncs Mar 6, 2024
@Kavindu-Dodan Kavindu-Dodan marked this pull request as ready for review March 6, 2024 21:43
@Kavindu-Dodan Kavindu-Dodan requested a review from a team as a code owner March 6, 2024 21:43
flagd/cmd/start.go Outdated Show resolved Hide resolved
@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/serve-flag-syncs branch 4 times, most recently from 7572ba3 to d042c9a Compare March 7, 2024 19:51
docs/architecture.md Outdated Show resolved Hide resolved
flagd/cmd/start.go Outdated Show resolved Hide resolved
@toddbaert toddbaert requested a review from bacherfl March 7, 2024 21:47
docs/architecture.md Outdated Show resolved Hide resolved
flagd/cmd/start.go Outdated Show resolved Hide resolved
flagd/cmd/start.go Outdated Show resolved Hide resolved
@toddbaert
Copy link
Member

toddbaert commented Mar 8, 2024

When starting flagd like this:

go run main.go start -f file:../config/samples/example_flags.flagd.json -e

Then attempting to resolve JUST that selector like this:

grpcurl -import-path "{path-to-flagd-repo}/schemas/protobuf/flagd/sync/v1/" -proto sync.proto  -plaintext -d '{"selector":"file:../config/samples/example_flags.flagd.json"}' localhost:8015  flagd.sync.v1.FlagSyncService/FetchAllFlags

I get:

ERROR:
  Code: Unknown
  Message: no flag watcher setup for source file:../config/samples/example_flags.flagd.json

Is there some normalization happening? I would have thought I could select based on this.

Note that omitting the -d {} arg (selecting nothing) works fine and returns all the flags as expected.

EDIT:

-d '{"selector":"../config/samples/example_flags.flagd.json"}' works! (your comment above led me to this solution).

This seems a bit brittle and confusing, but I think it's out of scope of this PR. I think we should just document it for now, and perhaps add a new PR that allows users to define an friendly label for each source in the JSON config mode.

Kavindu-Dodan and others added 18 commits March 11, 2024 09:32
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Co-authored-by: Michael Beemer <beeme1mr@users.noreply.github.com>
Signed-off-by: Kavindu Dodanduwa <Kavindu-Dodan@users.noreply.github.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Kavindu Dodanduwa <Kavindu-Dodan@users.noreply.github.com>
Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Kavindu Dodanduwa <Kavindu-Dodan@users.noreply.github.com>
Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Kavindu Dodanduwa <Kavindu-Dodan@users.noreply.github.com>
Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Kavindu Dodanduwa <Kavindu-Dodan@users.noreply.github.com>
Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
Signed-off-by: Kavindu Dodanduwa <Kavindu-Dodan@users.noreply.github.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
@Kavindu-Dodan Kavindu-Dodan force-pushed the feat/serve-flag-syncs branch from 1c330ff to 5eac82f Compare March 11, 2024 16:32
flagd/pkg/service/flag-sync/sync_service.go Outdated Show resolved Hide resolved
flagd/pkg/service/flag-sync/sync_service.go Outdated Show resolved Hide resolved
flagd/pkg/service/flag-sync/sync_service.go Outdated Show resolved Hide resolved
flagd/pkg/service/flag-sync/sync-multiplexer.go Outdated Show resolved Hide resolved
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
@Kavindu-Dodan Kavindu-Dodan changed the title feat: serve flag syncs feat: serve sync.proto on port 8015 Mar 11, 2024
Signed-off-by: Kavindu Dodanduwa <kavindudodanduwa@gmail.com>
@Kavindu-Dodan
Copy link
Contributor Author

Merging with all the approvals. Thank you @thisthat @toddbaert @bacherfl @beeme1mr for reviews 🤝

@Kavindu-Dodan Kavindu-Dodan merged commit 7afdc0c into open-feature:main Mar 12, 2024
15 checks passed
@github-actions github-actions bot mentioned this pull request Mar 12, 2024
Kavindu-Dodan pushed a commit that referenced this pull request Mar 15, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>flagd: 0.9.1</summary>

##
[0.9.1](flagd/v0.9.0...flagd/v0.9.1)
(2024-03-15)


### 🐛 Bug Fixes

* **deps:** update module google.golang.org/protobuf to v1.33.0
[security] ([#1248](#1248))
([b2b0fa1](b2b0fa1))
* update protobuff CVE-2024-24786
([#1249](#1249))
([fd81c23](fd81c23))


### ✨ New Features

* serve sync.proto on port 8015
([#1237](#1237))
([7afdc0c](7afdc0c))


### 🧹 Chore

* move packaging & isolate service implementations
([#1234](#1234))
([b58fab3](b58fab3))
</details>

<details><summary>flagd-proxy: 0.5.1</summary>

##
[0.5.1](flagd-proxy/v0.5.0...flagd-proxy/v0.5.1)
(2024-03-15)


### 🐛 Bug Fixes

* update protobuff CVE-2024-24786
([#1249](#1249))
([fd81c23](fd81c23))


### 🧹 Chore

* move packaging & isolate service implementations
([#1234](#1234))
([b58fab3](b58fab3))
</details>

<details><summary>core: 0.8.1</summary>

##
[0.8.1](core/v0.8.0...core/v0.8.1)
(2024-03-15)


### 🐛 Bug Fixes

* occasional panic when watched YAML files change
([#1246](#1246))
([6249d12](6249d12))
* update protobuff CVE-2024-24786
([#1249](#1249))
([fd81c23](fd81c23))


### 🧹 Chore

* move packaging & isolate service implementations
([#1234](#1234))
([b58fab3](b58fab3))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Signed-off-by: OpenFeature Bot <109696520+openfeaturebot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Support serving sync.proto
5 participants