Skip to content

Commit

Permalink
feat: Refactor LockInterface and AbstractLock to handle lock time…
Browse files Browse the repository at this point in the history
…outs

The code changes in `LockInterface.php` and `AbstractLock.php` refactor the lock functionality to handle lock timeouts. This includes adding a `LockTimeoutException` and updating the `block` method to throw this exception when the lock cannot be acquired within the specified time. This change improves the reliability and error handling of the lock mechanism.

Note: This message has been generated based on the provided code changes and recent commits.
  • Loading branch information
huangdijia committed Aug 7, 2024
1 parent 65528d7 commit 17e39c2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/lock/src/Driver/AbstractLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public function get(?callable $callback = null)
/**
* Attempt to acquire the lock for the given number of seconds.
* {@inheritdoc}
* @throws LockTimeoutException
*/
#[Override]
public function block(int $seconds, ?callable $callback = null)
Expand Down
3 changes: 3 additions & 0 deletions src/lock/src/Driver/LockInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace FriendsOfHyperf\Lock\Driver;

use FriendsOfHyperf\Lock\Exception\LockTimeoutException;

interface LockInterface
{
/**
Expand All @@ -27,6 +29,7 @@ public function get(?callable $callback = null);
* @template T
* @param (callable(): T)|null $callback
* @return ($callback is null ? bool : T)
* @throws LockTimeoutException
*/
public function block(int $seconds, ?callable $callback = null);

Expand Down

0 comments on commit 17e39c2

Please sign in to comment.