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!: add new sync proto, rm old sync proto #99

Merged
merged 1 commit into from
Feb 6, 2024
Merged

Conversation

toddbaert
Copy link
Member

@toddbaert toddbaert commented Feb 5, 2024

  • implements new proto: flagd.sync.v1
  • removes old proto sync.v1 (breaking)
  • adds metadata

⚠️ this is a breaking change, but I think for the test-harenss that's good. providers will be forced to update their sync proto when renovate pushes this in ⚠️

@@ -131,3 +130,14 @@ func (s *SyncImpl) FetchAllFlags(context.Context, *v1.FetchAllFlagsRequest) (*v1
FlagConfiguration: string(marshalled),
}, nil
}

func (s *SyncImpl) GetMetadata(context.Context, *v1.GetMetadataRequest) (*v1.GetMetadataResponse, error) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to implement this now.

Comment on lines +137 to +140
{
Key: "paths",
Value: fmt.Sprintf("%v", s.fw.paths),
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to add some kind of meaningful metadata, even though this is really just a test harness. I chose to send back all the watched flags:

{
  "metadata": [
    {
      "key": "paths",
      "value": "[//home/todd/git/flagd-testbed/flags/testing-flags.json //home/todd/git/flagd-testbed/flags/custom-ops.json]"
    }
  ]
}

Copy link
Member Author

@toddbaert toddbaert Feb 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this more, I wonder if we should have used a map here.

This key/value construct used to be the recommended way, but maps exist now: https://protobuf.dev/programming-guides/proto3/#maps

Interestingly, the backwards compatibility section here seems to imply we could make this change in a non-breaking way because @bacherfl followed the convention exactly.

cc @Kavindu-Dodan @beeme1mr

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Per details in the backward compatibility section, I assume the map is some syntactic sugar for key-value message definitions. And it should make schema easy to understand.

If this is not a breaking change (per buf validations) I think it's fine to upgrade to map<string, string>.

@@ -92,7 +93,6 @@ func (s *SyncImpl) SyncFlags(req *v1.SyncFlagsRequest, stream syncv1grpc.FlagSyn
// initial read
err := stream.Send(&v1.SyncFlagsResponse{
FlagConfiguration: string(s.fw.getCurrentData()),
State: v1.SyncState_SYNC_STATE_ALL,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is removed.

Comment on lines +11 to +12
"buf.build/gen/go/open-feature/flagd/grpc/go/flagd/sync/v1/syncv1grpc"
v1 "buf.build/gen/go/open-feature/flagd/protocolbuffers/go/flagd/sync/v1"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all it takes to use the new proto.

@toddbaert toddbaert changed the title feat!: use new proto, add metadata feat!: add new sync proto, rm old sync proto Feb 5, 2024
Copy link
Contributor

@Kavindu-Dodan Kavindu-Dodan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@toddbaert toddbaert merged commit fed2389 into main Feb 6, 2024
5 checks passed
@toddbaert toddbaert deleted the new-proto branch February 6, 2024 15:27
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.

3 participants