Skip to content

Commit

Permalink
Merge pull request #5 from morka17/ft/asynqWorker
Browse files Browse the repository at this point in the history
Ft/asynq worker
  • Loading branch information
morka17 committed Jul 6, 2023
2 parents 1fbcaae + 7414724 commit 6785fc7
Show file tree
Hide file tree
Showing 38 changed files with 1,598 additions and 203 deletions.
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ FROM golang:1.16-alpine AS builder
WORKDIR /app

COPY main .
COPY migrate.linux-amd64 .
COPY . .
# COPY migrate.linux-amd64 .

# FROM golang:1.16-alpine AS builder

Expand All @@ -13,25 +14,24 @@ COPY migrate.linux-amd64 .
# COPY go.mod .
# RUN go mod download
# # Copy the source code.
# COPY . .
# COPY . .g
# # Build
# # RUN apk add curl
# # RUN curl -L https://github.com/golang-migrate/migrate/releases/download/v4.12.2/migrate.linux-amd64.tar.gz | tar xvz
# COPY migrate.linux-amd64 .
# RUN CGO_ENABLED=0 GOOS=linux go build -o main main.go


# RUN STAGE
FROM alpine:latest
WORKDIR /app
COPY --from=builder /app/main .
COPY --from=builder /app/migrate.linux-amd64 ./migrate
# COPY --from=builder /app/migrate.linux-amd64 ./migrate
COPY app.env .
COPY src/db/migration ./migration
COPY src/db/migration ./src/db/migration
COPY wait-for.sh .
COPY start.sh .


EXPOSE 8080
CMD ["/app/main"]
ENTRYPOINT [ "/app/start.sh", "/app/main" ]
ENTRYPOINT [ "/app/start.sh"]
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ proto:
--grpc-gateway_out ./pb --grpc-gateway_opt paths=source_relative \
--openapiv2_out ./doc/swagger --openapiv2_opt allow_merge=true,merge_file_name=shiny_bank\
./proto/*.proto
statik -src=./doc/swagger -dest=./doc

evans:
evans --host localhost --port 9090 -r repl

redis:
docker run --name redis -p 6379:6379 -d redis:7-alpine


test:
go test -v -cover ./...
Expand Down
5 changes: 4 additions & 1 deletion app.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
ENVIRONMENT=development
DB_Driver = "postgres"
DB_Source = "postgresql://root:secret@localhost:5432/shiny_bank?sslmode=disable"
MIGRATION_URL = file://src/db/migration
HTTP_Server_Address = :8080
GRPC_Server_Address = :9090
TOKEN_SYMMETRIC_KEY = 12344563454624235362365474356564
ACCESS_TOKEN_DURATION=15m
REFRESH_TOKEN_DURATION=24h
REFRESH_TOKEN_DURATION=24h
REDIS_ADDRESS=0.0.0.0:6379
14 changes: 14 additions & 0 deletions doc/statik/statik.go

Large diffs are not rendered by default.

65 changes: 64 additions & 1 deletion doc/swagger/shiny_bank.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"swagger": "2.0",
"info": {
"title": "Shiny bank API",
"version": "1.0",
"version": "1.1",
"contact": {
"name": "Morka",
"url": "https://github.com/morka17",
Expand All @@ -26,6 +26,8 @@
"paths": {
"/v1/create_user": {
"post": {
"summary": "Create new user",
"description": "Use this API to create a new user",
"operationId": "SimpleBank_CreateUser",
"responses": {
"200": {
Expand Down Expand Up @@ -58,6 +60,8 @@
},
"/v1/login_user": {
"post": {
"summary": "login a user",
"description": "Use this API to login a user and get access Token and refresh Token",
"operationId": "SimpleBank_LoginUser",
"responses": {
"200": {
Expand Down Expand Up @@ -87,6 +91,40 @@
"SimpleBank"
]
}
},
"/v1/update_user": {
"patch": {
"summary": "Update user",
"description": "Use this API to update a user",
"operationId": "SimpleBank_UpdateUser",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/pbUpdateUserResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/pbUpdateUserRequest"
}
}
],
"tags": [
"SimpleBank"
]
}
}
},
"definitions": {
Expand Down Expand Up @@ -151,6 +189,31 @@
}
}
},
"pbUpdateUserRequest": {
"type": "object",
"properties": {
"username": {
"type": "string"
},
"fullName": {
"type": "string"
},
"email": {
"type": "string"
},
"password": {
"type": "string"
}
}
},
"pbUpdateUserResponse": {
"type": "object",
"properties": {
"user": {
"$ref": "#/definitions/pbUser"
}
}
},
"pbUser": {
"type": "object",
"properties": {
Expand Down
17 changes: 15 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ require (
github.com/aead/chacha20poly1305 v0.0.0-20170617001512-233f39982aeb
github.com/go-playground/validator/v10 v10.14.0
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/golang-migrate/migrate/v4 v4.16.2
github.com/google/uuid v1.3.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0
github.com/hibiken/asynq v0.24.1
github.com/o1egl/paseto v1.0.0
github.com/rakyll/statik v0.1.7
github.com/rs/zerolog v1.29.1
github.com/spf13/viper v1.16.0
golang.org/x/crypto v0.10.0
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc
google.golang.org/grpc v1.55.0
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.3.0
google.golang.org/protobuf v1.30.0
Expand All @@ -28,8 +34,10 @@ require (
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
github.com/aead/poly1305 v0.0.0-20180717145839-3fee0db0b635 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
Expand All @@ -38,32 +46,37 @@ require (
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/glog v1.1.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/redis/go-redis/v9 v9.0.3 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
go.uber.org/atomic v1.9.0 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/sys v0.9.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/time v0.1.0 // indirect
google.golang.org/genproto v0.0.0-20230526203410-71b5a4ffd15e // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 6785fc7

Please sign in to comment.