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!: struct for metadata for consistency and power #130

Merged
merged 3 commits into from
Feb 15, 2024

Conversation

toddbaert
Copy link
Member

This PR alters the new schemas to use maps consistently for all metadata.

Previously, the getMetadata RPC was returning a custom key/val response, which is the old proto2 way of doing maps.

Additionally, for consistency, I have changed the flag metadata to map<string, string> as well. This is a "more" breaking change, but it's consistent and will allow for much stronger typing. If there's a need for more flexibility in flag metadata, we can revert.

We can avoid this change if the breaking is a concern, but I think it's save to assume nobody but us are using this new proto.

@toddbaert toddbaert requested a review from a team as a code owner February 7, 2024 14:15
Copy link
Member

@thisthat thisthat left a comment

Choose a reason for hiding this comment

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

imho the breaking change is fine since flagd still supports the non-namespaced protos and not all languages are still using the new namespaced protos.
if the breaking change is a problem, it is worth considering having this under the v2 ns

@Kavindu-Dodan
Copy link
Contributor

@toddbaert and I discussed this and we concluded that,

  • Keeping Struct as internally its typed as map<string, Value> 1, where Value can be any type 2. This allows metadata to contain non-string values, which is useful for future enhancements
  • Transfer response type of GetMetadataResponse toStruct for the same advantage (ability to transfer any value type)

Footnotes

  1. https://protobuf.dev/reference/protobuf/google.protobuf/#struct

  2. https://protobuf.dev/reference/protobuf/google.protobuf/#value

@toddbaert toddbaert force-pushed the use-map-for-metadata branch from 5f6b854 to 705c84a Compare February 7, 2024 21:23
@toddbaert toddbaert changed the title feat!: use map for metadatas feat!: struct for metadata for consistency and power Feb 7, 2024
@toddbaert toddbaert requested a review from thisthat February 7, 2024 21:25
Signed-off-by: Todd Baert <[email protected]>
@toddbaert
Copy link
Member Author

@toddbaert and I discussed this and we concluded that,

  • Keeping Struct as internally its typed as map<string, Value> 1, where Value can be any type 2. This allows metadata to contain non-string values, which is useful for future enhancements
  • Transfer response type of GetMetadataResponse toStruct for the same advantage (ability to transfer any value type)

Footnotes

  1. https://protobuf.dev/reference/protobuf/google.protobuf/#struct
  2. https://protobuf.dev/reference/protobuf/google.protobuf/#value

Agreed, I've done this. This makes all our metadata consistent. Maybe if we could go back in time I'd use map<string, string>, but Struct also will allow us to do more complex stuff too.

@Kavindu-Dodan
Copy link
Contributor

PR checks / buf-breaking-changes : This is considered as a breaking change, but I think we can proceed anyway

Signed-off-by: Todd Baert <[email protected]>
@toddbaert
Copy link
Member Author

toddbaert commented Feb 15, 2024

@Kavindu-Dodan @thisthat @bacherfl I've marked the old metadata tag (1) as reserved. This is a protective measure for the future, and should reduce the chances of unmarshaling errors.

Only servers using/consuming the old field should be impacted now. See related SO.

@Kavindu-Dodan
Copy link
Contributor

Member

Good improvement. I think this is the way to go to avoid unnecessary issues between flagd & providers.

@toddbaert toddbaert merged commit 673fc15 into main Feb 15, 2024
5 of 6 checks passed
@github-actions github-actions bot mentioned this pull request Feb 15, 2024
toddbaert pushed a commit that referenced this pull request Feb 15, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>protobuf: 0.6.0</summary>

##
[0.6.0](protobuf-v0.5.4...protobuf-v0.6.0)
(2024-02-15)


### ⚠ BREAKING CHANGES

* struct for metadata for consistency and power
([#130](#130))

### ✨ New Features

* struct for metadata for consistency and power
([#130](#130))
([673fc15](673fc15))
</details>

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

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.

3 participants