diff --git a/participantes/olukkas/README.md b/participantes/olukkas/README.md new file mode 100644 index 000000000..f574ab360 --- /dev/null +++ b/participantes/olukkas/README.md @@ -0,0 +1,17 @@ +# RINHA DE BACKEND 2024 NA MELHOR LINGUAGEM AKA GO + +## Stack + +logo nginx +
+
+logo clojure +
+
+logo postgres + +## Libs usadas +github.com/go-chi/chi/v5 http router
+github.com/lib/pq driver para o postgres + +Repositório: [https://github.com/olukkas/rinha-2024-golang](https://github.com/olukkas/rinha-2024-golang) diff --git a/participantes/olukkas/docker-compose.yaml b/participantes/olukkas/docker-compose.yaml new file mode 100644 index 000000000..2350c85a9 --- /dev/null +++ b/participantes/olukkas/docker-compose.yaml @@ -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 diff --git a/participantes/olukkas/init.sql b/participantes/olukkas/init.sql new file mode 100644 index 000000000..901de8116 --- /dev/null +++ b/participantes/olukkas/init.sql @@ -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) diff --git a/participantes/olukkas/nginx.conf b/participantes/olukkas/nginx.conf new file mode 100644 index 000000000..9c75e84f3 --- /dev/null +++ b/participantes/olukkas/nginx.conf @@ -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; + } + } +}