bedelightful / async-event
Async event
Installs: 0
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/bedelightful/async-event
Requires
- php: >=7.4
- ext-json: *
- hyperf/config: *
- hyperf/crontab: *
- hyperf/db-connection: ^3.1.63
- hyperf/di: 3.1.65
- hyperf/event: *
- hyperf/framework: *
- hyperf/logger: ^3.1.63
- hyperf/redis: *
- hyperf/snowflake: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: >=7.0
- swoole/ide-helper: ^4.5
Suggests
- swow/swow: Required to create swow components.
This package is auto-updated.
Last update: 2026-01-14 18:08:30 UTC
README
- Events will be placed into a coroutine and then executed in sequence
- Core code is
\BeDelightful\AsyncEvent\AsyncEventDispatcher::dispatch
Installation
- Install
composer require bedelightful/async-event
- Publish configuration
php bin/hyperf.php vendor:publish bedelightful/async-event
- Run database migration
php bin/hyperf.php migrate
Usage
- To avoid affecting existing logic, use the new dispatcher
demo
<?php declare(strict_types=1); /** * Copyright (c) Be Delightful , Distributed under the MIT software license */ namespace App\Controller; use App\Event\DemoEvent; use Hyperf\Di\Annotation\Inject; use BeDelightful\AsyncEvent\AsyncEventDispatcher; class IndexController extends AbstractController { /** * @Inject() */ protected AsyncEventDispatcher $asyncEventDispatcher; public function index() { $user = $this->request->input('user', 'Hyperf'); $method = $this->request->getMethod(); $this->asyncEventDispatcher->dispatch(new DemoEvent([123,222], 9)); return [ 'method' => $method, 'message' => "Hello {$user}.", ]; } }
- When the maximum execution count is reached, you can send message notifications, but you need to add configuration yourself. This project only provides the maximum retry event
Notes
- Try to avoid using coroutine context to pass data in events, as events are asynchronous and may cause data inconsistency