Skip to content

Commit 02ce0d4

Browse files
authored
Improve trigger config (#813)
* Improve trigger config * refactor(trigger): simplify Config class and remove dependency on Hyperf\Config * feat(trigger): add has() method to Config class for key existence check * fix(trigger): update subscribers method docblock for correct namespace * Update Config.php --------- Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com>
1 parent e99c012 commit 02ce0d4

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/Config.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@
1111

1212
namespace FriendsOfHyperf\Trigger;
1313

14-
class Config extends \Hyperf\Config\Config
14+
use Hyperf\Collection\Arr;
15+
16+
class Config
1517
{
18+
public function __construct(private array $configs = [])
19+
{
20+
}
21+
22+
public function get(string $key, mixed $default = null): mixed
23+
{
24+
return Arr::get($this->configs, $key, $default);
25+
}
26+
27+
public function has(string $key): bool
28+
{
29+
return Arr::has($this->configs, $key);
30+
}
1631
}

src/Consumer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use FriendsOfHyperf\Trigger\Monitor\HealthMonitor;
1515
use FriendsOfHyperf\Trigger\Mutex\ServerMutexInterface;
1616
use FriendsOfHyperf\Trigger\Snapshot\BinLogCurrentSnapshotInterface;
17-
use Hyperf\Config\Config;
1817
use Hyperf\Coordinator\Constants;
1918
use Hyperf\Coordinator\CoordinatorManager;
2019
use Hyperf\Coroutine\Coroutine;

0 commit comments

Comments
 (0)