Skip to content

Commit

Permalink
Adiciona postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Ferreira authored and Diego Ferreira committed Aug 19, 2023
1 parent 6420912 commit 03edc0a
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 13 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \

# update
RUN set -ex \
&& apk --no-cache add \
&& apk add php82-pdo_pgsql \
# show php version and extensions
&& php -v \
&& php -m \
Expand Down
13 changes: 13 additions & 0 deletions app/Process/AsyncQueueConsumer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace App\Process;

use Hyperf\AsyncQueue\Process\ConsumerProcess;
use Hyperf\Process\Annotation\Process;

#[Process(name: "async-queue")]
class AsyncQueueConsumer extends ConsumerProcess
{
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"hyperf/command": "^3.0",
"hyperf/config": "^3.0",
"hyperf/database": "^3.0",
"hyperf/database-pgsql": "^3.0",
"hyperf/db-connection": "^3.0",
"hyperf/framework": "^3.0",
"hyperf/guzzle": "^3.0",
Expand Down
61 changes: 59 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions config/autoload/async_queue.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
<?php

use Hyperf\AsyncQueue\Driver\RedisDriver;

return [
'default' => [
'driver' => Hyperf\AsyncQueue\Driver\RedisDriver::class,
'channel' => 'queue',
'driver' => RedisDriver::class,
'redis' => [
'pool' => 'default',
],
'channel' => '{queue}',
'timeout' => 2,
'retry_seconds' => 5,
'processes' => 1,
'handle_timeout' => 10,
'processes' => 2,
'concurrent' => [
'limit' => 1,
],
],
];
6 changes: 2 additions & 4 deletions config/autoload/databases.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@
'port' => env('DB_PORT', 3306),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
'prefix' => env('DB_PREFIX', ''),
'pool' => [
'min_connections' => 1,
'max_connections' => 1000000,
'max_connections' => 1000,
'connect_timeout' => 10.0,
'wait_timeout' => 10.0,
'wait_timeout' => 3,
'heartbeat' => -1,
'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
],
Expand Down
26 changes: 22 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.5'
version: '3.9'

services:
api1: &api
Expand All @@ -8,9 +8,8 @@ services:
context: .
args:
APP_STAGE: dev
environment:
DB_HOST: db
REDIS_HOST: cache
env_file:
- .env
volumes:
- ./:/opt/www
depends_on:
Expand Down Expand Up @@ -43,6 +42,25 @@ services:
cpus: '0.65'
memory: '1.0GB'

# postgres
postgres:
container_name: rinha-de-backend-postgres
image: postgres:latest
environment:
POSTGRES_DB: ${DB_DATABASE}
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: ${DB_USERNAME}
PGDATA: /var/lib/postgresql/data/db-files/
volumes:
- ./migration-postgres.sql:/docker-entrypoint-initdb.d/ddl.sql
ports:
- 5432:5432
deploy:
resources:
limits:
cpus: '0.35'
memory: '0.7GB'

cache:
container_name: rinha-de-backend-cache
image: redis:latest
Expand Down
Empty file added migration-postgres.sql
Empty file.

0 comments on commit 03edc0a

Please sign in to comment.