-
Notifications
You must be signed in to change notification settings - Fork 932
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from olukkas/main
submissão para a rinha
- Loading branch information
Showing
4 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# RINHA DE BACKEND 2024 NA MELHOR LINGUAGEM AKA GO | ||
|
||
## Stack | ||
|
||
<img src="https://upload.wikimedia.org/wikipedia/commons/c/c5/Nginx_logo.svg" alt="logo nginx" width="300" height="auto"> | ||
<br /> | ||
<br /> | ||
<img src="https://upload.wikimedia.org/wikipedia/commons/0/05/Go_Logo_Blue.svg?uselang=pt" alt="logo clojure" width="200" height="auto"> | ||
<br /> | ||
<br /> | ||
<img src="https://upload.wikimedia.org/wikipedia/commons/2/29/Postgresql_elephant.svg" alt="logo postgres" width="200" height="auto"> | ||
|
||
## Libs usadas | ||
github.com/go-chi/chi/v5 http router <br/> | ||
github.com/lib/pq driver para o postgres | ||
|
||
Repositório: [https://github.com/olukkas/rinha-2024-golang](https://github.com/olukkas/rinha-2024-golang) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
version: '3' | ||
|
||
services: | ||
app1: &api1 | ||
image: olukkas/rinha-app:latest | ||
hostname: app1 | ||
environment: | ||
- DNS_DB=dbname=rinha sslmode=disable user=postgres password=root host=db | ||
- PORT=3000 | ||
ports: | ||
- "3000:3000" | ||
depends_on: | ||
- db | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: "0.3" | ||
memory: "150MB" | ||
|
||
app2: | ||
<<: *api1 | ||
hostname: app2 | ||
ports: | ||
- "3001:3000" | ||
|
||
nginx: | ||
image: nginx:latest | ||
volumes: | ||
- ./nginx.conf:/etc/nginx/nginx.conf:ro | ||
depends_on: | ||
- app1 | ||
- app2 | ||
ports: | ||
- "9999:9999" | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: "0.3" | ||
memory: "50MB" | ||
|
||
db: | ||
image: postgres:9.4 | ||
hostname: db | ||
environment: | ||
- POSTGRES_PASSWORD=root | ||
- POSTGRES_DB=rinha | ||
ports: | ||
- "5432:5432" | ||
volumes: | ||
- ./init.sql:/docker-entrypoint-initdb.d/init.sql | ||
deploy: | ||
resources: | ||
limits: | ||
cpus: "0.6" | ||
memory: "200MB" | ||
|
||
networks: | ||
default: | ||
driver: bridge | ||
# noinspection ComposeUnknownKeys | ||
name: rinha-net |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
CREATE TABLE clients ( | ||
id SERIAL PRIMARY KEY, | ||
balance INTEGER NOT NULL, | ||
total_limit INTEGER NOT NULL | ||
); | ||
|
||
CREATE TABLE transactions ( | ||
id SERIAL PRIMARY KEY, | ||
client_id INTEGER REFERENCES clients(id), | ||
value INTEGER NOT NULL, | ||
type "char" CHECK (type IN ('c', 'd')) NOT NULL, | ||
description VARCHAR(10) NOT NULL, | ||
created_at TIMESTAMPTZ DEFAULT current_timestamp NOT NULL | ||
); | ||
|
||
insert into clients | ||
(id, total_limit, balance) | ||
values | ||
(1, 100000, 0), | ||
(2, 80000, 0), | ||
(3, 1000000, 0), | ||
(4, 10000000, 0), | ||
(5, 500000, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
events { | ||
worker_connections 200; | ||
} | ||
|
||
http { | ||
access_log off; | ||
sendfile on; | ||
|
||
upstream api { | ||
server app1:3000; | ||
server app2:3000; | ||
} | ||
|
||
server { | ||
listen 9999; | ||
|
||
location / { | ||
proxy_pass http://api; | ||
} | ||
} | ||
} |