-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
91 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of Swoft. | ||
* | ||
* @link https://swoft.org | ||
* @document https://swoft.org/docs | ||
* @contact [email protected] | ||
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Swoft\Limiter\Annotation\Mapping; | ||
|
||
|
@@ -157,4 +164,4 @@ public function getDefault(): int | |
{ | ||
return $this->default; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of Swoft. | ||
* | ||
* @link https://swoft.org | ||
* @document https://swoft.org/docs | ||
* @contact [email protected] | ||
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Swoft\Limiter\Annotation\Parser; | ||
|
||
|
||
use Swoft\Annotation\Annotation\Mapping\AnnotationParser; | ||
use Swoft\Annotation\Annotation\Parser\Parser; | ||
use Swoft\Limiter\Annotation\Mapping\RateLimiter; | ||
use Swoft\Limiter\Exception\RateLImiterException; | ||
use Swoft\Limiter\RateLimiterRegister; | ||
|
||
|
||
/** | ||
* Class RateLimiterParser | ||
* | ||
|
@@ -36,4 +41,4 @@ public function parse(int $type, $annotationObject): array | |
RateLimiterRegister::registerRateLimiter($this->className, $this->methodName, $annotationObject); | ||
return []; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of Swoft. | ||
* | ||
* @link https://swoft.org | ||
* @document https://swoft.org/docs | ||
* @contact [email protected] | ||
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Swoft\Limiter\Aspect; | ||
|
||
|
||
use Swoft\Aop\Annotation\Mapping\Around; | ||
use Swoft\Aop\Annotation\Mapping\Aspect; | ||
use Swoft\Aop\Annotation\Mapping\PointAnnotation; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* This file is part of Swoft. | ||
* | ||
* @link https://swoft.org | ||
* @document https://swoft.org/docs | ||
* @contact [email protected] | ||
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Swoft\Limiter; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of Swoft. | ||
* | ||
* @link https://swoft.org | ||
* @document https://swoft.org/docs | ||
* @contact [email protected] | ||
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Swoft\Limiter\Contract; | ||
|
||
|
@@ -16,4 +23,4 @@ interface RateLimiterInterface | |
* @return bool | ||
*/ | ||
public function getTicket(array $config): bool; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of Swoft. | ||
* | ||
* @link https://swoft.org | ||
* @document https://swoft.org/docs | ||
* @contact [email protected] | ||
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Swoft\Limiter\Exception; | ||
|
||
|
@@ -12,5 +19,4 @@ | |
*/ | ||
class RateLImiterException extends Exception | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of Swoft. | ||
* | ||
* @link https://swoft.org | ||
* @document https://swoft.org/docs | ||
* @contact [email protected] | ||
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Swoft\Limiter\Rate; | ||
|
||
|
||
use Swoft\Limiter\Contract\RateLimiterInterface; | ||
|
||
/** | ||
|
@@ -13,5 +19,4 @@ | |
*/ | ||
abstract class AbstractRateLimiter implements RateLimiterInterface | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of Swoft. | ||
* | ||
* @link https://swoft.org | ||
* @document https://swoft.org/docs | ||
* @contact [email protected] | ||
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Swoft\Limiter\Rate; | ||
|
||
|
@@ -120,4 +127,4 @@ private function getStorekey(string $name, string $key): string | |
{ | ||
return sprintf('%s:%s:store', $name, $key); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of Swoft. | ||
* | ||
* @link https://swoft.org | ||
* @document https://swoft.org/docs | ||
* @contact [email protected] | ||
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Swoft\Limiter; | ||
|
||
|
||
use Swoft\Limiter\Annotation\Mapping\RateLimiter; | ||
use Swoft\Limiter\Exception\RateLImiterException; | ||
|
||
|
@@ -35,8 +41,11 @@ class RateLimiterRegister | |
public static function registerRateLimiter(string $className, string $method, RateLimiter $rateLimiter): void | ||
{ | ||
if (isset(self::$rateLimiters[$className][$method])) { | ||
throw new RateLImiterException(sprintf('`@RateLImiter` must be only one on method(%s->%s)!', $className, | ||
$method)); | ||
throw new RateLImiterException(sprintf( | ||
'`@RateLImiter` must be only one on method(%s->%s)!', | ||
$className, | ||
$method | ||
)); | ||
} | ||
|
||
$rlConfig = []; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of Swoft. | ||
* | ||
* @link https://swoft.org | ||
* @document https://swoft.org/docs | ||
* @contact [email protected] | ||
* @license https://github.com/swoft-cloud/swoft/blob/master/LICENSE | ||
*/ | ||
|
||
namespace Swoft\Limiter; | ||
|
||
|