Hello Deanna, Thank you for your reply.
What language is this for? Only PHP protos? -> Yes, It's only for the PHP language Is there a reason for needing the two distinct proto files? Can you reuse one of them for the other service? -> Main service is a mediator service, it needs to call both services in order to perform a task. Included services have their own protobuf files describing them Are you setting the `php_class_prefix` option in your `.proto` file? If not, I think this might be a way to implement your intended behavior. -> Protofile from the first service sets php_metadata_namespace + php_namespace resulting in namespace \Service\Service1Namespace and the second service has no such options and a resulting namespace is \Service Problem is not within PHP loading mechanics since it will be able to load both of those services. Problem will be in autogenerated classes using same pool and having same protofile name (queries.proto) On Mon, Aug 1, 2022 at 8:32 PM 'Deanna Garcia' via Protocol Buffers < [email protected]> wrote: > A few questions: > > - What language is this for? Only PHP protos? > - Is there a reason for needing the two distinct proto files? Can you > reuse one of them for the other service? > - Are you setting the `php_class_prefix` option in your `.proto` file? > If not, I think this might be a way to implement your intended behavior. > > > On Tuesday, July 26, 2022 at 4:14:59 AM UTC-7 [email protected] wrote: > >> Hello, >> >> *Set up:* >> >> 2 separate services having their own protobuf files. >> Service1 : >> service.proto >> queries.proto >> >> Service2: >> service.proto (different from service1) >> queries.proto (different from service1) >> filters.proto >> >> And a mediator service (gateway) which needs to query both services for >> data through grpc calls. >> >> Service1 and Service2 have different package names in proto files and >> different namespaces configured in options (php plugin) >> >> *Problem:* >> Once I try to compile them and include in project everything will be fine >> till i will try to >> create objects from same named proto files (eventho namespaces will be >> different) >> example: >> >> <?php >> declare(strict_types = 1); >> require __DIR__ . '/vendor/autoload.php'; >> $q1 = new \Service1\SearchQuery(); >> $q2 = new \Service2\FilteredQuery(); <- problem will occur here >> >> >> I've traced it to the way pool is set up in generated files: >> \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool() >> its one for all namespaces. >> >> Obvious solution is to rename proto files to be named separately in both >> services, but that kind of breaks service independence >> >> *Question:* >> Is there a proper way of handling this situation? >> Maybe I am misusing protobuf concept? >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Protocol Buffers" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/protobuf/eC-9x7av8wY/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/protobuf/6f136f19-3a41-4fb6-8cf8-00f855d2402dn%40googlegroups.com > <https://groups.google.com/d/msgid/protobuf/6f136f19-3a41-4fb6-8cf8-00f855d2402dn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/CAO5mSH0rxTH225fy-Px2p5JcBxSCw3pOxYmOqvuTVBSZtiHA1g%40mail.gmail.com.
