Skip to content

Conversation

@stephanos
Copy link
Contributor

@stephanos stephanos commented Jan 24, 2026

Add default_api_level=API_HYBRID to protoc-gen-go options to enable the Hybrid API.

This generates both Open struct and Opaque API files, allowing gradual migration of code to use accessor methods (Set*, Get*, Has*, Clear*) instead of direct field access.

See: https://go.dev/blog/protobuf-opaque

Add default_api_level=API_HYBRID to protoc-gen-go options to enable
the Hybrid API. This generates both Open struct and Opaque API files,
allowing gradual migration of code to use accessor methods (Set*, Get*,
Has*, Clear*) instead of direct field access.

The Hybrid API:
- Adds accessor methods to existing Open struct messages
- Generates *_protoopaque.pb.go files with hidden fields
- Enables lazy decoding and memory optimizations when fully migrated

See: https://go.dev/blog/protobuf-opaque

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@stephanos stephanos changed the title Enable Hybrid API Enable Protobuf Hybrid API [WiP] Jan 24, 2026
args = append(args, fmt.Sprintf("--go_out=paths=source_relative:%s", cfg.outputDir))
// Enable Hybrid API for gradual migration to Opaque API
// See: https://go.dev/blog/protobuf-opaque
args = append(args, "--go_opt=default_api_level=API_HYBRID")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the only manual change.

stephanos and others added 2 commits January 23, 2026 22:31
…e API

- Convert all serviceerror files to use Type_builder{}.Build() pattern
- Fix gateway files to use setters instead of direct field assignment
- Update convert.go for multi-operation error handling
- Various other opaque API compatibility fixes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update the interceptor template to generate code compatible with
protobuf opaque API:
- Use GetPayloads()/SetPayloads() instead of direct field access
- Use Has{{Field}}() for nil checks on payload fields
- Use Get{{Field}}()/Set{{Field}}() for payload field access

Regenerate proxy/interceptor.go with updated template.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@stephanos stephanos closed this Jan 24, 2026
@stephanos stephanos deleted the protobuf-opaque branch January 24, 2026 17:37
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.

2 participants