Skip to content

Commit

Permalink
Make maxBodySize nullable
Browse files Browse the repository at this point in the history
Symfony was updated to 4 to be able to use default env var processor, that was introduced in Symfony 4.3.
  • Loading branch information
fabianaromagnoli committed Apr 26, 2024
1 parent 96f3fbf commit d662906
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 22 deletions.
1 change: 0 additions & 1 deletion .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ 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
ESB_HTTP_SERVER_MAX_BODY_SIZE=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
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
19 changes: 10 additions & 9 deletions esb.yml.sample
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
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
http_server_max_body_size: '%env(default::int:ESB_HTTP_SERVER_MAX_BODY_SIZE)%' # HTTP Server max body size
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
8 changes: 5 additions & 3 deletions services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ services:

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 @@ -76,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 @@ -85,5 +86,6 @@ services:
Symfony\Component\Serializer\Normalizer\DenormalizerInterface: '@serializer'

Webgriffe\Esb\Service\ElasticSearch:
public: true
arguments:
$normalizer: '@serializer'
2 changes: 1 addition & 1 deletion services_test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
parameters:
beanstalkd: '%env(string:ESB_BEANSTALKD_URL)%'
http_server_port: '%env(int:ESB_HTTP_SERVER_PORT)%'
http_server_max_body_size: '%env(ESB_HTTP_SERVER_MAX_BODY_SIZE)%'
http_server_max_body_size: '%env(default::int:ESB_HTTP_SERVER_MAX_BODY_SIZE)%'
logger_mail_to: "[email protected]"
logger_mail_from: "From Name <[email protected]>"
console_port: '%env(int:ESB_CONSOLE_PORT)%'
Expand Down
11 changes: 7 additions & 4 deletions src/Service/HttpProducersServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ class HttpProducersServer
private $httpServer;

/**
* @var int
* @var int|null
*/
private $maxBodySize;

public function __construct(int $port, LoggerInterface $logger, int $maxBodySize)
public function __construct(int $port, LoggerInterface $logger, ?int $maxBodySize)
{
$this->port = $port;
$this->logger = $logger;
Expand All @@ -66,8 +66,11 @@ public function start(): Promise
Socket\listen("[::]:{$this->port}"),
];

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

$this->httpServer = new HttpServer(
$sockets,
Expand Down

0 comments on commit d662906

Please sign in to comment.