spiral / roadrunner-bridge

🌉 RoadRunner bridge to Spiral Framework
https://spiral.dev/docs/packages-roadrunner-bridge
MIT License
13 stars 6 forks source link

Add proto file repository #49

Closed meekstellar closed 1 year ago

meekstellar commented 1 year ago

After the PR developers will have an ability to use repositories for looking for proto files.

By default, generator will look for proto files using Spiral\RoadRunnerBridge\GRPC\ProtoRepository\FileRepository in local folder.

You can extend a behavior and change the place where to look for list of proto files, for example, create a repository like RRConfigProtoFilesRepository, or BufProtoFilesRepository

There is complete example of how to use proto files repositories:

<?php

declare(strict_types=1);

namespace App\Bootloader;

use Spiral\RoadRunnerBridge\GRPC\ProtoRepository\CompositeRepository;
use Spiral\RoadRunnerBridge\GRPC\ProtoRepository\ProtoFilesRepositoryInterface;
use App\GRPC\ProtoRepository\RRConfigProtoFilesRepository;
use App\GRPC\ProtoRepository\BufProtoFilesRepository;

final class AppBootloaderextends Bootloader
{
    protected const SINGLETONS = [
        ProtoFilesRepositoryInterface::class => [self::class, 'initProtoFilesRepository'],
    ];

    private function initProtoFilesRepository(): ProtoFilesRepositoryInterface
    {
        return new CompositeRepository(
            new RRConfigProtoFilesRepository($pathToRRConfig),
            new BufRepository([
                  'https://buf.build/roadrunner-server/api/file/main:proto/shared/status.proto'   
            ]),
        );
    }
}
codecov[bot] commented 1 year ago

Codecov Report

Base: 89.52% // Head: 89.68% // Increases project coverage by +0.15% :tada:

Coverage data is based on head (4f9b37c) compared to base (efe1901). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## 2.0 #49 +/- ## ============================================ + Coverage 89.52% 89.68% +0.15% - Complexity 262 268 +6 ============================================ Files 53 55 +2 Lines 659 669 +10 ============================================ + Hits 590 600 +10 Misses 69 69 ``` | [Impacted Files](https://codecov.io/gh/spiral/roadrunner-bridge/pull/49?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=spiral) | Coverage Δ | | |---|---|---| | [src/Bootloader/GRPCBootloader.php](https://codecov.io/gh/spiral/roadrunner-bridge/pull/49/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=spiral#diff-c3JjL0Jvb3Rsb2FkZXIvR1JQQ0Jvb3Rsb2FkZXIucGhw) | `78.26% <100.00%> (+2.07%)` | :arrow_up: | | [src/Console/Command/GRPC/GenerateCommand.php](https://codecov.io/gh/spiral/roadrunner-bridge/pull/49/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=spiral#diff-c3JjL0NvbnNvbGUvQ29tbWFuZC9HUlBDL0dlbmVyYXRlQ29tbWFuZC5waHA=) | `67.56% <100.00%> (ø)` | | | [src/GRPC/ProtoRepository/CompositeRepository.php](https://codecov.io/gh/spiral/roadrunner-bridge/pull/49/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=spiral#diff-c3JjL0dSUEMvUHJvdG9SZXBvc2l0b3J5L0NvbXBvc2l0ZVJlcG9zaXRvcnkucGhw) | `100.00% <100.00%> (ø)` | | | [src/GRPC/ProtoRepository/FileRepository.php](https://codecov.io/gh/spiral/roadrunner-bridge/pull/49/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=spiral#diff-c3JjL0dSUEMvUHJvdG9SZXBvc2l0b3J5L0ZpbGVSZXBvc2l0b3J5LnBocA==) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=spiral). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=spiral)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

butschster commented 1 year ago

@kastahov Could you add some description with examples of usage?