thempatel opened a new pull request #16961:
URL: https://github.com/apache/beam/pull/16961


   Generated protobuf files contain additional information about the messages 
and services they were compiled from such as the file path to the original 
source proto file. The protobuf runtime for Golang maintains a global registry 
of all protobufs being used by registering the descriptors using the file path 
to the source proto file. If multiple descriptors with the same source file 
path are registered to the global registry, then the initialization code will 
prevent startup by panic-ing and printing a message like this to stdout:
   
   ```
   panic: proto: file "metrics.proto" is already registered
        previously from: 
"github.com/apache/beam/sdks/v2/go/pkg/beam/model/pipeline_v1"
        currently from:  "..."
   See 
https://developers.google.com/protocol-buffers/docs/reference/go/faq#namespace-conflict
   ```
   
   This behavior in the Go SDK is not unlikely to [go 
away](https://go-review.googlesource.com/c/protobuf/+/322729/):
   
   > reflect/protoregistry: restore conflicting file names check
   >
   >There are inconsistencies between implementations on what happens when a 
single program contains generated code for multiple files with the same source 
path. At least one canonical implementation (C++) will fail at link time. 
Others print warnings. Some silently resolve the registry conflict in favor of 
one file or the other. The protobuf maintainers agree, however, that the 
desired behavior is for this condition to be an error.
   
   This change aims to bring the protobuf imports in Beam to follow the 
guidance from a comment in this 
[issue](https://github.com/golang/protobuf/issues/1122#issuecomment-853158260) 
filed with the protobuf repo:
   
   > To avoid conflicts, every source .proto that is part of a program must 
have a unique name. Practically speaking, this means that any .proto that is 
part of a public package should be placed in a directory that uniquely 
identifies the owner of the proto. For example, 
google/protobuf/descriptor.proto and k8s.io/apimachinery/pkg/types both have 
prefixes which specify the creating organization and a specific package within 
that organization.
   
   
   As such, I've elected to place each protobuf package in a directory 
`org/apache/beam/model` relative to its respective module root and have updated 
the build system where necessary.
   
   P.S. This is still a work in progress, but opened the PR to socialize since 
this will affect all of Beam.
   
   ------------------------
   
   Thank you for your contribution! Follow this checklist to help us 
incorporate your contribution quickly and easily:
   
    - [ ] [**Choose 
reviewer(s)**](https://beam.apache.org/contribute/#make-your-change) and 
mention them in a comment (`R: @username`).
    - [ ] Format the pull request title like `[BEAM-XXX] Fixes bug in 
ApproximateQuantiles`, where you replace `BEAM-XXX` with the appropriate JIRA 
issue, if applicable. This will automatically link the pull request to the 
issue.
    - [ ] Update `CHANGES.md` with noteworthy changes.
    - [ ] If this contribution is large, please file an Apache [Individual 
Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   See the [Contributor Guide](https://beam.apache.org/contribute) for more 
tips on [how to make review process 
smoother](https://beam.apache.org/contribute/#make-reviewers-job-easier).
   
   To check the build health, please visit 
[https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
   
   GitHub Actions Tests Status (on master branch)
   
------------------------------------------------------------------------------------------------
   [![Build python source distribution and 
wheels](https://github.com/apache/beam/workflows/Build%20python%20source%20distribution%20and%20wheels/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
   [![Python 
tests](https://github.com/apache/beam/workflows/Python%20tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
   [![Java 
tests](https://github.com/apache/beam/workflows/Java%20Tests/badge.svg?branch=master&event=schedule)](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
   
   See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more 
information about GitHub Actions CI.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to