Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow higher max body size #31

Merged
merged 5 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ESB_BEANSTALKD_URL=tcp://beanstalkd:11300
ESB_CONSOLE_PORT=8080
# ESB_HTTP_SERVER is the port for the ESB's HTTP request producers
ESB_HTTP_SERVER_PORT=34981
#ESB_HTTP_SERVER_MAX_BODY_SIZE is an optional parameter. You shoud set it if you need a value larger then default, that is 10485760

# MAILHOG_WEB_PORT_HOST is the host's port binding of the MailHog 8025 web UI server port
MAILHOG_WEB_PORT_HOST=8025
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
env:
ESB_CONSOLE_PORT: 8080
ESB_HTTP_SERVER_PORT: 34981
ESB_HTTP_SERVER_MAX_BODY_SIZE: 10485760
ESB_BEANSTALKD_URL: tcp://127.0.0.1:11300
ES_BASE_URI: http://127.0.0.1:9200

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"php": "~7.4.0|~8.0.0",
"ext-pcntl": "*",
"ext-json": "*",
"symfony/dependency-injection": "^3.3",
"symfony/config": "^3.3",
"symfony/yaml": "^3.3",
"symfony/dependency-injection": "^4.3",
"symfony/config": "^4.3",
"symfony/yaml": "^4.3",
"amphp/beanstalk": "^0.3.2",
"monolog/monolog": "^1.23",
"dragonmantank/cron-expression": "^2.0",
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ services:
- "${MAILHOG_WEB_PORT_HOST}:8025"

elasticsearch:
image: "docker.elastic.co/elasticsearch/elasticsearch-oss:7.4.0"
image: "docker.elastic.co/elasticsearch/elasticsearch-oss:7.8.0"
env_file:
- .env
environment:
Expand Down
18 changes: 9 additions & 9 deletions esb.yml.sample
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
parameters:
beanstalkd: tcp://127.0.0.1:11300 # Beanstalkd connection URI
http_server_port: 34981 # HTTP Server Port
logger_mail_to: [email protected] # Email address where to send significant events mail notifications
logger_mail_from: "From Name <[email protected]>" # From name/address for significant events mail notifications
console_port: 8080 # Web console port
console_username: admin # Web console username
console_password: password # Web console password
console_log_file: /tmp/esb_console.log # Web console server log file
elasticsearch_base_uri: '%env(string:ES_BASE_URI)%' # ElasticSearch base URI (i.e. http://elasticsearch:9200)
beanstalkd: tcp://127.0.0.1:11300 # Beanstalkd connection URI
http_server_port: 34981 # HTTP Server Port
logger_mail_to: [email protected] # Email address where to send significant events mail notifications
logger_mail_from: "From Name <[email protected]>" # From name/address for significant events mail notifications
console_port: 8080 # Web console port
console_username: admin # Web console username
console_password: password # Web console password
console_log_file: /tmp/esb_console.log # Web console server log file
elasticsearch_base_uri: '%env(string:ES_BASE_URI)%' # ElasticSearch base URI (i.e. http://elasticsearch:9200)

services:
_defaults:
Expand Down
10 changes: 7 additions & 3 deletions services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,22 @@ services:
Webgriffe\Esb\Service\HttpProducersServer:
arguments:
$port: '%http_server_port%'
$logger: '@Psr\Log\LoggerInterface'
$maxBodySize: '%env(default::int:ESB_HTTP_SERVER_MAX_BODY_SIZE)%'

Monolog\Handler\StreamHandler:
class: \Monolog\Handler\StreamHandler
arguments: [ 'php://stdout', !php/const:Monolog\Logger::DEBUG ]
arguments: [ 'php://stdout', !php/const Monolog\Logger::DEBUG ]

Monolog\Handler\ErrorLogHandler:
class: \Monolog\Handler\ErrorLogHandler
arguments: [ !php/const:Monolog\Handler\ErrorLogHandler::OPERATING_SYSTEM, !php/const:Monolog\Logger::ERROR ]
arguments: [ !php/const Monolog\Handler\ErrorLogHandler::OPERATING_SYSTEM, !php/const Monolog\Logger::ERROR ]

Monolog\Formatter\HtmlFormatter: {}

Monolog\Handler\NativeMailerHandler:
class: \Monolog\Handler\NativeMailerHandler
arguments: [ '%logger_mail_to%', 'Significant event from ESB', '%logger_mail_from%', !php/const:Monolog\Logger::WARNING ]
arguments: [ '%logger_mail_to%', 'Significant event from ESB', '%logger_mail_from%', !php/const Monolog\Logger::WARNING ]
calls:
- method: setFormatter
arguments:
Expand Down Expand Up @@ -74,6 +76,7 @@ services:
$classMetadataFactory: '@serializer.class_metadata_factory'
$propertyTypeExtractor: '@serializer.object_normalizer.reflection_extractor'
serializer:
public: true
class: \Symfony\Component\Serializer\Serializer
arguments:
- ['@serializer.array_denormalizer', '@serializer.date_time_normalizer', '@serializer.object_normalizer']
Expand All @@ -83,5 +86,6 @@ services:
Symfony\Component\Serializer\Normalizer\DenormalizerInterface: '@serializer'

Webgriffe\Esb\Service\ElasticSearch:
public: true
arguments:
$normalizer: '@serializer'
18 changes: 16 additions & 2 deletions src/Service/HttpProducersServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use function Amp\call;
use Amp\CallableMaker;
use Amp\Http\Server\HttpServer;
use Amp\Http\Server\Options;
use Amp\Http\Server\Request;
use Amp\Http\Server\RequestHandler\CallableRequestHandler;
use Amp\Http\Server\Response;
Expand Down Expand Up @@ -42,10 +43,16 @@ class HttpProducersServer
*/
private $httpServer;

public function __construct(int $port, LoggerInterface $logger)
/**
* @var int|null
*/
private $maxBodySize;

public function __construct(int $port, LoggerInterface $logger, ?int $maxBodySize)
{
$this->port = $port;
$this->logger = $logger;
$this->maxBodySize = $maxBodySize;
}

/**
Expand All @@ -59,10 +66,17 @@ public function start(): Promise
Socket\listen("[::]:{$this->port}"),
];

$options = null;
if ($this->maxBodySize !== null) {
$options = new Options();
$options->withBodySizeLimit($this->maxBodySize);
}

$this->httpServer = new HttpServer(
$sockets,
new CallableRequestHandler($this->callableFromInstanceMethod('requestHandler')),
new NullLogger()
new NullLogger(),
$options
);

yield $this->httpServer->start();
Expand Down
Loading