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

chore: statically extract .proto from Go source #2973

Merged
merged 1 commit into from
Oct 3, 2024
Merged

Conversation

alecthomas
Copy link
Collaborator

@alecthomas alecthomas commented Oct 3, 2024

This adds a general purpose command go2proto that statically generates a .proto file from Go source code. This used to be done via reflection, but that resulted in a chicken and egg problem whereby the reflection code needed to be compilable in order to generate the protobuf files that the reflection code depended on.

A couple of minor side-effects:

  1. This will automatically extract sum types and enums.
  2. The runtime types have been moved directly into the schema, as opposed to only existing in the proto.
  3. Sum type elements will need to be tagged with a //protobuf:<id> directive.

These are the breaking changes:

backend/protos/xyz/block/ftl/v1/schema/schema.proto:43:26:Field "5" on message "Data" changed name from "typeParameters" to "type_parameters".
backend/protos/xyz/block/ftl/v1/schema/schema.proto:162:3:Field "2" with name "kind" on message "MetadataAlias" changed type from "int64" to "enum".
backend/protos/xyz/block/ftl/v1/schema/schema.proto:197:10:Field "3" on message "MetadataRetry" changed name from "minBackoff" to "min_backoff".
backend/protos/xyz/block/ftl/v1/schema/schema.proto:198:10:Field "4" on message "MetadataRetry" changed name from "maxBackoff" to "max_backoff".
backend/protos/xyz/block/ftl/v1/schema/schema.proto:210:10:Field "3" on message "MetadataTypeMap" changed name from "nativeName" to "native_name".
backend/protos/xyz/block/ftl/v1/schema/schema.proto:245:17:Field "4" on message "Ref" changed name from "typeParameters" to "type_parameters".
backend/protos/xyz/block/ftl/v1/schema/schema.proto:350:3:Field "3" with name "status" on message "VerbRuntime" changed type from "xyz.block.ftl.v1.schema.Status" to "xyz.block.ftl.v1.schema.VerbStatus".

None of these changes should effect wire compatibility.

Fixes #2935

@alecthomas alecthomas added the skip-proto-breaking PRs with this label will skip the breaking proto check label Oct 3, 2024
@alecthomas alecthomas requested review from a team as code owners October 3, 2024 05:11
@alecthomas alecthomas requested review from a team, worstell and deniseli and removed request for a team October 3, 2024 05:11
@ftl-robot ftl-robot mentioned this pull request Oct 3, 2024
@ftl-robot ftl-robot mentioned this pull request Oct 3, 2024
@alecthomas alecthomas requested a review from a team as a code owner October 3, 2024 05:35
@alecthomas alecthomas requested review from stuartwdouglas and removed request for a team October 3, 2024 05:35
@stuartwdouglas stuartwdouglas requested a review from a team as a code owner October 3, 2024 05:42
@alecthomas alecthomas added skip-proto-breaking PRs with this label will skip the breaking proto check and removed skip-proto-breaking PRs with this label will skip the breaking proto check labels Oct 3, 2024
@alecthomas alecthomas force-pushed the aat/go2proto branch 2 times, most recently from 5c8e41f to 3439dcf Compare October 3, 2024 13:00
@alecthomas alecthomas enabled auto-merge (squash) October 3, 2024 13:00
@alecthomas alecthomas merged commit 0a7e36b into main Oct 3, 2024
93 checks passed
@alecthomas alecthomas deleted the aat/go2proto branch October 3, 2024 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-proto-breaking PRs with this label will skip the breaking proto check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move schema->proto generation to use static analysis
1 participant