[BUG] GRPC path generator always prefixed with `grpc` it will break generated client
- Lingua principale
- PHP
- Stelle
- 6.9k
- Fork
- 1.3k
- Merge medio
- 4h 21m
- PR unite (30g)
- 4
Descrizione
Execute the command and paste the result below.
Command: `uname -a && php -v && composer info | grep hyperf && php --ri swoole`
```bash
Linux ROCKAXE-CASTLE 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64 GNU/Linux
PHP 8.3.11 (cli) (built: Aug 27 2024 19:16:34) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.11, Copyright (c) Zend Technologies
with Zend OPcache v8.3.11, Copyright (c), by Zend Technologies
with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans
hyperf/amqp 3.1.28 A amqplib for hyperf.
hyperf/cache 3.1.38 A cache component for hyperf.
hyperf/code-parser 3.1.27 A code parser component for Hyperf.
hyperf/codec 3.1.27 A codec component for Hyperf.
hyperf/collection 3.1.38 Hyperf Collection package which come from illuminate/collect...
hyperf/command 3.1.34 Command for hyperf
hyperf/conditionable 3.1.27 Hyperf Macroable package which come from illuminate/conditio...
hyperf/config 3.1.27 An independent component that provides configuration container.
hyperf/context 3.1.31 A coroutine/application context library.
hyperf/contract 3.1.38 The contracts of Hyperf.
hyperf/coordinator 3.1.27 Hyperf Coordinator
hyperf/coroutine 3.1.29 Hyperf Coroutine
hyperf/database 3.1.41 A flexible database library.
hyperf/db-connection 3.1.41 A hyperf db connection handler for hyperf/database.
hyperf/devtool 3.1.27 A Devtool for Hyperf.
hyperf/di 3.1.35 A DI for Hyperf.
hyperf/dispatcher 3.1.27 A HTTP Server for Hyperf.
hyperf/engine 2.11.0 Coroutine engine provided by swoole.
hyperf/engine-contract 1.10.1 Contract for Coroutine Engine
hyperf/event 3.1.27 an event manager that implements PSR-14.
hyperf/exception-handler 3.1.27 Exception handler for hyperf
hyperf/framework 3.1.39 A coroutine framework that focuses on hyperspeed and flexibl...
hyperf/grpc 3.1.27 A GRPC basic library for Hyperf.
hyperf/grpc-client 3.1.27 A GRPC Client for Hyperf.
hyperf/grpc-server 3.1.27 A GRPC Server for Hyperf.
hyperf/guzzle 3.1.27 Swoole coroutine handler for guzzle
hyperf/http-message 3.1.36 microservice framework base on swoole
hyperf/http-server 3.1.36 A HTTP Server for Hyperf.
hyperf/logger 3.1.35 A logger component for hyperf.
hyperf/macroable 3.1.27 Hyperf Macroable package which come from illuminate/macroable
hyperf/memory 3.1.27 An independent component that use to operate and manage memory.
hyperf/model-listener 3.1.27 A model listener for Hyperf.
hyperf/pipeline 3.1.27 Hyperf Macroable package which come from illuminate/pipeline
hyperf/pool 3.1.35 An independent universal connection pool component.
hyperf/process 3.1.27 A process component for hyperf.
hyperf/redis 3.1.27 A redis component for hyperf.
hyperf/rpc 3.1.27 A rpc basic library for Hyperf.
hyperf/rpc-server 3.1.27 An abstract rpc server component for Hyperf.
hyperf/serializer 3.1.27 A serializer component for Hyperf.
hyperf/server 3.1.27 A base server library for Hyperf.
hyperf/stdlib 3.1.40 A stdlib component for Hyperf.
hyperf/stringable 3.1.40 Hyperf Stringable package which come from illuminate/support
hyperf/support 3.1.36 A support component for Hyperf.
hyperf/tappable 3.1.35 Hyperf Macroable package which come from illuminate/tappable
hyperf/testing 3.1.29 Testing for hyperf
hyperf/utils 3.1.27 A tools package that could help developer solved the problem...
hyperf/watcher 3.1.39 Hot reload watcher for Hyperf
swoole
Swoole => enabled
Author => Swoole Team
Version => 5.1.2
Built => Jan 1 1980 00:00:00
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
http2 => enabled
json => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_fiber_mock => Off => Off
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => On => On
swoole.unixsock_buffer_size => 8388608 => 8388608
```
### Description:
When registering GRPC service using `RpcService` annotation generated path always prefixed with `grpc`
```proto
syntax = "proto3";
option php_namespace = "GRPC\\Pinger";
option php_metadata_namespace = "GRPC\\GPBMetadata";
package pinger;
service Pinger {
rpc ping (PingRequest) returns (PingResponse) {}
}
message PingRequest {
string url = 1;
}
message PingResponse {
int32 status_code = 1;
}
```
```php
#[RpcService(name: 'Pinger', server: 'grpc', protocol: 'grpc')]
final class PingerController extends AbstractController
{
public function ping(PingRequest $req): PingResponse
{
$res = new PingResponse();
$res->setStatusCode(200);
return $res;
}
}
```
The path will be `grpc.Pinger/ping` instead of `pinger.Pinger/ping` so it will break generated client.
My suggestion either to have additional property in `RpcService`
```php
#[RpcService(name: 'Pinger', server: 'grpc', protocol: 'grpc', package: 'pinger')]
```
Then adjust `PathGeneratorInterface` to accept additional parameter
```php
interface PathGeneratorInterface
{
public function generate(string $service, string $method, array $options = []): string;
}
```
From there we can resolve package name in Grpc Path Generator. What do you think? or do you have any other idea to implement this?
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Start by tracing RpcService registration to the GRPC path generator and reviewing PathGeneratorInterface. Compare the generated grpc.Pinger/ping path with the proto package pinger and verify the approach against the generated client. Done means the registered service path uses the package-qualified name without breaking existing protocols.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- grpc, php
- Ambito
- api, backend-api-design
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100