Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First version #1

Merged
merged 5 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/codesniffer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: PHP code sniffer

on:
push:
branches:
- master
pull_request: null

jobs:
codesniffer:
runs-on: ubuntu-latest
name: PHP code sniffer

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Composer update
run: composer update --no-progress --no-interaction

- name: Install PHP code sniffer as dev dependency
run: composer require squizlabs/php_codesniffer --dev

- name: Code sniffer
run: vendor/bin/phpcs src --standard=PSR2 -n
32 changes: 32 additions & 0 deletions .github/workflows/composer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Composer outdated

on:
push:
branches:
- master
pull_request: null

jobs:
composer:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1' ]

name: Composer outdated - PHP ${{ matrix.php }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}

- name: Composer update
run: composer update --no-progress --no-interaction

- name: Composer outdated
run: composer outdated -D --strict
25 changes: 25 additions & 0 deletions .github/workflows/extensions_finder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: PHP extensions finder

on:
push:
branches:
- master
pull_request: null

jobs:
extensions_finder:
runs-on: ubuntu-latest
name: PHP extensions finder

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Composer update
run: composer update --no-progress --no-interaction

- name: Install PHP extensions finder as dev dependency
run: composer require efabrica/php-extensions-finder --dev

- name: PHP extensions finder
run: vendor/bin/php-extensions-finder check src
36 changes: 36 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: PHP static analysis

on:
push:
branches:
- master
pull_request: null

jobs:
phpstan:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1' ]

name: PHPStan - PHP ${{ matrix.php }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none # disable xdebug, pcov

- name: Composer update
run: composer update --no-progress --no-interaction

- name: Install PHPStan as dev dependency
run: composer require phpstan/phpstan --dev

- name: PHPStan analyse
run: vendor/bin/phpstan analyze src --level=max --no-progress
36 changes: 36 additions & 0 deletions .github/workflows/phpstan_lowest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: PHP static analysis with lowest dependencies

on:
push:
branches:
- master
pull_request: null

jobs:
phpstan:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1' ]

name: PHPStan with lowest dependencies - PHP ${{ matrix.php }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none # disable xdebug, pcov

- name: Composer update
run: composer update --prefer-lowest --no-progress --no-interaction

- name: Install PHPStan as dev dependency
run: composer require phpstan/phpstan --dev

- name: PHPStan analyse
run: vendor/bin/phpstan analyze src --level=max --no-progress
30 changes: 30 additions & 0 deletions .github/workflows/syntax_checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: PHP syntax checker

on:
push:
branches:
- master
pull_request: null

jobs:
syntax_checker:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '7.4', '8.0', '8.1' ]

name: PHP syntax checker - PHP ${{ matrix.php }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none # disable xdebug, pcov

- name: Check syntax
run: find src -name "*.php" -print0 | xargs -0 -n1 -P8 php -l
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/vendor
/composer.lock
/.idea
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Change Log

## [Unreleased][unreleased]

### Added
- HermesWorker (symfony command)
- RedisProxySetDriver (driver implementation using RedisProxy)
- RedisProxySortedSetDriver
- DummyDriver (for testing purposes)

[unreleased]: https://github.com/efabrica-team/hermes-extension/compare/8b055557b0c87b5c52961cf2bfa13340e50915ad...HEAD
17 changes: 17 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "efabrica/hermes-extension",
"description": "Extension for tomaj/hermes",
"keywords": ["worker", "driver", "redis-proxy"],
"license": "MIT",
"require": {
"php": ">= 7.4 < 8.2",
"tomaj/hermes": "^4.0",
"lulco/redis-proxy": "dev-master as 1.0.0",
"symfony/console": "^5.4 | ^6.0"
},
"autoload": {
"psr-4": {
"Efabrica\\HermesExtension\\": "src/"
}
}
}
33 changes: 33 additions & 0 deletions src/Command/HermesWorker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace Efabrica\HermesExtension\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Tomaj\Hermes\DispatcherInterface;

final class HermesWorker extends Command
{
private DispatcherInterface $dispatcher;

public function __construct(DispatcherInterface $dispatcher, string $name = 'hermes:worker')
{
parent::__construct($name);
$this->dispatcher = $dispatcher;
}

protected function configure(): void
{
$this->setDescription('Handle hermes messages');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->dispatcher->handle();
$output->writeln('Hermes worker end.');
return self::SUCCESS;
}
}
28 changes: 28 additions & 0 deletions src/Driver/DummyDriver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

declare(strict_types=1);

namespace Efabrica\HermesExtension\Driver;

use Closure;
use Tomaj\Hermes\Dispatcher;
use Tomaj\Hermes\Driver\DriverInterface;
use Tomaj\Hermes\MessageInterface;

final class DummyDriver implements DriverInterface
{
public function send(MessageInterface $message, int $priority = Dispatcher::DEFAULT_PRIORITY): bool
{
return true;
}

public function wait(Closure $callback, array $priorities = []): void
{
// do nothing
}

public function setupPriorityQueue(string $name, int $priority): void
{
// do nothing
}
}
Loading