Skip to content

Commit

Permalink
Fix the bug that cannot work in process mode (#345)
Browse files Browse the repository at this point in the history
* Fix the bug that cannot work in process mode

* Format
  • Loading branch information
huangdijia committed Sep 21, 2023
1 parent 59b6397 commit 8faad26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ composer require friendsofhyperf/trigger
php bin/hyperf.php vendor:publish friendsofhyperf/trigger
```

## Add listener

```php
// config/autoload/listeners.php

return [
FriendsOfHyperf\Trigger\Listener\BindTriggerProcessesListener::class => PHP_INT_MAX,
];
```

## Define a trigger

```php
Expand Down
6 changes: 3 additions & 3 deletions src/Listener/BindTriggerProcessesListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use FriendsOfHyperf\Trigger\SubscriberManager;
use FriendsOfHyperf\Trigger\TriggerManager;
use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\Framework\Event\MainWorkerStart;
use Hyperf\Framework\Event\BeforeMainServerStart;
use Hyperf\Server\Event\MainCoroutineServerStart;

class BindTriggerProcessesListener implements ListenerInterface
Expand All @@ -30,13 +30,13 @@ public function __construct(
public function listen(): array
{
return [
MainWorkerStart::class,
BeforeMainServerStart::class,
MainCoroutineServerStart::class,
];
}

/**
* @param MainWorkerStart|MainCoroutineServerStart $event
* @param BeforeMainServerStart|MainCoroutineServerStart $event
*/
public function process(object $event): void
{
Expand Down

0 comments on commit 8faad26

Please sign in to comment.