Skip to content

Commit

Permalink
Improve trigger config (#813)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
huangdijia and huangdijia authored Dec 27, 2024
1 parent ee2b2e0 commit 14be4cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/trigger/src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@

namespace FriendsOfHyperf\Trigger;

class Config extends \Hyperf\Config\Config
use Hyperf\Collection\Arr;

class Config
{
public function __construct(private array $configs = [])
{
}

public function get(string $key, mixed $default = null): mixed
{
return Arr::get($this->configs, $key, $default);
}

public function has(string $key): bool
{
return Arr::has($this->configs, $key);
}
}
1 change: 0 additions & 1 deletion src/trigger/src/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use FriendsOfHyperf\Trigger\Monitor\HealthMonitor;
use FriendsOfHyperf\Trigger\Mutex\ServerMutexInterface;
use FriendsOfHyperf\Trigger\Snapshot\BinLogCurrentSnapshotInterface;
use Hyperf\Config\Config;
use Hyperf\Coordinator\Constants;
use Hyperf\Coordinator\CoordinatorManager;
use Hyperf\Coroutine\Coroutine;
Expand Down

0 comments on commit 14be4cc

Please sign in to comment.