init
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\TestModuleWebapiBackpressure\Model;
|
||||
|
||||
use Magento\Framework\App\Backpressure\ContextInterface;
|
||||
use Magento\Framework\App\Backpressure\SlidingWindow\LimitConfig;
|
||||
use Magento\Framework\App\Backpressure\SlidingWindow\LimitConfigManagerInterface;
|
||||
|
||||
class LimitConfigManager implements LimitConfigManagerInterface
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function readLimit(ContextInterface $context): LimitConfig
|
||||
{
|
||||
return new LimitConfig(2, 60);
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\TestModuleWebapiBackpressure\Model;
|
||||
|
||||
use Magento\TestModuleWebapiBackpressure\Api\TestReadServiceInterface;
|
||||
|
||||
class TestReadService implements TestReadServiceInterface
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private int $counter = 0;
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function read(): string
|
||||
{
|
||||
$this->counter++;
|
||||
|
||||
return 'read';
|
||||
}
|
||||
|
||||
public function resetCounter(): void
|
||||
{
|
||||
$this->counter = 0;
|
||||
}
|
||||
|
||||
public function getCounter(): int
|
||||
{
|
||||
return $this->counter;
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\TestModuleWebapiBackpressure\Model;
|
||||
|
||||
use Magento\Framework\Webapi\Backpressure\BackpressureRequestTypeExtractorInterface;
|
||||
use Magento\TestModuleWebapiBackpressure\Api\TestReadServiceInterface;
|
||||
|
||||
class TypeExtractor implements BackpressureRequestTypeExtractorInterface
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function extract(string $service, string $method, string $endpoint): ?string
|
||||
{
|
||||
if ($service == TestReadServiceInterface::class) {
|
||||
return 'testwebapibackpressure';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user