Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init #1

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/statictest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
jobs:
statictest:
runs-on: ubuntu-latest
container: golang:1.23
container: golang:1.22
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
74 changes: 73 additions & 1 deletion cmd/gophermart/main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,75 @@
package main

func main() {}
import (
"context"
"errors"
"github.com/spqrcor/gofermart/internal/authenticate"
"github.com/spqrcor/gofermart/internal/client"
"github.com/spqrcor/gofermart/internal/config"
"github.com/spqrcor/gofermart/internal/db"
"github.com/spqrcor/gofermart/internal/logger"
"github.com/spqrcor/gofermart/internal/server"
"github.com/spqrcor/gofermart/internal/services"
"github.com/spqrcor/gofermart/internal/workers"
"log"
"net/http"
)

func main() {
mainCtx := context.Background()
conf := config.NewConfig()

loggerRes, err := logger.NewLogger(conf.LogLevel)
if err != nil {
log.Fatal(err)
}
dbRes, err := db.NewDB(loggerRes, conf.DatabaseURI)
spqrcor marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
loggerRes.Fatal(err.Error())
}
if err := db.Migrate(dbRes); err != nil {
ekubyshin marked this conversation as resolved.
Show resolved Hide resolved
loggerRes.Fatal(err.Error())
}

orderQueue := make(chan string)
defer close(orderQueue)

authService := authenticate.NewAuthenticateService(
authenticate.WithLogger(loggerRes),
spqrcor marked this conversation as resolved.
Show resolved Hide resolved
authenticate.WithSecretKey(conf.SecretKey),
authenticate.WithTokenExp(conf.TokenExp),
)
userService := services.NewUserService(dbRes, conf.QueryTimeOut)
orderService := services.NewOrderService(orderQueue, dbRes, loggerRes, conf.QueryTimeOut)
spqrcor marked this conversation as resolved.
Show resolved Hide resolved
withdrawalService := services.NewWithdrawalService(dbRes, loggerRes, conf.QueryTimeOut)
orderClient := client.NewOrderClient(
client.WithLogger(loggerRes),
client.WithAccrualSystemAddress(conf.AccrualSystemAddress),
)

orderWorker := workers.NewOrderWorker(
workers.WithCtx(mainCtx),
spqrcor marked this conversation as resolved.
Show resolved Hide resolved
workers.WithOrderService(orderService),
workers.WithOrderQueue(orderQueue),
workers.WithLogger(loggerRes),
workers.WithConfig(conf),
workers.WithOrderClient(orderClient),
)
orderWorker.Run()
ekubyshin marked this conversation as resolved.
Show resolved Hide resolved

appServer := server.NewServer(
server.WithUserService(userService),
server.WithOrderService(orderService),
server.WithWithdrawalService(withdrawalService),
server.WithLogger(loggerRes),
server.WithRunAddress(conf.RunAddr),
server.WithAuthService(authService),
)
err = appServer.Start()
if errors.Is(err, http.ErrServerClosed) {
ekubyshin marked this conversation as resolved.
Show resolved Hide resolved
loggerRes.Error("Server stop")
}
if err != nil {
loggerRes.Error(err.Error())
}
}
101 changes: 101 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
module github.com/spqrcor/gofermart

go 1.22

require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/ClickHouse/ch-go v0.62.0 // indirect
github.com/ClickHouse/clickhouse-go/v2 v2.28.1 // indirect
github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
github.com/brianvoe/gofakeit/v7 v7.0.4 // indirect
github.com/coder/websocket v1.8.12 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/elastic/go-sysinfo v1.14.1 // indirect
github.com/elastic/go-windows v1.0.2 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/gavv/httpexpect/v2 v2.16.0 // indirect
github.com/go-chi/chi/v5 v5.1.0 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/go-sql-driver/mysql v1.8.1 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/imkira/go-interpol v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.6.0 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect
github.com/jonboulle/clockwork v0.4.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/libsql/sqlite-antlr4-parser v0.0.0-20240721121621-c0bdc870f11c // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mfridman/interpolate v0.0.2 // indirect
github.com/microsoft/go-mssqldb v1.7.2 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/paulmach/orb v0.11.1 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pressly/goose/v3 v3.21.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/sanity-io/litter v1.5.5 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/sergi/go-diff v1.0.0 // indirect
github.com/sethvargo/go-retry v0.3.0 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/tursodatabase/libsql-client-go v0.0.0-20240812094001-348a4e45b535 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.34.0 // indirect
github.com/vertica/vertica-sql-go v1.3.3 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
github.com/ydb-platform/ydb-go-genproto v0.0.0-20240821162910-6cb364b2ccc8 // indirect
github.com/ydb-platform/ydb-go-sdk/v3 v3.77.1 // indirect
github.com/yudai/gojsondiff v1.0.0 // indirect
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
github.com/ziutek/mymysql v1.5.4 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/crypto v0.26.0 // indirect
golang.org/x/exp v0.0.0-20240823005443-9b4947da3948 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/text v0.17.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect
google.golang.org/grpc v1.66.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
howett.net/plist v1.0.1 // indirect
modernc.org/gc/v3 v3.0.0-20240801135723-a856999a2e4a // indirect
modernc.org/libc v1.60.0 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/sqlite v1.32.0 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
moul.io/http2curl/v2 v2.3.0 // indirect
nhooyr.io/websocket v1.8.17 // indirect
)
Loading
Loading