Skip to content

Commit

Permalink
perf: Timer add log (#410)
Browse files Browse the repository at this point in the history
* perf: Timer add log

* Remove unused import and refactor constructor.

* Refactor Confd constructor to use one-line syntax

---------

Co-authored-by: greezen <[email protected]>
Co-authored-by: Deeka Wong <[email protected]>
  • Loading branch information
3 people committed Nov 8, 2023
1 parent c9bf856 commit fae8cc6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/confd/src/Confd.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use FriendsOfHyperf\Confd\Event\WatchDispatched;
use Hyperf\Collection\Arr;
use Hyperf\Contract\ConfigInterface;
use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Coordinator\Timer;
use Psr\Container\ContainerInterface;
use Psr\EventDispatcher\EventDispatcherInterface;
Expand All @@ -37,7 +38,11 @@ public function __construct(private ContainerInterface $container, private Confi
$class = $this->config->get(sprintf('confd.drivers.%s.driver', $driver), Etcd::class);
$this->driver = $container->get($class);
$this->interval = (int) $this->config->get('confd.interval', 1);
$this->timer = new Timer();
$logger = null;
if ($container->has(StdoutLoggerInterface::class)) {
$logger = $container->get(StdoutLoggerInterface::class);
}
$this->timer = new Timer($logger);
}

public function fetch(): array
Expand Down

0 comments on commit fae8cc6

Please sign in to comment.