mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-28 09:51:40 -06:00
Added package to delegate the execution of event listeners to a swoole task worker
This commit is contained in:
parent
4380b62715
commit
0dfadcbb4a
@ -30,6 +30,7 @@
|
|||||||
"mikehaertl/phpwkhtmltopdf": "^2.2",
|
"mikehaertl/phpwkhtmltopdf": "^2.2",
|
||||||
"monolog/monolog": "^1.21",
|
"monolog/monolog": "^1.21",
|
||||||
"phly/phly-event-dispatcher": "^1.0",
|
"phly/phly-event-dispatcher": "^1.0",
|
||||||
|
"phly/phly-swoole-taskworker": "^1.1",
|
||||||
"shlinkio/shlink-installer": "^1.1",
|
"shlinkio/shlink-installer": "^1.1",
|
||||||
"symfony/console": "^4.2",
|
"symfony/console": "^4.2",
|
||||||
"symfony/filesystem": "^4.2",
|
"symfony/filesystem": "^4.2",
|
||||||
|
@ -9,6 +9,11 @@ return [
|
|||||||
'swoole-http-server' => [
|
'swoole-http-server' => [
|
||||||
'host' => '0.0.0.0',
|
'host' => '0.0.0.0',
|
||||||
'process-name' => 'shlink',
|
'process-name' => 'shlink',
|
||||||
|
|
||||||
|
'options' => [
|
||||||
|
'worker_num' => 16,
|
||||||
|
'task_worker_num' => 16,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ namespace Shlinkio\Shlink;
|
|||||||
|
|
||||||
use Acelaya\ExpressiveErrorHandler;
|
use Acelaya\ExpressiveErrorHandler;
|
||||||
use Phly\EventDispatcher;
|
use Phly\EventDispatcher;
|
||||||
|
use Phly\Swoole\TaskWorker;
|
||||||
use Zend\ConfigAggregator;
|
use Zend\ConfigAggregator;
|
||||||
use Zend\Expressive;
|
use Zend\Expressive;
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ return (new ConfigAggregator\ConfigAggregator([
|
|||||||
Expressive\Swoole\ConfigProvider::class,
|
Expressive\Swoole\ConfigProvider::class,
|
||||||
ExpressiveErrorHandler\ConfigProvider::class,
|
ExpressiveErrorHandler\ConfigProvider::class,
|
||||||
EventDispatcher\ConfigProvider::class,
|
EventDispatcher\ConfigProvider::class,
|
||||||
|
TaskWorker\ConfigProvider::class,
|
||||||
Common\ConfigProvider::class,
|
Common\ConfigProvider::class,
|
||||||
Core\ConfigProvider::class,
|
Core\ConfigProvider::class,
|
||||||
CLI\ConfigProvider::class,
|
CLI\ConfigProvider::class,
|
||||||
|
@ -3,6 +3,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Shlinkio\Shlink\Core;
|
namespace Shlinkio\Shlink\Core;
|
||||||
|
|
||||||
|
use Phly\Swoole\TaskWorker\DeferredListenerDelegator;
|
||||||
use Shlinkio\Shlink\Common\IpGeolocation\IpLocationResolverInterface;
|
use Shlinkio\Shlink\Common\IpGeolocation\IpLocationResolverInterface;
|
||||||
use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory;
|
use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory;
|
||||||
|
|
||||||
@ -18,6 +19,11 @@ return [
|
|||||||
'factories' => [
|
'factories' => [
|
||||||
EventDispatcher\LocateShortUrlVisit::class => ConfigAbstractFactory::class,
|
EventDispatcher\LocateShortUrlVisit::class => ConfigAbstractFactory::class,
|
||||||
],
|
],
|
||||||
|
'delegators' => [
|
||||||
|
EventDispatcher\LocateShortUrlVisit::class => [
|
||||||
|
DeferredListenerDelegator::class,
|
||||||
|
],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
ConfigAbstractFactory::class => [
|
ConfigAbstractFactory::class => [
|
||||||
|
@ -3,7 +3,9 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Shlinkio\Shlink\Core\EventDispatcher;
|
namespace Shlinkio\Shlink\Core\EventDispatcher;
|
||||||
|
|
||||||
final class ShortUrlVisited
|
use JsonSerializable;
|
||||||
|
|
||||||
|
final class ShortUrlVisited implements JsonSerializable
|
||||||
{
|
{
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $visitId;
|
private $visitId;
|
||||||
@ -17,4 +19,9 @@ final class ShortUrlVisited
|
|||||||
{
|
{
|
||||||
return $this->visitId;
|
return $this->visitId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function jsonSerialize(): array
|
||||||
|
{
|
||||||
|
return ['visitId' => $this->visitId];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,14 +25,7 @@ final class UnknownVisitLocation implements VisitLocationInterface
|
|||||||
return 'Unknown';
|
return 'Unknown';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function jsonSerialize(): array
|
||||||
* Specify data which should be serialized to JSON
|
|
||||||
* @link https://php.net/manual/en/jsonserializable.jsonserialize.php
|
|
||||||
* @return mixed data which can be serialized by <b>json_encode</b>,
|
|
||||||
* which is a value of any type other than a resource.
|
|
||||||
* @since 5.4.0
|
|
||||||
*/
|
|
||||||
public function jsonSerialize()
|
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'countryCode' => 'Unknown',
|
'countryCode' => 'Unknown',
|
||||||
|
Loading…
Reference in New Issue
Block a user