This commit is contained in:
2026-09-15 10:26:34 +08:00
commit ecf36afa56
10493 changed files with 1404888 additions and 0 deletions
@@ -0,0 +1,17 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\TestModuleWebapiBackpressure\Api;
interface TestReadServiceInterface
{
/**
* @return string
*/
public function read(): string;
}
@@ -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);
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -0,0 +1,21 @@
{
"name": "magento/module-test-webapi-backpressure",
"description": "test webapi module",
"config": {
"sort-packages": true
},
"require": {
"php": "~7.4.0||~8.0.0",
"magento/framework": "*",
"magento/module-integration": "*"
},
"type": "magento2-module",
"extra": {
"map": [
[
"*",
"Magento/TestModuleWebapiBackpressure"
]
]
}
}
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\TestModuleWebapiBackpressure\Api\TestReadServiceInterface"
type="Magento\TestModuleWebapiBackpressure\Model\TestReadService" />
<type name="Magento\Framework\Webapi\Backpressure\CompositeRequestTypeExtractor">
<arguments>
<argument name="extractors" xsi:type="array">
<item name="webapitestbackpressure" xsi:type="object">
Magento\TestModuleWebapiBackpressure\Model\TypeExtractor
</item>
</argument>
</arguments>
</type>
<type name="Magento\Framework\App\Backpressure\SlidingWindow\CompositeLimitConfigManager">
<arguments>
<argument name="configs" xsi:type="array">
<item name="testwebapibackpressure" xsi:type="object">
Magento\TestModuleWebapiBackpressure\Model\LimitConfigManager
</item>
</argument>
</arguments>
</type>
</config>
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_TestModuleWebapiBackpressure" />
</config>
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="moduletestwebapiback" frontName="moduletestwebapiback">
<module name="Magento_TestModuleWebapiBackpressure" />
</route>
</router>
</config>
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
<route url="/V1/test-module-webapi-backpressure/read" method="GET">
<service class="Magento\TestModuleWebapiBackpressure\Api\TestReadServiceInterface" method="read"/>
<resources>
<resource ref="anonymous" />
</resources>
</route>
</routes>
@@ -0,0 +1,13 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
use Magento\Framework\Component\ComponentRegistrar;
$registrar = new ComponentRegistrar();
if ($registrar->getPath(ComponentRegistrar::MODULE, 'Magento_TestModuleWebapiBackpressure') === null) {
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestModuleWebapiBackpressure', __DIR__);
}