Skip to content

Commit

Permalink
Merge pull request #55 from olukkas/main
Browse files Browse the repository at this point in the history
submissão para a rinha
  • Loading branch information
zanfranceschi authored Feb 9, 2024
2 parents 0290092 + ed1af03 commit adcbb03
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 0 deletions.
17 changes: 17 additions & 0 deletions participantes/olukkas/README.md
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)
61 changes: 61 additions & 0 deletions participantes/olukkas/docker-compose.yaml
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
23 changes: 23 additions & 0 deletions participantes/olukkas/init.sql
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)
21 changes: 21 additions & 0 deletions participantes/olukkas/nginx.conf
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;
}
}
}

0 comments on commit adcbb03

Please sign in to comment.