spiral / roadrunner-bridge

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

Adding the ability to define default options in the pipeline config #65

Closed msmakouz closed 1 year ago

msmakouz commented 1 year ago

Psalm error will be fixed after merging and releasing this: https://github.com/spiral/roadrunner-jobs/pull/39

Default options

Added the ability to configure default options in the pipeline configuration. Via Spiral\Queue\Options:

// file app/app/config/queue.php 
use Spiral\Queue\Options;
use Spiral\RoadRunner\Jobs\Queue\MemoryCreateInfo;

return [
    'connections' => [
        'roadrunner' => [
            'driver' => 'roadrunner',
            'default' => 'memory',
            'pipelines' => [
                'memory' => [
                    'connector' => new MemoryCreateInfo('local'),
                    'consume' => true,
                    'options' => (new Options())->withDelay(5),
                ],
            ],
        ],
    ],
];

Via Spiral\RoadRunner\Jobs\Options or Spiral\RoadRunner\Jobs\KafkaOptions:

// file app/app/config/queue.php 
use Spiral\RoadRunner\Jobs\KafkaOptions;
use Spiral\RoadRunner\Jobs\Queue\KafkaCreateInfo;

return [
    'connections' => [
        'roadrunner' => [
            'driver' => 'roadrunner',
            'default' => 'kafka',
            'pipelines' => [
                'kafka' => [
                    'connector' => new KafkaCreateInfo(
                        name:'test-kafka',
                        topic: 'from-create-info'
                    ),
                    'options' => new KafkaOptions(
                        topic: 'some-topic',
                        priority: 5
                    ),
                    'consume' => true,
                ],
            ],
        ],
    ],
];
codecov[bot] commented 1 year ago

Codecov Report

Base: 91.79% // Head: 91.85% // Increases project coverage by +0.06% :tada:

Coverage data is based on head (419c695) compared to base (78d3418). Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## 2.0 #65 +/- ## ============================================ + Coverage 91.79% 91.85% +0.06% - Complexity 317 318 +1 ============================================ Files 62 62 Lines 999 1007 +8 ============================================ + Hits 917 925 +8 Misses 82 82 ``` | [Impacted Files](https://codecov.io/gh/spiral/roadrunner-bridge/pull/65?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=spiral) | Coverage Δ | | |---|---|---| | [src/Queue/OptionsFactory.php](https://codecov.io/gh/spiral/roadrunner-bridge/pull/65?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=spiral#diff-c3JjL1F1ZXVlL09wdGlvbnNGYWN0b3J5LnBocA==) | `100.00% <100.00%> (ø)` | | | [src/Queue/RPCPipelineRegistry.php](https://codecov.io/gh/spiral/roadrunner-bridge/pull/65?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=spiral#diff-c3JjL1F1ZXVlL1JQQ1BpcGVsaW5lUmVnaXN0cnkucGhw) | `97.14% <100.00%> (+0.17%)` | :arrow_up: | 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.