resolve conflicts

This commit is contained in:
timka
2025-12-17 17:49:38 +03:00
19 changed files with 454 additions and 230 deletions
-14
View File
@@ -1,14 +0,0 @@
# Change all vars before going to production and remove all comments (!)
# Below all environment variables and default values
GRPC_PORT=50051
GRPC_ENABLE_REFLECTION=false
HTTP_HANDLER_ENABLE=false
HTTP_PORT=8080
LOG_LEVEL=info
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USERNAME=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DATABASE=postgres
REDIS_URI=redis://localhost:6379
+2 -2
View File
@@ -44,7 +44,7 @@ ARG SERVICE
WORKDIR /app
COPY --from=build --chown=1000:1000 /out/${SERVICE} /app/bin/${SERVICE}
COPY --from=build --chown=1000:1000 /out/${SERVICE} /app/bin
EXPOSE 8080 50051
@@ -54,6 +54,6 @@ LABEL org.opencontainers.image.created="${BUILD_TIME}" \
USER 1000
ENTRYPOINT ["/app/bin/${SERVICE}"]
ENTRYPOINT ["/app/bin"]
CMD []
+1 -1
View File
@@ -29,4 +29,4 @@ func main() {
log.Println("shutting down competition server...")
srv.Stop()
log.Println("competition server stopped")
}
}
+75 -22
View File
@@ -31,42 +31,53 @@ func main() {
authClient, err := grpc_client.NewAuthClient(ctx, cfg.GRPC.AuthServiceAddr, clientFactory)
if err != nil {
log.Fatalf("Failed to create auth client: %v", err)
log.Printf("Warning: Failed to create auth client: %v", err)
authClient = nil
}
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
userClient, err := grpc_client.NewUserClient(ctx, cfg.GRPC.UserServiceAddr, clientFactory)
if err != nil {
log.Fatalf("Failed to create user client: %v", err)
log.Printf("Warning: Failed to create user client: %v", err)
userClient = nil
}
competitionClient, err := grpc_client.NewCompetitionClient(ctx, cfg.GRPC.CompetitionServiceAddr, clientFactory)
if err != nil {
log.Fatalf("Failed to create competition client: %v", err)
log.Printf("Warning: Failed to create competition client: %v", err)
competitionClient = nil
}
taskClient, err := grpc_client.NewTaskClient(ctx, cfg.GRPC.TaskServiceAddr, clientFactory)
if err != nil {
log.Fatalf("Failed to create task client: %v", err)
log.Printf("Warning: Failed to create task client: %v", err)
taskClient = nil
}
submissionClient, err := grpc_client.NewSubmissionClient(ctx, cfg.GRPC.SubmissionServiceAddr, clientFactory)
if err != nil {
log.Fatalf("Failed to create submission client: %v", err)
log.Printf("Warning: Failed to create submission client: %v", err)
submissionClient = nil
}
resultsClient, err := grpc_client.NewResultsClient(ctx, cfg.GRPC.ResultsServiceAddr, clientFactory)
if err != nil {
log.Fatalf("Failed to create results client: %v", err)
log.Printf("Warning: Failed to create results client: %v", err)
resultsClient = nil
}
reviewClient, err := grpc_client.NewReviewClient(ctx, cfg.GRPC.ReviewServiceAddr, clientFactory)
if err != nil {
log.Fatalf("Failed to create review client: %v", err)
log.Printf("Warning: Failed to create review client: %v", err)
reviewClient = nil
}
achievementsClient, err := grpc_client.NewAchievementsClient(ctx, cfg.GRPC.AchievementsServiceAddr, clientFactory)
if err != nil {
log.Fatalf("Failed to create achievements client: %v", err)
log.Printf("Warning: Failed to create achievements client: %v", err)
achievementsClient = nil
}
s3Storage, err := storage.NewS3Storage(storage.S3Config{
@@ -82,23 +93,65 @@ func main() {
authMiddleware := middleware.NewAuthMiddleware(authClient)
authHandler := handler.NewAuthHandler(authClient, userClient)
competitionHandler := handler.NewCompetitionHandler(competitionClient, userClient)
taskHandler := handler.NewTaskHandler(taskClient)
submissionHandler := handler.NewSubmissionHandler(submissionClient, s3Storage)
resultsHandler := handler.NewResultsHandler(resultsClient)
reviewHandler := handler.NewReviewHandler(reviewClient)
achievementsHandler := handler.NewAchievementsHandler(achievementsClient)
var authHandler handler.AuthHandler
if authClient != nil {
authHandler = *handler.NewAuthHandler(authClient, userClient)
} else {
log.Printf("Warning: AuthHandler not initialized due to missing authClient")
}
var competitionHandler handler.CompetitionHandler
if competitionClient != nil {
competitionHandler = *handler.NewCompetitionHandler(competitionClient, userClient)
} else {
log.Printf("Warning: CompetitionHandler not initialized due to missing competitionClient")
}
var taskHandler handler.TaskHandler
if taskClient != nil {
taskHandler = *handler.NewTaskHandler(taskClient)
} else {
log.Printf("Warning: TaskHandler not initialized due to missing taskClient")
}
var submissionHandler handler.SubmissionHandler
if submissionClient != nil {
submissionHandler = *handler.NewSubmissionHandler(submissionClient, s3Storage)
} else {
log.Printf("Warning: SubmissionHandler not initialized due to missing submissionClient")
}
var resultsHandler handler.ResultsHandler
if resultsClient != nil {
resultsHandler = *handler.NewResultsHandler(resultsClient)
} else {
log.Printf("Warning: ResultsHandler not initialized due to missing resultsClient")
}
var reviewHandler handler.ReviewHandler
if reviewClient != nil {
reviewHandler = *handler.NewReviewHandler(reviewClient)
} else {
log.Printf("Warning: ReviewHandler not initialized due to missing reviewClient")
}
var achievementsHandler handler.AchievementsHandler
if achievementsClient != nil {
achievementsHandler = *handler.NewAchievementsHandler(achievementsClient)
} else {
log.Printf("Warning: AchievementsHandler not initialized due to missing achievementsClient")
}
pingHandler := handler.NewPingHandler()
rt := router.NewRouter(
authHandler,
competitionHandler,
taskHandler,
submissionHandler,
resultsHandler,
reviewHandler,
achievementsHandler,
&authHandler,
&competitionHandler,
&taskHandler,
&submissionHandler,
&resultsHandler,
&reviewHandler,
&achievementsHandler,
pingHandler,
authMiddleware,
)
+176 -130
View File
@@ -1,122 +1,12 @@
name: datarush
services:
auth:
build:
context: .
dockerfile: Containerfile
depends_on:
postgres:
restart: false
condition: service_healthy
required: true
env_file:
- path: ./infrastructure/auth/.env.template
required: true
- path: ./infrastructure/auth/.env
required: false
ports:
- name: http
target: 8081
published: 13443
host_ip: 127.0.0.1
protocol: tcp
app_protocol: http
- name: grpc
target: 50052
published: 13444
host_ip: 127.0.0.1
protocol: tcp
app_protocol: http
networks:
- default
restart: unless-stopped
shm_size: 4mb
competition:
build:
context: .
dockerfile: Containerfile
depends_on:
postgres:
restart: false
condition: service_healthy
required: true
redis:
restart: false
condition: service_healthy
required: true
auth:
restart: false
condition: service_started
required: true
env_file:
- path: ./infrastructure/competition/.env.template
required: true
- path: ./infrastructure/competition/.env
required: false
ports:
- name: http
target: 8082
published: 13445
host_ip: 127.0.0.1
protocol: tcp
app_protocol: http
- name: grpc
target: 50053
published: 13446
host_ip: 127.0.0.1
protocol: tcp
app_protocol: http
networks:
- default
restart: unless-stopped
shm_size: 4mb
task:
build:
context: .
dockerfile: Containerfile
depends_on:
postgres:
restart: false
condition: service_healthy
required: true
redis:
restart: false
condition: service_healthy
required: true
auth:
restart: false
condition: service_started
required: true
env_file:
- path: ./infrastructure/task/.env.template
required: true
- path: ./infrastructure/task/.env
required: false
ports:
- name: http
target: 8083
published: 13447
host_ip: 127.0.0.1
protocol: tcp
app_protocol: http
- name: grpc
target: 50054
published: 13448
host_ip: 127.0.0.1
protocol: tcp
app_protocol: http
networks:
- default
restart: unless-stopped
shm_size: 4mb
core:
gw:
build:
context: .
dockerfile: Containerfile
args:
SERVICE: gw
depends_on:
migrate:
restart: false
@@ -143,22 +33,10 @@ services:
condition: service_started
required: true
env_file:
- path: ./infrastructure/core/.env.template
- path: ./infrastructure/gw/.env.template
required: true
- path: ./infrastructure/core/.env
ports:
- name: http
target: 8080
published: 13440
host_ip: 127.0.0.1
protocol: tcp
app_protocol: http
- name: grpc
target: 50051
published: 13441
host_ip: 127.0.0.1
protocol: tcp
app_protocol: http
- path: ./infrastructure/gw/.env
required: false
networks:
- default
restart: unless-stopped
@@ -168,20 +46,131 @@ services:
build:
context: .
dockerfile: Containerfile
args:
SERVICE: migrate
depends_on:
postgres:
restart: false
condition: service_healthy
required: true
env_file:
- path: ./infrastructure/core/.env.template
- path: ./infrastructure/migrate/.env.template
required: true
- path: ./infrastructure/core/.env
- path: ./infrastructure/migrate/.env
required: false
networks:
- default
restart: no
shm_size: 4mb
auth:
build:
context: .
dockerfile: Containerfile
args:
SERVICE: auth
depends_on:
postgres:
restart: false
condition: service_healthy
required: true
env_file:
- path: ./infrastructure/auth/.env.template
required: true
- path: ./infrastructure/auth/.env
required: false
networks:
- default
restart: unless-stopped
shm_size: 4mb
competition:
build:
context: .
dockerfile: Containerfile
args:
SERVICE: competition
depends_on:
postgres:
restart: false
condition: service_healthy
required: true
redis:
restart: false
condition: service_healthy
required: true
auth:
restart: false
condition: service_started
required: true
env_file:
- path: ./infrastructure/competition/.env.template
required: true
- path: ./infrastructure/competition/.env
required: false
networks:
- default
restart: unless-stopped
shm_size: 4mb
task:
build:
context: .
dockerfile: Containerfile
args:
SERVICE: task
depends_on:
postgres:
restart: false
condition: service_healthy
required: true
redis:
restart: false
condition: service_healthy
required: true
auth:
restart: false
condition: service_started
required: true
env_file:
- path: ./infrastructure/task/.env.template
required: true
- path: ./infrastructure/task/.env
required: false
networks:
- default
restart: unless-stopped
shm_size: 4mb
nginx:
image: docker.io/nginx:1.29-alpine
configs:
- source: nginx_config
target: /etc/nginx/nginx.conf
depends_on:
gw:
restart: false
condition: service_started
required: true
healthcheck:
test: ["CMD", "wget", "-O", "-", "http://localhost:80/healthz"]
interval: 1m30s
timeout: 5s
start_period: 5s
start_interval: 2s
retries: 5
ports:
- name: web
target: 80
published: 8080
host_ip: 0.0.0.0
protocol: tcp
app_protocol: http
networks:
- default
restart: unless-stopped
shm_size: 4mb
postgres:
image: docker.io/postgres:17-alpine
configs:
@@ -278,6 +267,60 @@ services:
target: /data
read_only: false
minio-init:
image: docker.io/minio/minio:RELEASE.2025-09-07T16-13-09Z
entrypoint: >
/bin/sh -c "
sleep 5;
/usr/bin/mc alias set minio http://minio:9000 admin password;
/usr/bin/mc mb minio/datarush;
exit 0;
"
env_file:
- path: ./infrastructure/minio/.env.template
required: true
- path: ./infrastructure/minio/.env
required: false
restart: no
volumes:
- type: volume
source: minio_data
target: /data
minio:
image: docker.io/minio/minio:RELEASE.2025-09-07T16-13-09Z
command: server --console-address ":9001"
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 1m30s
timeout: 5s
start_period: 5s
start_interval: 2s
retries: 5
env_file:
- path: ./infrastructure/minio/.env.template
required: true
- path: ./infrastructure/minio/.env
required: false
ports:
- name: api
target: 9000
published: 8005
host_ip: 127.0.0.1
protocol: tcp
app_protocol: http
- name: console
target: 9001
published: 8006
host_ip: 127.0.0.1
protocol: tcp
app_protocol: http
restart: unless-stopped
volumes:
- type: volume
source: minio_data
target: /data
networks:
default:
driver: bridge
@@ -291,8 +334,11 @@ volumes:
postgres_data:
pgadmin_data:
redis_data:
minio_data:
configs:
nginx_config:
file: ./infrastructure/nginx/nginx.conf
postgres_config:
file: ./infrastructure/postgres/postgresql.conf
pgadmin_servers_config:
+5
View File
@@ -138,8 +138,13 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
<<<<<<< HEAD
github.com/redis/go-redis/v9 v9.16.0 h1:OotgqgLSRCmzfqChbQyG1PHC3tLNR89DG4jdOERSEP4=
github.com/redis/go-redis/v9 v9.16.0/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370=
=======
github.com/redis/go-redis/v9 v9.17.2 h1:P2EGsA4qVIM3Pp+aPocCJ7DguDHhqrXNhVcEp4ViluI=
github.com/redis/go-redis/v9 v9.17.2/go.mod h1:u410H11HMLoB+TP67dz8rL9s6QW2j76l0//kSOd3370=
>>>>>>> origin/feature/task
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+2 -2
View File
@@ -1,5 +1,5 @@
AUTH_GRPC_PORT=50052
AUTH_HTTP_PORT=8081
AUTH_GRPC_PORT=50051
AUTH_HTTP_PORT=8080
AUTH_GRPC_ENABLE_REFLECTION=true
POSTGRES_HOST=postgres
+4 -16
View File
@@ -1,31 +1,19 @@
# Competition Service Configuration
# gRPC server port
COMPETITION_GRPC_PORT=50053
# Enable/disable gRPC reflection
COMPETITION_GRPC_PORT=50051
COMPETITION_GRPC_ENABLE_REFLECTION=true
COMPETITION_HTTP_PORT=8080
# HTTP server port (if applicable)
COMPETITION_HTTP_PORT=8082
# Log level (e.g., debug, info, warn, error)
LOG_LEVEL=info
# PostgreSQL database connection
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_USERNAME=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DATABASE=postgres
# Address of the authentication gRPC service
AUTH_SVC_ADDR=auth:50052
AUTH_SVC_ADDR=auth:50051
# Redis connection for caching
REDIS_ADDR=redis:6379
REDIS_PASSWORD=
REDIS_DB=0
# Enable/disable caching
CACHE_ENABLED=true
CACHE_ENABLED=true
+13 -13
View File
@@ -1,19 +1,19 @@
SERVER_PORT=8080
SERVER_HOST=0.0.0.0
AUTH_SERVICE_ADDR=auth:50052
USER_SERVICE_ADDR=user:50052
COMPETITION_SERVICE_ADDR=competition:50052
TASK_SERVICE_ADDR=task:50052
SUBMISSION_SERVICE_ADDR=submission:50052
RESULTS_SERVICE_ADDR=results:50052
REVIEW_SERVICE_ADDR=review:50052
ACHIEVEMENTS_SERVICE_ADDR=achievements:50052
AUTH_SERVICE_ADDR=auth:50051
USER_SERVICE_ADDR=user:50051
COMPETITION_SERVICE_ADDR=competition:50051
TASK_SERVICE_ADDR=task:50051
SUBMISSION_SERVICE_ADDR=submission:50051
RESULTS_SERVICE_ADDR=results:50051
REVIEW_SERVICE_ADDR=review:50051
ACHIEVEMENTS_SERVICE_ADDR=achievements:50051
AWS_ACCESS_KEY_ID=your_access_key_here
AWS_SECRET_ACCESS_KEY=your_secret_key_here
AWS_REGION=us-east-1
S3_BUCKET=datarush-submissions
S3_ENDPOINT=
AWS_ACCESS_KEY_ID=admin
AWS_SECRET_ACCESS_KEY=password
AWS_REGION=
S3_BUCKET=datarush
S3_ENDPOINT=http://localhost:9000
JWT_SECRET=your_jwt_secret_here
+5
View File
@@ -0,0 +1,5 @@
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USERNAME=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DATABASE=postgres
+3
View File
@@ -0,0 +1,3 @@
MINIO_ROOT_USER=admin
MINIO_ROOT_PASSWORD=password
MINIO_VOLUMES=/data
+156
View File
@@ -0,0 +1,156 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 4096;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_session_cache shared:SSL:50m;
ssl_session_timeout 1d;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256;
ssl_ecdh_curve X25519:secp521r1:secp384r1;
ssl_prefer_server_ciphers on;
ssl_stapling on;
ssl_stapling_verify on;
resolver 127.0.0.11 valid=30s;
resolver_timeout 5s;
server_names_hash_bucket_size 128;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "0";
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
add_header Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()" always;
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https:; img-src 'self' data: https:; style-src 'self' 'unsafe-inline' https:; font-src 'self' https:; frame-ancestors 'none'; form-action 'self'; object-src 'none'; base-uri 'self';" always;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 75;
client_body_timeout 15;
client_header_timeout 15;
reset_timedout_connection on;
send_timeout 15;
client_body_buffer_size 128k;
client_header_buffer_size 4k;
client_max_body_size 100M;
large_client_header_buffers 4 16k;
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_min_length 1024;
gzip_types
text/plain
text/css
text/xml
text/javascript
application/json
application/javascript
application/x-javascript
application/xml
application/xml+rss
font/woff
font/woff2
image/svg+xml;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
server_tokens off;
upstream gw {
zone gw 64k;
server gw:8080 resolve;
}
upstream minio {
zone minio 64k;
server minio:9000 resolve;
}
upstream minio-ui {
zone minio-ui 64k;
server minio:9001 resolve;
}
server {
listen 80;
server_name _;
location / {
proxy_pass http://gw;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 80;
listen [::]:80;
server_name minio;
http2 on;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
ignore_invalid_headers off;
client_max_body_size 0;
proxy_buffering off;
proxy_request_buffering off;
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 300;
proxy_http_version 1.1;
proxy_set_header Connection "";
chunked_transfer_encoding off;
proxy_pass http://minio;
}
location /minio/ui/ {
rewrite ^/minio/ui/(.*) /$1 break;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-NginX-Proxy true;
real_ip_header X-Real-IP;
proxy_connect_timeout 300;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
chunked_transfer_encoding off;
proxy_pass http://minio-ui;
}
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ func Load() (*Config, error) {
_ = godotenv.Load()
return &Config{
GRPCPort: mustGetInt("AUTH_GRPC_PORT", 50052),
GRPCPort: mustGetInt("AUTH_GRPC_PORT", 50051),
GRPCEnableReflection: mustGetBool("AUTH_GRPC_ENABLE_REFLECTION", false),
HTTPPort: mustGetInt("AUTH_HTTP_PORT", 8081),
LogLevel: getEnv("LOG_LEVEL", "info"),
+4 -1
View File
@@ -53,7 +53,10 @@ func (h *AuthHandler) SignIn(ctx context.Context, req *pb.SignInRequest) (*pb.Si
return &pb.SignInResponse{Token: token}, nil
}
func (h *AuthHandler) ValidateToken(ctx context.Context, req *pb.ValidateTokenRequest) (*pb.ValidateTokenResponse, error) {
func (h *AuthHandler) ValidateToken(
ctx context.Context,
req *pb.ValidateTokenRequest,
) (*pb.ValidateTokenResponse, error) {
token := req.Token
if token == "" {
+2 -2
View File
@@ -12,13 +12,13 @@ import (
)
type SignUpRequest struct {
Email string `json:"email" binding:"required,email"`
Email string `json:"email" binding:"required,email"`
Username string `json:"username" binding:"required"`
Password string `json:"password" binding:"required"`
}
type SignInRequest struct {
Email string `json:"email" binding:"required,email"`
Email string `json:"email" binding:"required,email"`
Password string `json:"password" binding:"required"`
}
+1 -1
View File
@@ -31,7 +31,7 @@ func Load() (*Config, error) {
_ = godotenv.Load()
return &Config{
GRPCPort: mustGetInt("COMPETITION_GRPC_PORT", 50053),
GRPCPort: mustGetInt("COMPETITION_GRPC_PORT", 50051),
GRPCEnableReflection: mustGetBool("COMPETITION_GRPC_ENABLE_REFLECTION", false),
HTTPPort: mustGetInt("COMPETITION_HTTP_PORT", 8082),
LogLevel: getEnv("LOG_LEVEL", "info"),
+1 -1
View File
@@ -60,7 +60,7 @@ func Load() (*Config, error) {
S3: S3Config{
AccessKeyID: getEnvRequired("AWS_ACCESS_KEY_ID"),
SecretAccessKey: getEnvRequired("AWS_SECRET_ACCESS_KEY"),
Region: getEnvRequired("AWS_REGION"),
Region: getEnv("AWS_REGION", ""),
Bucket: getEnvRequired("S3_BUCKET"),
Endpoint: getEnv("S3_ENDPOINT", ""),
},
-10
View File
@@ -22,27 +22,17 @@ type Config struct {
DBPassword string
DBName string
RedisURI string
AuthGRPCAddr string
CacheEnabled bool
}
func Load() (*Config, error) {
_ = godotenv.Load()
return &Config{
GRPCPort: mustGetInt("GRPC_PORT", 50051), //nolint:mnd // false-positive
GRPCEnableReflection: mustGetBool("GRPC_ENABLE_REFLECTION", false),
EnableHTTPHandler: mustGetBool("HTTP_HANDLER_ENABLE", false),
HTTPPort: mustGetInt("HTTP_PORT", 8080), //nolint:mnd // false-positive
LogLevel: getEnv("LOG_LEVEL", "info"),
DBHost: getEnv("POSTGRES_HOST", "localhost"),
DBPort: mustGetInt("POSTGRES_PORT", 5432), //nolint:mnd // false-positive
DBUser: getEnv("POSTGRES_USERNAME", "postgres"),
DBPassword: getEnv("POSTGRES_PASSWORD", "postgres"),
DBName: getEnv("POSTGRES_DATABASE", "postgres"),
RedisURI: getEnv("REDIS_URI", "redis://localhost:6379"),
AuthGRPCAddr: getEnv("AUTH_GRPC_ADDR", "localhost:50052"),
CacheEnabled: mustGetBool("CACHE_ENABLED", true),
}, nil
}
+3 -14
View File
@@ -7,24 +7,13 @@
package competition
import (
"context"
"io"
"net/http"
"unsafe"
"reflect"
"sync"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
emptypb "google.golang.org/protobuf/types/known/emptypb"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
reflect "reflect"
sync "sync"
unsafe "unsafe"
)
const (