diff --git a/Makefile b/Makefile index 59afe2e..a0102f3 100644 --- a/Makefile +++ b/Makefile @@ -103,7 +103,7 @@ phpstan: var vendor ## Analyze code using PHPStan $(RUN) phpstan analyze --memory-limit=1G $(ARGS) .PHONY: phpstan -test: var vendor ## Run tests using PHPUnit +test: var vendor compile-test-stub ## Run tests using PHPUnit $(RUN) vendor/bin/phpunit $(ARGS) --colors .PHONY: test @@ -130,12 +130,12 @@ composer-normalize-check: ## Check that composer.json is normalized fix: fixer rector composer-normalize ## Run all fixing recipes .PHONY: fix -check: fixer-check rector-check composer-validate composer-normalize-check deps-analyze phpstan compile-test-stub test ## Run all project checks +check: fixer-check rector-check composer-validate composer-normalize-check deps-analyze phpstan test ## Run all project checks .PHONY: check compile-test-stub: docker run --rm \ - --user 1000:1000 \ + --user $(CONTAINER_USER) \ -v $(PWD):/workspace \ -w /workspace \ ghcr.io/thesis-php/protoc-plugin:latest \ diff --git a/composer.json b/composer.json index d4e0087..b1fdb29 100644 --- a/composer.json +++ b/composer.json @@ -30,15 +30,16 @@ "psr/log": "^3.0", "revolt/event-loop": "1.0.8", "thesis/endian": "^0.3.0", - "thesis/googleapis-rpc-types": "^0.1.2", + "thesis/googleapis-rpc-types": "^0.1.6", "thesis/package-version": "^0.1.2", - "thesis/protobuf": "^0.1.5", - "thesis/protobuf-known-types": "^0.1.2" + "thesis/protobuf": "^0.1.8", + "thesis/protobuf-known-types": "^0.1.5" }, "require-dev": { "ext-bcmath": "*", "phpunit/phpunit": "^12.4", - "symfony/var-dumper": "^8.0" + "symfony/var-dumper": "^8.0", + "thesis/protoregistry": "^0.1.2" }, "autoload": { "psr-4": { diff --git a/src/Server.php b/src/Server.php index 9419205..d2b3772 100644 --- a/src/Server.php +++ b/src/Server.php @@ -10,7 +10,7 @@ /** * @api */ -interface Server +interface Server extends ServiceRegistrar { /** * The server can subscribe to the {@see Cancellation} to stop automatically when it is triggered, for example on a signal. diff --git a/src/Server/Builder.php b/src/Server/Builder.php index 8d91179..0fd2935 100644 --- a/src/Server/Builder.php +++ b/src/Server/Builder.php @@ -373,17 +373,20 @@ public function build(): Server $server->expose($address, $bindContext); } - return new Internal\AmphpHttpServer( + $grpc = new Internal\AmphpHttpServer( server: $server, requestHandler: new ServerRequestHandler( encoderFactory: new MessageEncoderFactory(array_values($this->encoders)), compressorFactory: new MessageCompressorFactory($compressors), protobuf: $this->protobuf ?? Protobuf\Encoder\Builder::buildDefault(), - services: $this->services, interceptors: $this->interceptors, ), errorHandler: new ServerErrorHandler(), ); + + $grpc->register(...$this->services); + + return $grpc; } /** diff --git a/src/Server/Internal/AmphpHttpServer.php b/src/Server/Internal/AmphpHttpServer.php index 9a33d7f..8741d8b 100644 --- a/src/Server/Internal/AmphpHttpServer.php +++ b/src/Server/Internal/AmphpHttpServer.php @@ -10,6 +10,7 @@ use Amp\NullCancellation; use Revolt\EventLoop; use Thesis\Grpc\Server; +use Thesis\Grpc\Server\Service; use function Amp\async; /** @@ -68,4 +69,20 @@ public function __destruct() { $this->stop(); } + + #[\Override] + public function register(Service ...$services): void + { + if ($this->state === HttpServerState::Serve) { + throw new Server\ServerRunning(); + } + + $this->requestHandler->register(...$services); + } + + #[\Override] + public function services(): array + { + return $this->requestHandler->services(); + } } diff --git a/src/Server/Internal/Http2/Router.php b/src/Server/Internal/Http2/Router.php index 47fb3d4..bb2600d 100644 --- a/src/Server/Internal/Http2/Router.php +++ b/src/Server/Internal/Http2/Router.php @@ -11,26 +11,25 @@ /** * @internal + * @template-implements \IteratorAggregate */ -final readonly class Router +final class Router implements \IteratorAggregate { /** @var array> */ - private array $services; + private array $index = []; - /** - * @param list $services - */ - public function __construct(array $services) + /** @var list */ + private array $services = []; + + public function addService(Service $service): void { - $this->services = array_combine( - array_map(static fn(Service $service) => $service->name, $services), + $this->services[] = $service; + $this->index[$service->name] = array_combine( array_map( - static fn(Service $service) => array_combine( - array_map(static fn(Rpc $rpc) => $rpc->handle->method, $service->handlers), - $service->handlers, - ), - $services, + static fn(Rpc $rpc) => $rpc->handle->method, + $service->handlers, ), + $service->handlers, ); } @@ -47,8 +46,14 @@ public function route(Request $request): Rpc $endpoint = Endpoint::parse($path); - $rpc = $this->services[$endpoint->service] ?? throw new InvalidRpcMethod("Unknown service {$endpoint->service}"); + $rpc = $this->index[$endpoint->service] ?? throw new InvalidRpcMethod("Unknown service {$endpoint->service}"); return $rpc[$endpoint->method] ?? throw new InvalidRpcMethod("Unknown method {$endpoint->method} for service {$endpoint->service}"); } + + #[\Override] + public function getIterator(): \Traversable + { + yield from $this->services; + } } diff --git a/src/Server/Internal/Http2/ServerRequestHandler.php b/src/Server/Internal/Http2/ServerRequestHandler.php index 5287cb3..b9e40a8 100644 --- a/src/Server/Internal/Http2/ServerRequestHandler.php +++ b/src/Server/Internal/Http2/ServerRequestHandler.php @@ -22,6 +22,7 @@ use Thesis\Grpc\Server\Service; use Thesis\Grpc\Server\StreamInfo; use Thesis\Grpc\ServerStream; +use Thesis\Grpc\ServiceRegistrar; use Thesis\Grpc\UnimplementedException; use Thesis\Protobuf; use function Amp\async; @@ -30,7 +31,9 @@ * @internal * @phpstan-type HandlerEntry = object{future: Future, cancellation: DeferredCancellation} */ -final class ServerRequestHandler implements RequestHandler +final class ServerRequestHandler implements + RequestHandler, + ServiceRegistrar { private readonly Router $router; @@ -40,24 +43,34 @@ final class ServerRequestHandler implements RequestHandler private \WeakMap $pending; /** - * @param list $services * @param list $interceptors */ public function __construct( private readonly MessageEncoderFactory $encoderFactory, private readonly MessageCompressorFactory $compressorFactory, Protobuf\Encoder $protobuf, - array $services, array $interceptors, ) { $this->pending = new \WeakMap(); - $this->router = new Router($services); + $this->router = new Router(); $this->interceptor = new InterceptorComposer([ new StreamHandleInterceptor($protobuf), ...$interceptors, ]); } + #[\Override] + public function register(Service ...$services): void + { + array_walk($services, $this->router->addService(...)); + } + + #[\Override] + public function services(): array + { + return iterator_to_array($this->router, preserve_keys: false); + } + #[\Override] public function handleRequest(Request $request): Response { diff --git a/src/Server/ServerRunning.php b/src/Server/ServerRunning.php new file mode 100644 index 0000000..c3692fe --- /dev/null +++ b/src/Server/ServerRunning.php @@ -0,0 +1,12 @@ + + */ + public function services(): array; +} diff --git a/tests/ServerTest.php b/tests/ServerTest.php new file mode 100644 index 0000000..9a41096 --- /dev/null +++ b/tests/ServerTest.php @@ -0,0 +1,51 @@ +build(); + $server->register(...new EchoServiceServerRegistry(new class implements EchoServiceServer { + #[\Override] + public function echo(EchoRequest $request, Metadata $md, Cancellation $cancellation): EchoResponse + { + return new EchoResponse($request->sentence); + } + })->services()); + + $server->start(); + $client = new EchoServiceClient(new Client\Builder()->build()); + self::assertSame('Hello, gRPC', $client->echo(new EchoRequest('Hello, gRPC'))->sentence); + $server->stop(); + } + + public function testRegisterServiceInRunningServer(): void + { + $server = new Server\Builder()->build(); + $server->start(); + $this->expectExceptionObject(new ServerRunning()); + $server->register(...new EchoServiceServerRegistry(new class implements EchoServiceServer { + #[\Override] + public function echo(EchoRequest $request, Metadata $md, Cancellation $cancellation): EchoResponse + { + return new EchoResponse($request->sentence); + } + })->services()); + } +} diff --git a/tests/genproto/Chat/Api/V1/Message.php b/tests/genproto/Chat/Api/V1/Message.php index cbb04e1..01a28c2 100644 --- a/tests/genproto/Chat/Api/V1/Message.php +++ b/tests/genproto/Chat/Api/V1/Message.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/chat_v1.proto */ diff --git a/tests/genproto/Chat/Api/V1/MessengerServiceClient.php b/tests/genproto/Chat/Api/V1/MessengerServiceClient.php index d081cbf..2a92a18 100644 --- a/tests/genproto/Chat/Api/V1/MessengerServiceClient.php +++ b/tests/genproto/Chat/Api/V1/MessengerServiceClient.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/chat_v1.proto */ diff --git a/tests/genproto/Chat/Api/V1/MessengerServiceServer.php b/tests/genproto/Chat/Api/V1/MessengerServiceServer.php index b6bb838..18e8ae1 100644 --- a/tests/genproto/Chat/Api/V1/MessengerServiceServer.php +++ b/tests/genproto/Chat/Api/V1/MessengerServiceServer.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/chat_v1.proto */ diff --git a/tests/genproto/Chat/Api/V1/MessengerServiceServerRegistry.php b/tests/genproto/Chat/Api/V1/MessengerServiceServerRegistry.php index ba7ef14..4ccb45a 100644 --- a/tests/genproto/Chat/Api/V1/MessengerServiceServerRegistry.php +++ b/tests/genproto/Chat/Api/V1/MessengerServiceServerRegistry.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/chat_v1.proto */ diff --git a/tests/genproto/Chat/Api/V1/TestsProtosChatV1DescriptorRegistry.php b/tests/genproto/Chat/Api/V1/TestsProtosChatV1DescriptorRegistry.php index f4ef34f..4dbdc58 100644 --- a/tests/genproto/Chat/Api/V1/TestsProtosChatV1DescriptorRegistry.php +++ b/tests/genproto/Chat/Api/V1/TestsProtosChatV1DescriptorRegistry.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/chat_v1.proto */ @@ -13,20 +13,32 @@ namespace Chat\Api\V1; use Override; -use Thesis\Protobuf\Pool; +use Thesis\Protobuf\Registry; +use Thesis\Protobuf\Registry\File; /** * @api */ -final readonly class TestsProtosChatV1DescriptorRegistry implements Pool\Registrar +final readonly class TestsProtosChatV1DescriptorRegistry implements Registry\Registrar { private const string DESCRIPTOR_BUFFER = 'Chp0ZXN0cy9wcm90b3MvY2hhdF92MS5wcm90bxILY2hhdC5hcGkudjEiHQoHTWVzc2FnZRISCgR0ZXh0GAEgASgJUgR0ZXh0MkoKEE1lc3NlbmdlclNlcnZpY2USNgoEQ2hhdBIULmNoYXQuYXBpLnYxLk1lc3NhZ2UaFC5jaGF0LmFwaS52MS5NZXNzYWdlKAEwAUrWAQoGEgQAAAoBCggKAQwSAwAAEgoICgECEgMCABQKCgoCBAASBAQABgEKCgoDBAABEgMECA8KCwoEBAACABIDBQQUCgwKBQQAAgAFEgMFBAoKDAoFBAACAAESAwULDwoMCgUEAAIAAxIDBRITCgoKAgYAEgQIAAoBCgoKAwYAARIDCAgYCgsKBAYAAgASAwkENgoMCgUGAAIAARIDCQgMCgwKBQYAAgAFEgMJDRMKDAoFBgACAAISAwkUGwoMCgUGAAIABhIDCSYsCgwKBQYAAgADEgMJLTRiBnByb3RvMw=='; #[Override] - public function register(Pool\Registry $pool): void + public function register(Registry\Pool $pool): void { - $pool->add(Pool\Descriptor::base64(self::DESCRIPTOR_BUFFER), [ - 'chat.api.v1.Message' => new Pool\MessageMetadata(\Chat\Api\V1\Message::class), - ]); + $pool->add(Registry\Descriptor::base64(self::DESCRIPTOR_BUFFER), new File( + name: 'tests/protos/chat_v1.proto', + messages: [ + new File\MessageDescriptor('chat.api.v1.Message', \Chat\Api\V1\Message::class), + ], + services: [ + new File\ServiceDescriptor( + name: 'chat.api.v1.MessengerService', + methods: [ + new File\MethodDescriptor('Chat', true, true), + ], + ), + ], + )); } } diff --git a/tests/genproto/Chat/Api/V1/autoload.metadata.php b/tests/genproto/Chat/Api/V1/autoload.metadata.php index 6e7f0a8..b6d0151 100644 --- a/tests/genproto/Chat/Api/V1/autoload.metadata.php +++ b/tests/genproto/Chat/Api/V1/autoload.metadata.php @@ -3,12 +3,12 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 */ declare(strict_types=1); -\Thesis\Protobuf\Pool\Registry::get()->register( - new \Thesis\Protobuf\Pool\OnceRegistrar(new \Chat\Api\V1\TestsProtosChatV1DescriptorRegistry()), +\Thesis\Protobuf\Registry\Pool::get()->register( + new \Thesis\Protobuf\Registry\OnceRegistrar(new \Chat\Api\V1\TestsProtosChatV1DescriptorRegistry()), ); diff --git a/tests/genproto/Echos/Api/V1/EchoRequest.php b/tests/genproto/Echos/Api/V1/EchoRequest.php index f1479aa..16fda2a 100644 --- a/tests/genproto/Echos/Api/V1/EchoRequest.php +++ b/tests/genproto/Echos/Api/V1/EchoRequest.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/echo_v1.proto */ diff --git a/tests/genproto/Echos/Api/V1/EchoResponse.php b/tests/genproto/Echos/Api/V1/EchoResponse.php index ff07b99..33018b2 100644 --- a/tests/genproto/Echos/Api/V1/EchoResponse.php +++ b/tests/genproto/Echos/Api/V1/EchoResponse.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/echo_v1.proto */ diff --git a/tests/genproto/Echos/Api/V1/EchoServiceClient.php b/tests/genproto/Echos/Api/V1/EchoServiceClient.php index 16d0b30..d877423 100644 --- a/tests/genproto/Echos/Api/V1/EchoServiceClient.php +++ b/tests/genproto/Echos/Api/V1/EchoServiceClient.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/echo_v1.proto */ diff --git a/tests/genproto/Echos/Api/V1/EchoServiceServer.php b/tests/genproto/Echos/Api/V1/EchoServiceServer.php index 3c68871..9883d2a 100644 --- a/tests/genproto/Echos/Api/V1/EchoServiceServer.php +++ b/tests/genproto/Echos/Api/V1/EchoServiceServer.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/echo_v1.proto */ diff --git a/tests/genproto/Echos/Api/V1/EchoServiceServerRegistry.php b/tests/genproto/Echos/Api/V1/EchoServiceServerRegistry.php index 6a39a0f..f3756d5 100644 --- a/tests/genproto/Echos/Api/V1/EchoServiceServerRegistry.php +++ b/tests/genproto/Echos/Api/V1/EchoServiceServerRegistry.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/echo_v1.proto */ diff --git a/tests/genproto/Echos/Api/V1/TestsProtosEchoV1DescriptorRegistry.php b/tests/genproto/Echos/Api/V1/TestsProtosEchoV1DescriptorRegistry.php index 44d8c3a..7c80a9e 100644 --- a/tests/genproto/Echos/Api/V1/TestsProtosEchoV1DescriptorRegistry.php +++ b/tests/genproto/Echos/Api/V1/TestsProtosEchoV1DescriptorRegistry.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/echo_v1.proto */ @@ -13,21 +13,33 @@ namespace Echos\Api\V1; use Override; -use Thesis\Protobuf\Pool; +use Thesis\Protobuf\Registry; +use Thesis\Protobuf\Registry\File; /** * @api */ -final readonly class TestsProtosEchoV1DescriptorRegistry implements Pool\Registrar +final readonly class TestsProtosEchoV1DescriptorRegistry implements Registry\Registrar { private const string DESCRIPTOR_BUFFER = 'Chp0ZXN0cy9wcm90b3MvZWNob192MS5wcm90bxIMZWNob3MuYXBpLnYxIikKC0VjaG9SZXF1ZXN0EhoKCHNlbnRlbmNlGAEgASgJUghzZW50ZW5jZSIqCgxFY2hvUmVzcG9uc2USGgoIc2VudGVuY2UYASABKAlSCHNlbnRlbmNlMkwKC0VjaG9TZXJ2aWNlEj0KBEVjaG8SGS5lY2hvcy5hcGkudjEuRWNob1JlcXVlc3QaGi5lY2hvcy5hcGkudjEuRWNob1Jlc3BvbnNlSokCCgYSBAAADgEKCAoBDBIDAAASCggKAQISAwIAFQoKCgIEABIEBAAGAQoKCgMEAAESAwQIEwoLCgQEAAIAEgMFBBgKDAoFBAACAAUSAwUECgoMCgUEAAIAARIDBQsTCgwKBQQAAgADEgMFFhcKCgoCBAESBAgACgEKCgoDBAEBEgMICBQKCwoEBAECABIDCQQYCgwKBQQBAgAFEgMJBAoKDAoFBAECAAESAwkLEwoMCgUEAQIAAxIDCRYXCgoKAgYAEgQMAA4BCgoKAwYAARIDDAgTCgsKBAYAAgASAw0EMQoMCgUGAAIAARIDDQgMCgwKBQYAAgACEgMNDRgKDAoFBgACAAMSAw0jL2IGcHJvdG8z'; #[Override] - public function register(Pool\Registry $pool): void + public function register(Registry\Pool $pool): void { - $pool->add(Pool\Descriptor::base64(self::DESCRIPTOR_BUFFER), [ - 'echos.api.v1.EchoRequest' => new Pool\MessageMetadata(\Echos\Api\V1\EchoRequest::class), - 'echos.api.v1.EchoResponse' => new Pool\MessageMetadata(\Echos\Api\V1\EchoResponse::class), - ]); + $pool->add(Registry\Descriptor::base64(self::DESCRIPTOR_BUFFER), new File( + name: 'tests/protos/echo_v1.proto', + messages: [ + new File\MessageDescriptor('echos.api.v1.EchoRequest', \Echos\Api\V1\EchoRequest::class), + new File\MessageDescriptor('echos.api.v1.EchoResponse', \Echos\Api\V1\EchoResponse::class), + ], + services: [ + new File\ServiceDescriptor( + name: 'echos.api.v1.EchoService', + methods: [ + new File\MethodDescriptor('Echo', false, false), + ], + ), + ], + )); } } diff --git a/tests/genproto/Echos/Api/V1/autoload.metadata.php b/tests/genproto/Echos/Api/V1/autoload.metadata.php index 6d7587a..92c3227 100644 --- a/tests/genproto/Echos/Api/V1/autoload.metadata.php +++ b/tests/genproto/Echos/Api/V1/autoload.metadata.php @@ -3,12 +3,12 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 */ declare(strict_types=1); -\Thesis\Protobuf\Pool\Registry::get()->register( - new \Thesis\Protobuf\Pool\OnceRegistrar(new \Echos\Api\V1\TestsProtosEchoV1DescriptorRegistry()), +\Thesis\Protobuf\Registry\Pool::get()->register( + new \Thesis\Protobuf\Registry\OnceRegistrar(new \Echos\Api\V1\TestsProtosEchoV1DescriptorRegistry()), ); diff --git a/tests/genproto/File/Api/V1/Chunk.php b/tests/genproto/File/Api/V1/Chunk.php index a0a32e0..06acb0b 100644 --- a/tests/genproto/File/Api/V1/Chunk.php +++ b/tests/genproto/File/Api/V1/Chunk.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/file_v1.proto */ diff --git a/tests/genproto/File/Api/V1/FileInfo.php b/tests/genproto/File/Api/V1/FileInfo.php index fdcc958..b3bb8f0 100644 --- a/tests/genproto/File/Api/V1/FileInfo.php +++ b/tests/genproto/File/Api/V1/FileInfo.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/file_v1.proto */ diff --git a/tests/genproto/File/Api/V1/FileServiceClient.php b/tests/genproto/File/Api/V1/FileServiceClient.php index aff6bf5..a2a98d5 100644 --- a/tests/genproto/File/Api/V1/FileServiceClient.php +++ b/tests/genproto/File/Api/V1/FileServiceClient.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/file_v1.proto */ diff --git a/tests/genproto/File/Api/V1/FileServiceServer.php b/tests/genproto/File/Api/V1/FileServiceServer.php index eed8013..da3a1c7 100644 --- a/tests/genproto/File/Api/V1/FileServiceServer.php +++ b/tests/genproto/File/Api/V1/FileServiceServer.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/file_v1.proto */ diff --git a/tests/genproto/File/Api/V1/FileServiceServerRegistry.php b/tests/genproto/File/Api/V1/FileServiceServerRegistry.php index a5667c5..8b30e55 100644 --- a/tests/genproto/File/Api/V1/FileServiceServerRegistry.php +++ b/tests/genproto/File/Api/V1/FileServiceServerRegistry.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/file_v1.proto */ diff --git a/tests/genproto/File/Api/V1/TestsProtosFileV1DescriptorRegistry.php b/tests/genproto/File/Api/V1/TestsProtosFileV1DescriptorRegistry.php index a6712fd..dd5996f 100644 --- a/tests/genproto/File/Api/V1/TestsProtosFileV1DescriptorRegistry.php +++ b/tests/genproto/File/Api/V1/TestsProtosFileV1DescriptorRegistry.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/file_v1.proto */ @@ -13,21 +13,33 @@ namespace File\Api\V1; use Override; -use Thesis\Protobuf\Pool; +use Thesis\Protobuf\Registry; +use Thesis\Protobuf\Registry\File; /** * @api */ -final readonly class TestsProtosFileV1DescriptorRegistry implements Pool\Registrar +final readonly class TestsProtosFileV1DescriptorRegistry implements Registry\Registrar { private const string DESCRIPTOR_BUFFER = 'Chp0ZXN0cy9wcm90b3MvZmlsZV92MS5wcm90bxILZmlsZS5hcGkudjEiIQoFQ2h1bmsSGAoHY29udGVudBgBIAEoDFIHY29udGVudCIeCghGaWxlSW5mbxISCgRzaXplGAEgASgFUgRzaXplMkQKC0ZpbGVTZXJ2aWNlEjUKBlVwbG9hZBISLmZpbGUuYXBpLnYxLkNodW5rGhUuZmlsZS5hcGkudjEuRmlsZUluZm8oAUqXAgoGEgQAAA4BCggKAQwSAwAAEgoICgECEgMCABQKCgoCBAASBAQABgEKCgoDBAABEgMECA0KCwoEBAACABIDBQQWCgwKBQQAAgAFEgMFBAkKDAoFBAACAAESAwUKEQoMCgUEAAIAAxIDBRQVCgoKAgQBEgQIAAoBCgoKAwQBARIDCAgQCgsKBAQBAgASAwkEEwoMCgUEAQIABRIDCQQJCgwKBQQBAgABEgMJCg4KDAoFBAECAAMSAwkREgoKCgIGABIEDAAOAQoKCgMGAAESAwwIEwoLCgQGAAIAEgMNBDEKDAoFBgACAAESAw0IDgoMCgUGAAIABRIDDRAWCgwKBQYAAgACEgMNFxwKDAoFBgACAAMSAw0nL2IGcHJvdG8z'; #[Override] - public function register(Pool\Registry $pool): void + public function register(Registry\Pool $pool): void { - $pool->add(Pool\Descriptor::base64(self::DESCRIPTOR_BUFFER), [ - 'file.api.v1.Chunk' => new Pool\MessageMetadata(\File\Api\V1\Chunk::class), - 'file.api.v1.FileInfo' => new Pool\MessageMetadata(\File\Api\V1\FileInfo::class), - ]); + $pool->add(Registry\Descriptor::base64(self::DESCRIPTOR_BUFFER), new File( + name: 'tests/protos/file_v1.proto', + messages: [ + new File\MessageDescriptor('file.api.v1.Chunk', \File\Api\V1\Chunk::class), + new File\MessageDescriptor('file.api.v1.FileInfo', \File\Api\V1\FileInfo::class), + ], + services: [ + new File\ServiceDescriptor( + name: 'file.api.v1.FileService', + methods: [ + new File\MethodDescriptor('Upload', true, false), + ], + ), + ], + )); } } diff --git a/tests/genproto/File/Api/V1/autoload.metadata.php b/tests/genproto/File/Api/V1/autoload.metadata.php index 19131bd..627a6c5 100644 --- a/tests/genproto/File/Api/V1/autoload.metadata.php +++ b/tests/genproto/File/Api/V1/autoload.metadata.php @@ -3,12 +3,12 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 */ declare(strict_types=1); -\Thesis\Protobuf\Pool\Registry::get()->register( - new \Thesis\Protobuf\Pool\OnceRegistrar(new \File\Api\V1\TestsProtosFileV1DescriptorRegistry()), +\Thesis\Protobuf\Registry\Pool::get()->register( + new \Thesis\Protobuf\Registry\OnceRegistrar(new \File\Api\V1\TestsProtosFileV1DescriptorRegistry()), ); diff --git a/tests/genproto/Topic/Api/V1/Event.php b/tests/genproto/Topic/Api/V1/Event.php index 2d09d5d..b1c68fa 100644 --- a/tests/genproto/Topic/Api/V1/Event.php +++ b/tests/genproto/Topic/Api/V1/Event.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/topic_v1.proto */ diff --git a/tests/genproto/Topic/Api/V1/SubscribeRequest.php b/tests/genproto/Topic/Api/V1/SubscribeRequest.php index b707785..57ad187 100644 --- a/tests/genproto/Topic/Api/V1/SubscribeRequest.php +++ b/tests/genproto/Topic/Api/V1/SubscribeRequest.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/topic_v1.proto */ diff --git a/tests/genproto/Topic/Api/V1/TestsProtosTopicV1DescriptorRegistry.php b/tests/genproto/Topic/Api/V1/TestsProtosTopicV1DescriptorRegistry.php index b65dd3e..eefeede 100644 --- a/tests/genproto/Topic/Api/V1/TestsProtosTopicV1DescriptorRegistry.php +++ b/tests/genproto/Topic/Api/V1/TestsProtosTopicV1DescriptorRegistry.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/topic_v1.proto */ @@ -13,21 +13,36 @@ namespace Topic\Api\V1; use Override; -use Thesis\Protobuf\Pool; +use Thesis\Protobuf\Registry; +use Thesis\Protobuf\Registry\File; /** * @api */ -final readonly class TestsProtosTopicV1DescriptorRegistry implements Pool\Registrar +final readonly class TestsProtosTopicV1DescriptorRegistry implements Registry\Registrar { private const string DESCRIPTOR_BUFFER = 'Cht0ZXN0cy9wcm90b3MvdG9waWNfdjEucHJvdG8SDHRvcGljLmFwaS52MRofZ29vZ2xlL3Byb3RvYnVmL3RpbWVzdGFtcC5wcm90byIoChBTdWJzY3JpYmVSZXF1ZXN0EhQKBXRvcGljGAEgASgJUgV0b3BpYyJhCgVFdmVudBISCgR0eXBlGAEgASgJUgR0eXBlEhgKB3BheWxvYWQYAiABKAlSB3BheWxvYWQSKgoCdHMYAyABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wUgJ0czJSCgxUb3BpY1NlcnZpY2USQgoJU3Vic2NyaWJlEh4udG9waWMuYXBpLnYxLlN1YnNjcmliZVJlcXVlc3QaEy50b3BpYy5hcGkudjEuRXZlbnQwAUqQAwoGEgQAABIBCggKAQwSAwAAEgoJCgIDABIDAgApCggKAQISAwQAFQoKCgIEABIEBgAIAQoKCgMEAAESAwYIGAoLCgQEAAIAEgMHBBUKDAoFBAACAAUSAwcECgoMCgUEAAIAARIDBwsQCgwKBQQAAgADEgMHExQKCgoCBAESBAoADgEKCgoDBAEBEgMKCA0KCwoEBAECABIDCwQUCgwKBQQBAgAFEgMLBAoKDAoFBAECAAESAwsLDwoMCgUEAQIAAxIDCxITCgsKBAQBAgESAwwEFwoMCgUEAQIBBRIDDAQKCgwKBQQBAgEBEgMMCxIKDAoFBAECAQMSAwwVFgoLCgQEAQICEgMNBCUKDAoFBAECAgYSAw0EHQoMCgUEAQICARIDDR4gCgwKBQQBAgIDEgMNIyQKCgoCBgASBBAAEgEKCgoDBgABEgMQCBQKCwoEBgACABIDEQQ7CgwKBQYAAgABEgMRCBEKDAoFBgACAAISAxESIgoMCgUGAAIABhIDES0zCgwKBQYAAgADEgMRNDliBnByb3RvMw=='; #[Override] - public function register(Pool\Registry $pool): void + public function register(Registry\Pool $pool): void { - $pool->add(Pool\Descriptor::base64(self::DESCRIPTOR_BUFFER), [ - 'topic.api.v1.SubscribeRequest' => new Pool\MessageMetadata(\Topic\Api\V1\SubscribeRequest::class), - 'topic.api.v1.Event' => new Pool\MessageMetadata(\Topic\Api\V1\Event::class), - ]); + $pool->add(Registry\Descriptor::base64(self::DESCRIPTOR_BUFFER), new File( + name: 'tests/protos/topic_v1.proto', + dependencies: [ + 'google/protobuf/timestamp.proto', + ], + messages: [ + new File\MessageDescriptor('topic.api.v1.SubscribeRequest', \Topic\Api\V1\SubscribeRequest::class), + new File\MessageDescriptor('topic.api.v1.Event', \Topic\Api\V1\Event::class), + ], + services: [ + new File\ServiceDescriptor( + name: 'topic.api.v1.TopicService', + methods: [ + new File\MethodDescriptor('Subscribe', false, true), + ], + ), + ], + )); } } diff --git a/tests/genproto/Topic/Api/V1/TopicServiceClient.php b/tests/genproto/Topic/Api/V1/TopicServiceClient.php index 8d9f8c8..103c966 100644 --- a/tests/genproto/Topic/Api/V1/TopicServiceClient.php +++ b/tests/genproto/Topic/Api/V1/TopicServiceClient.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/topic_v1.proto */ diff --git a/tests/genproto/Topic/Api/V1/TopicServiceServer.php b/tests/genproto/Topic/Api/V1/TopicServiceServer.php index 87d3d0e..40831ac 100644 --- a/tests/genproto/Topic/Api/V1/TopicServiceServer.php +++ b/tests/genproto/Topic/Api/V1/TopicServiceServer.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/topic_v1.proto */ diff --git a/tests/genproto/Topic/Api/V1/TopicServiceServerRegistry.php b/tests/genproto/Topic/Api/V1/TopicServiceServerRegistry.php index ca37811..94c8b4e 100644 --- a/tests/genproto/Topic/Api/V1/TopicServiceServerRegistry.php +++ b/tests/genproto/Topic/Api/V1/TopicServiceServerRegistry.php @@ -3,7 +3,7 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 * Source: tests/protos/topic_v1.proto */ diff --git a/tests/genproto/Topic/Api/V1/autoload.metadata.php b/tests/genproto/Topic/Api/V1/autoload.metadata.php index 9db84bb..9a9032b 100644 --- a/tests/genproto/Topic/Api/V1/autoload.metadata.php +++ b/tests/genproto/Topic/Api/V1/autoload.metadata.php @@ -3,12 +3,12 @@ /** * Code generated by thesis/protoc-plugin. DO NOT EDIT. * Versions: - * thesis/protoc-plugin — v0.1.11 + * thesis/protoc-plugin — v0.1.19 * protoc — v6.33.5 */ declare(strict_types=1); -\Thesis\Protobuf\Pool\Registry::get()->register( - new \Thesis\Protobuf\Pool\OnceRegistrar(new \Topic\Api\V1\TestsProtosTopicV1DescriptorRegistry()), +\Thesis\Protobuf\Registry\Pool::get()->register( + new \Thesis\Protobuf\Registry\OnceRegistrar(new \Topic\Api\V1\TestsProtosTopicV1DescriptorRegistry()), );