Skip to content

Commit c42dbbb

Browse files
feat: fetch all flags rpc for sync server (#82)
<!-- Please use this template for your pull request. --> <!-- Please use the sections that you need and delete other sections --> ## This PR <!-- add the description of the PR here --> - adds the fetch all flags rpc for sync server, required for flagd to resend state on merge events ### Related Issues <!-- add here the GitHub issue that this PR resolves if applicable --> ### Notes <!-- any additional notes for this PR --> ### Follow-up Tasks <!-- anything that is related to this PR but not done here should be noted under this section --> <!-- if there is a need for a new issue, please link it here --> ### How to test <!-- if applicable, add testing instructions under this section --> Signed-off-by: James Milligan <james@omnant.co.uk>
1 parent bb96463 commit c42dbbb

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

protobuf/buf.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,19 @@ a supported plugin for generating connect stubs then it is recommended to use th
2121

2222
## Flag sync
2323

24-
The module `sync.v1` is a grpc server streaming service definition to provide flagd with feature flag configurations.
25-
This service exposes a single method `SyncFlags`. Flagd acts as the client and initiates the streaming with `SyncFlagsRequest`.
24+
The module `sync.v1` is a service definition to provide flagd with feature flag configurations.
25+
The server exposes 2 `rpcs`.
2626

27+
### SyncFlags
28+
Flagd acts as the client and initiates the streaming with `SyncFlagsRequest`.
2729
The server implementation will then stream feature flag configurations through `SyncFlagsResponse`. The response contains
2830
`SyncState` which can be utilized to provide flagd with flexible configuration updates.
2931

32+
### FetchAllFlags
33+
Flagd acts as the client and sends the empty message `FetchAllFlagsRequest`.
34+
The server implementation responds with the full feature flag configuration through the `FetchAllFlagsResponse`.
35+
This `rpc` is used to re-sync flagd's internal state during configuration merge events.
36+
3037
## Code generation
3138

3239
Easiest way to generate grpc code for your language of choice is using provided [buf](https://buf.build/) templates.

protobuf/sync/v1/sync_service.proto

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,17 @@ message SyncFlagsResponse {
4646
SyncState state = 2;
4747
}
4848

49+
// FetchAllFlagsRequest is the request to fetch all flags. Flagd sends this request as the client in order to resync its internal state
50+
message FetchAllFlagsRequest {}
51+
52+
// FetchAllFlagsResponse is the server response containing feature flag configurations
53+
message FetchAllFlagsResponse {
54+
// flagd feature flag configuration. Must be validated to schema - https://raw.githubusercontent.com/open-feature/schemas/main/json/flagd-definitions.json
55+
string flag_configuration = 1;
56+
}
57+
4958
// FlagService implements a server streaming to provide realtime flag configurations
5059
service FlagSyncService {
5160
rpc SyncFlags(SyncFlagsRequest) returns (stream SyncFlagsResponse) {}
61+
rpc FetchAllFlags(FetchAllFlagsRequest) returns (FetchAllFlagsResponse) {}
5262
}

0 commit comments

Comments
 (0)