diff --git a/src/cmd/migrate/main.go b/src/cmd/migrate/main.go index e88561c..70e2ccc 100644 --- a/src/cmd/migrate/main.go +++ b/src/cmd/migrate/main.go @@ -9,10 +9,10 @@ import ( "github.com/go-pg/migrations/v8" "github.com/go-pg/pg/v10" - "git.pbiernat.dev/egommerce/go-api-pkg/fluentd" + "git.pbiernat.io/egommerce/go-api-pkg/fluentd" - "git.pbiernat.dev/egommerce/catalog-service/internal" - baseCnf "git.pbiernat.dev/egommerce/go-api-pkg/config" + cnf "git.pbiernat.io/egommerce/catalog-service/internal/server" + baseCnf "git.pbiernat.io/egommerce/go-api-pkg/config" ) const ( @@ -46,7 +46,7 @@ func main() { log.Panicln("Error loading .env file", baseCnf.ErrLoadingEnvs) } - c := internal.NewConfig("catalog-migrator") + c := cnf.NewConfig("catalog-migrator") // dbURL := baseCnf.GetEnv("DATABASE_URL", defDbURL) diff --git a/src/cmd/server/main.go b/src/cmd/server/main.go index 34a3770..7722ff6 100644 --- a/src/cmd/server/main.go +++ b/src/cmd/server/main.go @@ -4,33 +4,34 @@ import ( "log" "os" - baseCnf "git.pbiernat.dev/egommerce/go-api-pkg/config" + cnf "git.pbiernat.io/egommerce/go-api-pkg/config" - cnf "git.pbiernat.dev/egommerce/catalog-service/internal/config" - svr "git.pbiernat.dev/egommerce/catalog-service/internal/server" + "git.pbiernat.io/egommerce/catalog-service/internal/app" + "git.pbiernat.io/egommerce/catalog-service/internal/config" + "git.pbiernat.io/egommerce/catalog-service/internal/server" ) func main() { - if baseCnf.ErrLoadingEnvs != nil { - log.Panicln("Error loading .env file", baseCnf.ErrLoadingEnvs) + if cnf.ErrLoadingEnvs != nil { + log.Panicln("Error loading .env file", cnf.ErrLoadingEnvs) } - c := cnf.NewConfig("catalog") - srv := svr.New( - c, - svr.WithCache(c), - svr.WithDatabase(c), - svr.WithEventbus(c), - svr.WithLogger(c), - svr.WithRegistry(c), - ) + c := config.NewServerConfig("catalog") + srv := server.New(c) + app := app.NewApp(c, srv) + + app.RegisterHelper("cache", app.WithCache()) + app.RegisterHelper("database", app.WithDatabase()) + app.RegisterHelper("eventbus", app.WithEventbus()) + app.RegisterHelper("logger", app.WithLogger()) + app.RegisterHelper("registry", app.WithRegistry()) while := make(chan struct{}) - err := srv.Base.Start(while) + err := app.Start(while) <-while if err != nil { - log.Fatalf("Failed to start server. Reason: %v\n", err) + log.Fatalf("Failed to start application. Reason: %v\n", err) os.Exit(1) } diff --git a/src/cmd/worker/main.go b/src/cmd/worker/main.go index 2fc7304..24a5d34 100644 --- a/src/cmd/worker/main.go +++ b/src/cmd/worker/main.go @@ -4,10 +4,8 @@ import ( "log" "os" - // "git.pbiernat.dev/egommerce/go-api-pkg/config" - - "git.pbiernat.dev/egommerce/catalog-service/internal" - "git.pbiernat.dev/egommerce/catalog-service/internal/worker" + // "git.pbiernat.io/egommerce/go-api-pkg/config" + "git.pbiernat.io/egommerce/catalog-service/internal/worker" ) func main() { @@ -15,8 +13,13 @@ func main() { // log.Fatalln("Error loading .env file.") // } + c := cnf.NewConfig("catalog-worker") wrk := worker.New( - internal.NewConfig("catalog-worker"), + c, + worker.WithCache(c), + worker.WithDatabase(c), + worker.WithEventbus(c), + worker.WithLogger(c), ) while := make(chan struct{}) diff --git a/src/go.mod b/src/go.mod index 99d3a09..7430804 100644 --- a/src/go.mod +++ b/src/go.mod @@ -1,23 +1,23 @@ -module git.pbiernat.dev/egommerce/catalog-service +module git.pbiernat.io/egommerce/catalog-service go 1.18 require ( - git.pbiernat.dev/egommerce/api-entities v0.0.26 - git.pbiernat.dev/egommerce/go-api-pkg v0.1.66 + git.pbiernat.io/egommerce/api-entities v0.2.3 + git.pbiernat.io/egommerce/go-api-pkg v0.2.72 github.com/georgysavva/scany/v2 v2.0.0 github.com/go-pg/migrations/v8 v8.1.0 - github.com/go-pg/pg/v10 v10.10.7 + github.com/go-pg/pg/v10 v10.11.1 github.com/go-redis/redis/v8 v8.11.5 - github.com/gofiber/fiber/v2 v2.40.1 - github.com/google/uuid v1.3.0 + github.com/gofiber/fiber/v2 v2.52.5 + github.com/google/uuid v1.6.0 github.com/jackc/pgx/v5 v5.1.1 - github.com/streadway/amqp v1.0.0 + github.com/rabbitmq/amqp091-go v1.10.0 ) require ( github.com/DataDog/datadog-go v3.2.0+incompatible // indirect - github.com/andybalholm/brotli v1.0.4 // indirect + github.com/andybalholm/brotli v1.1.0 // indirect github.com/armon/go-metrics v0.4.1 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/aws/aws-sdk-go v1.42.34 // indirect @@ -61,19 +61,17 @@ require ( github.com/hashicorp/raft-autopilot v0.1.6 // indirect github.com/hashicorp/serf v0.10.1 // indirect github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect - github.com/jackc/pgconn v1.13.0 // indirect github.com/jackc/pgio v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgproto3/v2 v2.3.1 // indirect - github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect - github.com/jackc/pgtype v1.13.0 // indirect + github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect + github.com/jackc/pgtype v1.14.3 // indirect github.com/jackc/puddle/v2 v2.1.2 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/joho/godotenv v1.5.1 // indirect - github.com/klauspost/compress v1.15.9 // indirect + github.com/klauspost/compress v1.17.8 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect - github.com/mattn/go-runewidth v0.0.14 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-runewidth v0.0.15 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/miekg/dns v1.1.41 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect @@ -82,37 +80,37 @@ require ( github.com/mitchellh/hashstructure v0.0.0-20170609045927-2bca23e0e452 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/philhofer/fwd v1.1.1 // indirect + github.com/philhofer/fwd v1.1.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_golang v1.14.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.37.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect - github.com/rivo/uniseg v0.2.0 // indirect + github.com/rivo/uniseg v0.4.7 // indirect github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/stretchr/testify v1.8.3 // indirect - github.com/tinylib/msgp v1.1.6 // indirect + github.com/tinylib/msgp v1.1.8 // indirect github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect - github.com/valyala/fasthttp v1.41.0 // indirect + github.com/valyala/fasthttp v1.52.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect github.com/vmihailenco/bufpool v0.1.11 // indirect github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect github.com/vmihailenco/tagparser v0.1.2 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect go.uber.org/atomic v1.10.0 // indirect - golang.org/x/crypto v0.1.0 // indirect + golang.org/x/crypto v0.20.0 // indirect golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect - golang.org/x/net v0.10.0 // indirect + golang.org/x/net v0.21.0 // indirect golang.org/x/sync v0.2.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/text v0.9.0 // indirect + golang.org/x/sys v0.19.0 // indirect + golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/protobuf v1.30.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - mellium.im/sasl v0.2.1 // indirect + mellium.im/sasl v0.3.1 // indirect ) diff --git a/src/go.sum b/src/go.sum index 8dc1a81..14ef396 100644 --- a/src/go.sum +++ b/src/go.sum @@ -35,10 +35,10 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -git.pbiernat.dev/egommerce/api-entities v0.0.26 h1:Avz02GINwuYWOjw1fmZIJ3QgGEIz3a5vRQZNaxxUQIk= -git.pbiernat.dev/egommerce/api-entities v0.0.26/go.mod h1:+BXvUcr6Cr6QNpJsW8BUfe1vVILdWDADNE0e3u0lNvU= -git.pbiernat.dev/egommerce/go-api-pkg v0.1.66 h1:CRJYVSIZ8iolu3LQM9hAcImniM5u9+EYFRUR2bY0Emk= -git.pbiernat.dev/egommerce/go-api-pkg v0.1.66/go.mod h1:nzsa99OyjTHGT5KK294iPzDEjtDFdkcHYejcpDDTL6M= +git.pbiernat.io/egommerce/api-entities v0.2.3 h1:mR6EYfZkAzh4teydb7KXDBWoxwVW3qasnmmH5J3mnas= +git.pbiernat.io/egommerce/api-entities v0.2.3/go.mod h1:INXAG5x4+i+vNwg1NpfPHiDW8nY1kn1K7pgLOtX+/I0= +git.pbiernat.io/egommerce/go-api-pkg v0.2.72 h1:289HdYxa5ZzKEirxZfat1i6B7jThvZwtvO3SZykFTcg= +git.pbiernat.io/egommerce/go-api-pkg v0.2.72/go.mod h1:XIy2mmvRNIzQmYIUAcDZafhRPxTQFS2HDmsK7ZQ6980= github.com/Azure/azure-sdk-for-go v44.0.0+incompatible h1:e82Yv2HNpS0kuyeCrV29OPKvEiqfs2/uJHic3/3iKdg= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= github.com/Azure/go-autorest/autorest v0.11.18 h1:90Y4srNYrwOtAgVo3ndrQkTYn6kf1Eg/AjTFJ8Is2aM= @@ -64,8 +64,8 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/aliyun/alibaba-cloud-sdk-go v1.62.156 h1:K4N91T1+RlSlx+t2dujeDviy4ehSGVjEltluDgmeHS4= -github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= -github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= +github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1RINW/+RMTVmiwxETico2l3gxJA= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= @@ -177,15 +177,15 @@ github.com/go-ozzo/ozzo-validation v3.6.0+incompatible h1:msy24VGS42fKO9K1vLz82/ github.com/go-pg/migrations/v8 v8.1.0 h1:bc1wQwFoWRKvLdluXCRFRkeaw9xDU4qJ63uCAagh66w= github.com/go-pg/migrations/v8 v8.1.0/go.mod h1:o+CN1u572XHphEHZyK6tqyg2GDkRvL2bIoLNyGIewus= github.com/go-pg/pg/v10 v10.4.0/go.mod h1:BfgPoQnD2wXNd986RYEHzikqv9iE875PrFaZ9vXvtNM= -github.com/go-pg/pg/v10 v10.10.7 h1:Q7Bs45kP9MIg03v/ejwdqsPd1T0cecgeDoTJVg/UJuQ= -github.com/go-pg/pg/v10 v10.10.7/go.mod h1:GLmFXufrElQHf5uzM3BQlcfwV3nsgnHue5uzjQ6Nqxg= +github.com/go-pg/pg/v10 v10.11.1 h1:vYwbFpqoMpTDphnzIPshPPepdy3VpzD8qo29OFKp4vo= +github.com/go-pg/pg/v10 v10.11.1/go.mod h1:ExJWndhDNNftBdw1Ow83xqpSf4WMSJK8urmXD5VXS1I= github.com/go-pg/zerochecker v0.2.0 h1:pp7f72c3DobMWOb2ErtZsnrPaSvHd2W4o9//8HtF4mU= github.com/go-pg/zerochecker v0.2.0/go.mod h1:NJZ4wKL0NmTtz0GKCoJ8kym6Xn/EQzXRl2OnAe7MmDo= github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gofiber/fiber/v2 v2.40.1 h1:pc7n9VVpGIqNsvg9IPLQhyFEMJL8gCs1kneH5D1pIl4= -github.com/gofiber/fiber/v2 v2.40.1/go.mod h1:Gko04sLksnHbzLSRBFWPFdzM9Ws9pRxvvIaohJK1dsk= +github.com/gofiber/fiber/v2 v2.52.5 h1:tWoP1MJQjGEe4GB5TUGOi7P2E0ZMMRx5ZTG4rT+yGMo= +github.com/gofiber/fiber/v2 v2.52.5/go.mod h1:KEOE+cXMhXG0zHc9d8+E38hoX+ZN7bhOtgeF2oT6jrQ= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -250,8 +250,8 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= @@ -368,8 +368,8 @@ github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsU github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= -github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys= -github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= +github.com/jackc/pgconn v1.14.3 h1:bVoTr12EGANZz66nZPkMInAV/KHD2TxH9npjXXgiB3w= +github.com/jackc/pgconn v1.14.3/go.mod h1:RZbme4uasqzybK2RK5c65VsHxoyaml09lx3tXOcO/VM= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= @@ -377,6 +377,7 @@ github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZ github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A= github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= @@ -384,26 +385,30 @@ github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvW github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y= -github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= +github.com/jackc/pgproto3/v2 v2.3.3 h1:1HLSx5H+tXR9pW3in3zaztoEwQYRC9SQaYUHjTSUOag= +github.com/jackc/pgproto3/v2 v2.3.3/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= +github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= -github.com/jackc/pgtype v1.13.0 h1:XkIc7A+1BmZD19bB2NxrtjJweHxQ9agqvM+9URc68Cg= -github.com/jackc/pgtype v1.13.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgtype v1.14.3 h1:h6W9cPuHsRWQFTWUZMAKMgG5jSwQI0Zurzdvlx3Plus= +github.com/jackc/pgtype v1.14.3/go.mod h1:aKeozOde08iifGosdJpz9MBZonJOUJxqNpPBcMJTlVA= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= -github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c h1:Dznn52SgVIVst9UyOT9brctYUgxs+CvVfPaC3jKrA50= github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= +github.com/jackc/pgx/v4 v4.18.2 h1:xVpYkNR5pk5bMCZGfClbO962UIqVABcAGt7ha1s/FeU= +github.com/jackc/pgx/v4 v4.18.2/go.mod h1:Ey4Oru5tH5sB6tV7hDmfWFahwF15Eb7DNXlRKx2CkVw= github.com/jackc/pgx/v5 v5.1.1 h1:pZD79K1SYv8wc2HmCQA6VdmRQi7/OtCfv9bM3WAXUYA= github.com/jackc/pgx/v5 v5.1.1/go.mod h1:Ptn7zmohNsWEsdxRawMzk3gaKma2obW+NWTnKa0S4nk= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle/v2 v2.1.2 h1:0f7vaaXINONKTsxYDn4otOAiJanX/BMeAtY//BXqzlg= github.com/jackc/puddle/v2 v2.1.2/go.mod h1:2lpufsF5mRHO6SuZkm0fNYxM6SWHfvyFj62KwNzgels= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= @@ -427,8 +432,8 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY= -github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= +github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= +github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -464,10 +469,10 @@ github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOA github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= -github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= @@ -524,8 +529,8 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= -github.com/philhofer/fwd v1.1.1 h1:GdGcTjf5RNAxwS4QLsiMzJYj5KEvPJD3Abr261yRQXQ= -github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= +github.com/philhofer/fwd v1.1.2 h1:bnDivRJ1EWPjUIRXV5KfORO897HTbpFAQddBdE8t7Gw= +github.com/philhofer/fwd v1.1.2/go.mod h1:qkPdfjR2SIEbspLqpe1tO4n5yICnr2DY7mqEx2tUTP0= github.com/pierrec/lz4 v2.5.2+incompatible h1:WCjObylUIOlKy/+7Abdn34TLIkXiA4UWUMhxq9m9ZXI= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -570,9 +575,12 @@ github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= +github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw= +github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o= github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03 h1:Wdi9nwnhFNAlseAOekn6B5G/+GMtks9UKbvRU/CMM/o= -github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= @@ -596,8 +604,6 @@ github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0 github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 h1:JIAuq3EEf9cgbU6AtGPK4CTG3Zf6CKMNqf0MHTggAUA= github.com/softlayer/softlayer-go v0.0.0-20180806151055-260589d94c7d h1:bVQRCxQvfjNUeRqaY/uT0tFuvuFY0ulgnczuR684Xic= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/streadway/amqp v1.0.0 h1:kuuDrUJFZL1QYL9hUNuCxNObNzB0bV/ZG5jV3RWAQgo= -github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= @@ -613,12 +619,13 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tencentcloud/tencentcloud-sdk-go v1.0.162 h1:8fDzz4GuVg4skjY2B0nMN7h6uN61EDVkuLyI2+qGHhI= -github.com/tinylib/msgp v1.1.6 h1:i+SbKraHhnrf9M5MYmvQhFnbLhAXSDWF8WWsuyRdocw= -github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw= +github.com/tinylib/msgp v1.1.8 h1:FCXC1xanKO4I8plpHGH2P7koL/RzZs12l/+r7vakfm0= +github.com/tinylib/msgp v1.1.8/go.mod h1:qkpG+2ldGg4xRFmx+jfTvZPxfGFhi64BcnL9vkCm/Tw= github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo= @@ -627,8 +634,8 @@ github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 h1:G3dpKMzFDjgEh2q1Z github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasthttp v1.41.0 h1:zeR0Z1my1wDHTRiamBCXVglQdbUwgb9uWG3k1HQz6jY= -github.com/valyala/fasthttp v1.41.0/go.mod h1:f6VbjjoI3z1NDOZOv17o6RvtRSWxC77seBFc2uWtgiY= +github.com/valyala/fasthttp v1.52.0 h1:wqBQpxH71XW0e2g+Og4dzQM8pk34aFYlA1Ga8db7gU0= +github.com/valyala/fasthttp v1.52.0/go.mod h1:hf5C4QnVMkNXMspnsUlfM3WitlgYflyhHYoKol/szxQ= github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVSA8= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/vmihailenco/bufpool v0.1.11 h1:gOq2WmBrq0i2yW5QJ16ykccQ4wH9UyEsgLm6czKAd94= @@ -646,7 +653,7 @@ github.com/vmware/govmomi v0.18.0 h1:f7QxSmP7meCtoAmiKZogvVbLInT+CZx6Px6K5rYsJZo github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ= @@ -670,8 +677,8 @@ go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.1.10 h1:z+mqJhf6ss6BSfSM671tgKyZBFPTTJM+HLxnhPC3wu0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= @@ -682,6 +689,7 @@ go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180910181607-0e37d006457b/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -695,10 +703,10 @@ golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= +golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -723,7 +731,6 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -732,6 +739,9 @@ golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -769,17 +779,19 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201016165138-7b1cca2348c0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220906165146-f3363e06e74c/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= +golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -796,9 +808,10 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -858,19 +871,31 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210923061019-b8560ed6a9b7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -879,8 +904,12 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -933,7 +962,9 @@ golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1063,8 +1094,9 @@ k8s.io/client-go v0.26.2 h1:s1WkVujHX3kTp4Zn4yGNFK+dlDXy1bAAkIl+cFAiuYI= k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+OGxg8HsuBr/5f6tVAjDu6E= k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5 h1:kmDqav+P+/5e1i9tFfHq1qcF3sOrDp+YEkVDAHu7Jwk= -mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w= mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ= +mellium.im/sasl v0.3.1 h1:wE0LW6g7U83vhvxjC1IY8DnXM+EU095yeo8XClvCdfo= +mellium.im/sasl v0.3.1/go.mod h1:xm59PUYpZHhgQ9ZqoJ5QaCqzWMi8IeS49dhp6plPCzw= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/src/internal/app/app.go b/src/internal/app/app.go new file mode 100644 index 0000000..da47d15 --- /dev/null +++ b/src/internal/app/app.go @@ -0,0 +1,215 @@ +package app + +import ( + "log" + "os" + "os/signal" + "strconv" + "syscall" + + redis "github.com/go-redis/redis/v8" + "github.com/jackc/pgx/v5/pgxpool" + amqp "github.com/rabbitmq/amqp091-go" + + "git.pbiernat.io/egommerce/go-api-pkg/consul" + "git.pbiernat.io/egommerce/go-api-pkg/fluentd" + + cnf "git.pbiernat.io/egommerce/catalog-service/internal/config" + srv "git.pbiernat.io/egommerce/catalog-service/internal/server" + db "git.pbiernat.io/egommerce/catalog-service/pkg/database" +) + +type ( + Doer interface { + Start(while chan struct{}) error + OnShutdown(*App) + } + Application interface { + Start(while chan struct{}) + RegisterHelper(OptionFn) error + Shutdown() + } + OptionFn func(*App) error + + App struct { + cnf *srv.ServerConfig + + doer Doer + + // helpers + Cache *redis.Client + Database *pgxpool.Pool + Eventbus *amqp.Channel + Logger *fluentd.Logger + Registry *consul.Service + } +) + +func NewApp(c *cnf.ServerConfig, d Doer) *App { + app := &App{ + cnf: c, + doer: d, + } + + // while := make(chan struct{}) + // // err := srv.Base.Start(while) + // err := app.Doer.Start(while) + // <-while + + // if err != nil { + // log.Fatalf("Failed to start application. Reason: %v\n", err) + // os.Exit(1) + // } + + // os.Exit(0) + + return app +} + +func (a *App) Start(while chan struct{}) error { + go func() { + sigint := make(chan os.Signal, 1) + signal.Notify(sigint, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) + <-sigint + + a.doer.OnShutdown(a) + a.Shutdown() + + close(while) + }() + + run := a.createRunFile("./app.run") // FIXME path... + defer a.removeRunFile(run) + + a.doer.Start(while) +} + +func (a *App) RegisterHelper(name string, opt OptionFn) error { + if err := opt(a); err != nil { + log.Fatalf("Failed to attach extension to the server. Err: %v\n", err) + } +} + +func (a *App) Shutdown() { + // ... +} + +func (a *App) createRunFile(path string) *os.File { + run, err := os.Create(path) + if err != nil { + log.Fatalf("Failed to create run file. Reason: %v\n", err) + os.Exit(1) + } + run.WriteString(strconv.Itoa(os.Getpid())) + + return run +} + +func (a *App) removeRunFile(f *os.File) error { + return f.Close() +} + +func WithCache() OptionFn { + return func(a *App) error { + a.Cache = redis.NewClient(&redis.Options{ + Addr: a.cnf.CacheAddr, + Password: a.cnf.CachePassword, + DB: 0, + }) + + return nil + } +} + +func WithDatabase() OptionFn { + return func(a *App) error { + dbConn, err := db.Connect(a.cnf.DbURL) + if err != nil { + log.Fatalf("Failed to connect to the Database: %s. Err: %v\n", a.cnf.DbURL, err) + os.Exit(1) // TODO: retry in background... for now treat as integraded service... + } + + a.Database = dbConn + + return nil + } +} + +func WithEventbus() OptionFn { + return func(a *App) error { + conn, err := amqp.Dial(a.cnf.EventBusURL) + if err != nil { + log.Fatalf("Failed to connect to the Eventbus: %s. Err: %v\n", a.cnf.EventBusURL, err) + } + + chn, err := conn.Channel() + if err != nil { + log.Fatalf("Failed to open new Eventbus channel. Err: %v\n", err) + } + + a.Eventbus = chn + + return nil + } +} + +func WithLogger() OptionFn { + return func(a *App) error { + logHost, logPort, err := fluentd.ParseAddr(a.cnf.LoggerAddr) + if err != nil { + log.Fatalf("Failed to parse Fluentd address: %s. Err: %v", a.cnf.LoggerAddr, err) + } + + logger, err := fluentd.NewLogger(a.cnf.Base.GetAppFullName(), logHost, logPort) + if err != nil { + log.Fatalf("Failed to connect to the Fluentd on %s:%d. Err: %v", logHost, logPort, err) + } + + a.Logger = logger + + return nil + } +} + +func WithRegistry() OptionFn { + return func(a *App) error { + port, _ := strconv.Atoi(a.cnf.Base.NetAddr[1:]) // FIXME: can be IP:PORT or :PORT + // log.Printf("Consul retrieved port: %v", port) + registry, err := consul.NewService(a.cnf.RegistryAddr, a.cnf.Base.AppID, a.cnf.Base.AppName, a.cnf.Base.RegistryDomainOverIP, a.cnf.Base.GetIP(), a.cnf.Base.AppDomain, a.cnf.Base.PathPrefix, port) + if err != nil { + log.Fatalf("Failed to connect to the Consul on: %s. Err: %v", c.RegistryAddr, err) + } + + err = registry.Register() + if err != nil { + log.Fatalf("Failed to register in the Consul service. Err: %v", err) + } + + registry.RegisterHealthChecks() + // a.registerKVUpdater() // FIXME run as goroutine + + a.Registry = registry + + // svc, _ := registry.Connect() + // tlsCnf := svc.ServerTLSConfig() + // s.Base.App.Server().TLSConfig = tlsCnf + // fmt.Println("Podmiana configa TLS") + // defer svc.Close() + + // go func() { // Consul KV updater + // ticker := time.NewTicker(time.Second * 15) + // for range ticker.C { + // fetchKVConfig(s) // FIXME: duplicated in worker + // } + // }() + + // go func() { // Server metadata cache updater + // ticker := time.NewTicker(time.Second * 5) + // for range ticker.C { + // s.cacheMetadata() + // } + // }() + + return nil + } +} diff --git a/src/internal/config/config.go b/src/internal/config/config.go deleted file mode 100644 index 95f4bd6..0000000 --- a/src/internal/config/config.go +++ /dev/null @@ -1,66 +0,0 @@ -package common - -import ( - "os" - - srv "git.pbiernat.dev/egommerce/catalog-service/pkg/server" - cnf "git.pbiernat.dev/egommerce/go-api-pkg/config" -) - -const ( - // defAppDomain = "basket-svc" - // defEventBusURL = "amqp://guest:guest@esb.service.ego.io:5672" - defAppName = "basket-svc" - defAppDomain = "basket-svc" - defCacheAddr = "api-cache:6379" - defCachePassword = "12345678" - defDbURL = "postgres://postgres:12345678@db-postgres:5432/egommerce" - defEventBusURL = "amqp://guest:guest@api-eventbus:5672" - defKVNmspc = "dev.egommerce/service/basket" - defLoggerAddr = "api-logger:24224" - defNetAddr = ":80" - defMongoDbURL = "mongodb://mongodb:12345678@mongo-db:27017" - defPathPrefix = "/basket" - defRegistryAddr = "api-registry:8500" - defEbEventsExchange = "api-events" - defEbEventsQueue = "basket-svc" -) - -type Config struct { - Base *srv.Config - - LoggerAddr string `json:"logger_addr"` - DbURL string `json:"db_url"` - CacheAddr string `json:"cache_addr"` - CachePassword string `json:"cache_password"` - MongoDbUrl string `json:"mongodb_url"` - EventBusURL string `json:"eventbus_url"` - EventBusExchange string `json:"eventbus_exchange"` - EventBusQueue string `json:"eventbus_queue"` - KVNamespace string - RegistryAddr string - - // Fields with JSON mappings are available through Consul KV storage -} - -func NewConfig(name string) *Config { - c := new(Config) - c.Base = new(srv.Config) - - c.Base.AppID, _ = os.Hostname() - c.Base.AppName = name - c.Base.AppDomain = cnf.GetEnv("APP_DOMAIN", defAppDomain) - c.Base.NetAddr = cnf.GetEnv("SERVER_ADDR", defNetAddr) - c.Base.PathPrefix = cnf.GetEnv("APP_PATH_PREFIX", defPathPrefix) - - c.CacheAddr = cnf.GetEnv("CACHE_ADDR", defCacheAddr) - c.CachePassword = cnf.GetEnv("CACHE_PASSWORD", defCachePassword) - c.DbURL = cnf.GetEnv("DATABASE_URL", defDbURL) - c.EventBusExchange = defEbEventsExchange - c.EventBusURL = cnf.GetEnv("EVENTBUS_URL", defEventBusURL) - c.KVNamespace = cnf.GetEnv("APP_KV_NAMESPACE", defKVNmspc) - c.LoggerAddr = cnf.GetEnv("LOGGER_ADDR", defLoggerAddr) - c.RegistryAddr = cnf.GetEnv("REGISTRY_ADDR", defRegistryAddr) - - return c -} diff --git a/src/internal/config.go b/src/internal/config/server.go similarity index 55% rename from src/internal/config.go rename to src/internal/config/server.go index 3925ee3..65ed96a 100644 --- a/src/internal/config.go +++ b/src/internal/config/server.go @@ -1,20 +1,18 @@ -package internal +package config import ( "fmt" "net" "os" + "time" - srv "git.pbiernat.dev/egommerce/catalog-service/pkg/server" - cnf "git.pbiernat.dev/egommerce/go-api-pkg/config" + cnf "git.pbiernat.io/egommerce/go-api-pkg/config" ) const ( - // defAppDomain = "catalog-svc" - // defEventBusURL = "amqp://guest:guest@esb.service.ego.io:5672" - defAppName = "catalog-svc" - defAppDomain = "catalog-svc" - defCacheAddr = "api-cache:6379" + defName = "catalog-svc" + defDomain = "catalog-svc" + defCacheAddr = "egommerce.local:6379" defCachePassword = "12345678" defDbURL = "postgres://postgres:12345678@db-postgres:5432/egommerce" defEventBusURL = "amqp://guest:guest@api-eventbus:5672" @@ -28,8 +26,17 @@ const ( defEbEventsQueue = "catalog-svc" ) -type Config struct { - Base *srv.Config +type ServerConfig struct { + ID string + Name string + Domain string + NetAddr string + RegistryDomainOverIP string + PathPrefix string + + IdleTimeout time.Duration // miliseconds + ReadTimeout time.Duration // miliseconds + WriteTimeout time.Duration // miliseconds LoggerAddr string `json:"logger_addr"` DbURL string `json:"db_url"` @@ -42,21 +49,18 @@ type Config struct { KVNamespace string RegistryAddr string - // Fields with json mapping are available trough ConsulKV - // HttpReadTimeout int `json:"http_read_timeout"` - // HttpWriteTimeout int `json:"http_write_timeout"` - // HttpIdleTimeout int `json:"http_idle_timeout"` + // Fields with JSON mappings are available through Consul KV storage } -func NewConfig(name string) *Config { - c := new(Config) - c.Base = new(srv.Config) +func NewServerConfig(name string) *ServerConfig { + c := new(ServerConfig) - c.Base.AppID, _ = os.Hostname() - c.Base.AppName = name - c.Base.AppDomain = cnf.GetEnv("APP_DOMAIN", defAppDomain) - c.Base.NetAddr = cnf.GetEnv("SERVER_ADDR", defNetAddr) - c.Base.PathPrefix = cnf.GetEnv("APP_PATH_PREFIX", defPathPrefix) + c.ID, _ = os.Hostname() + c.Name = name + c.Domain = cnf.GetEnv("APP_DOMAIN", defDomain) + c.NetAddr = cnf.GetEnv("SERVER_ADDR", defNetAddr) + c.RegistryDomainOverIP = cnf.GetEnv("REGISTRY_USE_DOMAIN_OVER_IP", "false") + c.PathPrefix = cnf.GetEnv("APP_PATH_PREFIX", defPathPrefix) c.CacheAddr = cnf.GetEnv("CACHE_ADDR", defCacheAddr) c.CachePassword = cnf.GetEnv("CACHE_PASSWORD", defCachePassword) @@ -70,16 +74,20 @@ func NewConfig(name string) *Config { return c } -func (c *Config) GetAppFullName() string { - return fmt.Sprintf("%s_%s", c.Base.AppName, c.Base.AppID) +func (c *ServerConfig) GetAppFullName() string { + return fmt.Sprintf("%s_%s", c.Name, c.ID) } -func getIP() string { +// func (c *ServerConfig) GetAddressForRegistry() string { + +// } + +func (c *ServerConfig) GetIP() string { host, _ := os.Hostname() ips, _ := net.LookupIP(host) - for _, ip := range ips { - return ip.String() - } + // for _, ip := range ips { + // return ip.String() + // } - return host // hostname for the rescue... NOT! + return ips[0].String() } diff --git a/src/internal/server/catalog_handler.go b/src/internal/server/catalog_handler.go index 378fb6c..17b03b3 100644 --- a/src/internal/server/catalog_handler.go +++ b/src/internal/server/catalog_handler.go @@ -6,9 +6,10 @@ import ( "github.com/gofiber/fiber/v2" "github.com/google/uuid" - def "git.pbiernat.dev/egommerce/api-entities/http" - "git.pbiernat.dev/egommerce/catalog-service/internal/service" - "git.pbiernat.dev/egommerce/catalog-service/internal/ui" + def "git.pbiernat.io/egommerce/api-entities/http" + + "git.pbiernat.io/egommerce/catalog-service/internal/service" + "git.pbiernat.io/egommerce/catalog-service/internal/ui" ) func (s *Server) GetProductListHandler(c *fiber.Ctx) error { diff --git a/src/internal/server/health_handler.go b/src/internal/server/health_handler.go index a69b881..f171220 100644 --- a/src/internal/server/health_handler.go +++ b/src/internal/server/health_handler.go @@ -1,7 +1,7 @@ package server import ( - def "git.pbiernat.dev/egommerce/api-entities/http" + def "git.pbiernat.io/egommerce/api-entities/http" "github.com/gofiber/fiber/v2" ) diff --git a/src/internal/server/middleware.go b/src/internal/server/middleware.go index a059d7c..165472c 100644 --- a/src/internal/server/middleware.go +++ b/src/internal/server/middleware.go @@ -5,7 +5,7 @@ import ( "github.com/gofiber/fiber/v2" - "git.pbiernat.dev/egommerce/go-api-pkg/fluentd" + "git.pbiernat.io/egommerce/go-api-pkg/fluentd" ) // "github.com/gofiber/fiber/v2" diff --git a/src/internal/server/router.go b/src/internal/server/router.go index 6f8410a..af8cba9 100644 --- a/src/internal/server/router.go +++ b/src/internal/server/router.go @@ -6,21 +6,21 @@ import ( var ( defaultCORS = cors.New(cors.Config{ - AllowOrigins: "*", - AllowCredentials: true, - AllowMethods: "GET, POST, PATCH, PUT, DELETE, OPTIONS", - AllowHeaders: "Accept, Authorization, Content-Type, Vary, X-Request-Id", + AllowOrigins: "*", + // AllowCredentials: true, + AllowMethods: "GET, POST, PATCH, PUT, DELETE, OPTIONS", + AllowHeaders: "Accept, Authorization, Content-Type, Vary, X-Request-Id", }) ) func SetupRouter(s *Server) { - s.Base.Options("*", defaultCORS) - s.Base.Use(defaultCORS) + s.Options("*", defaultCORS) + s.Use(defaultCORS) - s.Base.Get("/health", s.HealthHandler) - s.Base.Get("/config", s.ConfigHandler) + s.Get("/health", s.HealthHandler) + s.Get("/config", s.ConfigHandler) - api := s.Base.Group("/api") + api := s.Group("/api") v1 := api.Group("/v1") v1.Get("/product", s.GetProductListHandler) // v1.Get("/product/:productId", s.GetProductHandler) diff --git a/src/internal/server/server.go b/src/internal/server/server.go index bf5d3e7..73393c4 100644 --- a/src/internal/server/server.go +++ b/src/internal/server/server.go @@ -1,210 +1,119 @@ package server import ( - "bytes" - "encoding/json" + "fmt" "log" - "os" - "strconv" + "net" "time" - redis "github.com/go-redis/redis/v8" - "github.com/jackc/pgx/v5/pgxpool" - "github.com/streadway/amqp" + "github.com/gofiber/fiber/v2" - "git.pbiernat.dev/egommerce/go-api-pkg/consul" - "git.pbiernat.dev/egommerce/go-api-pkg/fluentd" - - db "git.pbiernat.dev/egommerce/catalog-service/pkg/database" - p "git.pbiernat.dev/egommerce/catalog-service/pkg/server" - - cnf "git.pbiernat.dev/egommerce/catalog-service/internal/config" + "git.pbiernat.io/egommerce/api-entities/http" + "git.pbiernat.io/egommerce/catalog-service/app" + cnf "git.pbiernat.io/egommerce/catalog-service/config" ) type ( Server struct { - Base *p.Server - Config *cnf.Config - Cache *redis.Client - Database *pgxpool.Pool - Eventbus *amqp.Channel - Logger *fluentd.Logger - Registry *consul.Service + *fiber.App + cnf *cnf.ServerConfig + + addr string // e.g. "127.0.0.1:80" + + ShutdownFn } - OptionFn func(*Server) error // FIXME: similar in worker + HeaderRequestID struct { + RequestID string `reqHeader:"x-request-id"` + } + ShutdownFn func() error ) -func New(c *cnf.Config, opts ...OptionFn) *Server { - svr := &Server{ - Base: p.New(c.Base), - Config: c, +func New(conf *cnf.Config) *Server { + return &Server{ + App: fiber.New(fiber.Config{ + AppName: conf.ID, + ServerHeader: conf.Name + ":" + conf.ID, + ReadTimeout: conf.ReadTimeout * time.Millisecond, + WriteTimeout: conf.WriteTimeout * time.Millisecond, + IdleTimeout: conf.IdleTimeout * time.Millisecond, + }), + cnf: conf, + addr: conf.NetAddr, } - - for _, opt := range opts { - if err := opt(svr); err != nil { - log.Fatalf("Failed to attach extension to the server. Err: %v\n", err) - } - } - - svr.Base.ShutdownFn = svr.Shutdown() - - SetupMiddleware(svr) - SetupRouter(svr) - - return svr } -func (s *Server) Shutdown() p.ShutdownFn { - return func() error { - s.Logger.Log("Server %s is going down...", s.Base.AppID) +func (s *Server) Init() { + // svr.Base.ShutdownFn = svr.Shutdown() - s.Registry.Unregister() - // s.clearMetadataCache() - s.Eventbus.Close() - s.Database.Close() - s.Logger.Log("Gone.") - s.Logger.Close() + SetupMiddleware(s) + SetupRouter(s) +} - return s.Base.Shutdown() +func (s *Server) Start(while chan struct{}) { + // fmt.Println("[DOER] Started server at: " + s.addr) + ln, _ := net.Listen("tcp", s.addr) + // ln = tls.NewListener(ln, s.App.Server().TLSConfig) + err := s.Listener(ln) + if err != nil { + log.Fatalf("Failed to start server: %s. Reason: %v\n", s.cnf.ID, err) + close(while) } + <-while + + // return err +} + +func (s *Server) OnShutdown(a *app.App) { + a.Logger.Log("Server %s is going down...", a.cnf.ID) + + fmt.Println("Unregistering...") + a.Registry.Unregister() + // a.clearMetadataCache() + a.Eventbus.Close() + a.Database.Close() + a.Logger.Log("Gone.") + a.Logger.Close() +} + +func (s *Server) GetRequestID(c *fiber.Ctx) (string, error) { + var hdr = new(HeaderRequestID) + if err := c.ReqHeaderParser(hdr); err != nil { + return "", err + } + + return hdr.RequestID, nil +} + +func (s *Server) Error(c *fiber.Ctx, code int, msg string) error { + return c.Status(code).JSON(http.ErrorResponse{Error: msg}) } // @CHECK: merge s.Config and s.Base.Config to display all config as one array/map -func (s *Server) registerKVUpdater() { // @FIXME: merge duplication in server.go and worker.go - go func() { - ticker := time.NewTicker(time.Second * 10) - for range ticker.C { - config, _, err := s.Registry.KV().Get(s.Config.KVNamespace, nil) - if err != nil || config == nil { - return - } +// func (s *Server) registerKVUpdater() { // @FIXME: merge duplication in server.go and worker.go +// go func() { +// ticker := time.NewTicker(time.Second * 10) +// for range ticker.C { +// config, _, err := s.Registry.KV().Get(s.cnf.KVNamespace, nil) +// if err != nil || config == nil { +// return +// } - kvCnf := bytes.NewBuffer(config.Value) - decoder := json.NewDecoder(kvCnf) - if err := decoder.Decode(&s.Config); err != nil { - return - } - } - }() -} - -// func (s *Server) clearMetadataCache() { -// ctx := context.Background() -// key, address := s.getMetadataIPsKey(), s.Config.Base.AppID - -// s.Cache.LRem(ctx, key, 0, address) +// kvCnf := bytes.NewBuffer(config.Value) +// decoder := json.NewDecoder(kvCnf) +// if err := decoder.Decode(&s.cnf); err != nil { +// return +// } +// } +// }() // } -// func (s *Server) getMetadataIPsKey() string { -// return "internal__" + s.Base.Config.AppName + "__ips" -// } +// // func (s *Server) clearMetadataCache() { +// // ctx := context.Background() +// // key, address := s.getMetadataIPsKey(), s.cnf.Base.AppID -func WithCache(c *cnf.Config) OptionFn { - return func(s *Server) error { - s.Cache = redis.NewClient(&redis.Options{ - Addr: s.Config.CacheAddr, - Password: s.Config.CachePassword, - DB: 0, - }) +// // s.Cache.LRem(ctx, key, 0, address) +// // } - return nil - } -} - -func WithDatabase(c *cnf.Config) OptionFn { - return func(s *Server) error { - dbConn, err := db.Connect(s.Config.DbURL) - if err != nil { - log.Fatalf("Failed to connect to the Database: %s. Err: %v\n", s.Config.DbURL, err) - os.Exit(1) - } - - s.Database = dbConn - - return nil - } -} - -func WithEventbus(c *cnf.Config) OptionFn { - return func(s *Server) error { - conn, err := amqp.Dial(s.Config.EventBusURL) - if err != nil { - log.Fatalf("Failed to connect to the Eventbus: %s. Err: %v\n", s.Config.EventBusURL, err) - } - - chn, err := conn.Channel() - if err != nil { - log.Fatalf("Failed to open new Eventbus channel. Err: %v\n", err) - } - - s.Eventbus = chn - - return nil - } -} - -func WithLogger(c *cnf.Config) OptionFn { - return func(s *Server) error { - logHost, logPort, err := fluentd.ParseAddr(s.Config.LoggerAddr) - if err != nil { - log.Fatalf("Failed to parse Fluentd address: %s. Err: %v", s.Config.LoggerAddr, err) - } - - logger, err := fluentd.NewLogger(s.Config.Base.GetAppFullName(), logHost, logPort) - if err != nil { - log.Fatalf("Failed to connect to the Fluentd on %s:%d. Err: %v", logHost, logPort, err) - } - - s.Logger = logger - - return nil - } -} - -func WithRegistry(c *cnf.Config) OptionFn { - return func(s *Server) error { - c := s.Config - - port, _ := strconv.Atoi(c.Base.NetAddr[1:]) // FIXME: can be IP:PORT which will cause error - registry, err := consul.NewService(c.RegistryAddr, c.Base.AppID, c.Base.AppName, c.Base.GetIP(), c.Base.AppDomain, c.Base.PathPrefix, port) - if err != nil { - log.Fatalf("Failed to connect to the Consul on: %s. Err: %v", c.RegistryAddr, err) - } - - err = registry.Register() - if err != nil { - log.Fatalf("Failed to register in the Consul service. Err: %v", err) - } - - registry.RegisterHealthChecks() - s.registerKVUpdater() - - s.Registry = registry - - // svc, err := registry.Connect() - // if err != nil { - // log.Fatalf("Failed to initialize Consul Connect service. Err: %v", err) - // } - - // confUpdated := make(chan bool, 1) - // go func(s *Server) { // startup register - // ticker := time.NewTicker(time.Second * 5) - // for range ticker.C { - // tlsCnf := svc.ServerTLSConfig() - // if len(tlsCnf.Certificates) > 0 { // FIXME more complex checking(validity date) - // fmt.Println("certs: ", tlsCnf.Certificates) - // confUpdated <- true - // } - // s.Base.App.Server().TLSConfig = tlsCnf - // fmt.Printf("CERTY TLS [routine]: %v\n", tlsCnf.Certificates) - // } - // }(s) - - // fmt.Println("Waiting until receive certs...") - // <-confUpdated - // fmt.Println("CONTINUE STARTING...") - // defer svc.Close() // tmp - ensure svc.Close is called on exit - - return nil - } -} +// // func (s *Server) getMetadataIPsKey() string { +// // return "internal__" + s.cnf.Name + "__ips" +// // } diff --git a/src/internal/service/catalog.go b/src/internal/service/catalog.go index 1ef2824..dacf538 100644 --- a/src/internal/service/catalog.go +++ b/src/internal/service/catalog.go @@ -3,13 +3,13 @@ package service import ( "context" - "git.pbiernat.dev/egommerce/api-entities/model" - "git.pbiernat.dev/egommerce/catalog-service/internal/event" - "git.pbiernat.dev/egommerce/go-api-pkg/fluentd" - "git.pbiernat.dev/egommerce/go-api-pkg/rabbitmq" + "git.pbiernat.io/egommerce/api-entities/model" + "git.pbiernat.io/egommerce/catalog-service/internal/event" + "git.pbiernat.io/egommerce/go-api-pkg/fluentd" + "git.pbiernat.io/egommerce/go-api-pkg/rabbitmq" "github.com/georgysavva/scany/v2/pgxscan" "github.com/jackc/pgx/v5/pgxpool" - "github.com/streadway/amqp" + amqp "github.com/rabbitmq/amqp091-go" ) const ( diff --git a/src/internal/ui/catalog.go b/src/internal/ui/catalog.go index d9df25b..2e6be54 100644 --- a/src/internal/ui/catalog.go +++ b/src/internal/ui/catalog.go @@ -4,8 +4,8 @@ import ( "context" "time" - def "git.pbiernat.dev/egommerce/api-entities/http" - "git.pbiernat.dev/egommerce/catalog-service/internal/service" + def "git.pbiernat.io/egommerce/api-entities/http" + "git.pbiernat.io/egommerce/catalog-service/internal/service" ) func GetProductList(srv *service.CatalogService, categoryID int, reqID string) ([]def.GetProductResponse, error) { diff --git a/src/internal/worker/command.go b/src/internal/worker/command.go index 10d7407..e03af15 100644 --- a/src/internal/worker/command.go +++ b/src/internal/worker/command.go @@ -1,7 +1,7 @@ package worker import ( - "git.pbiernat.dev/egommerce/catalog-service/internal/service" + "git.pbiernat.io/egommerce/catalog-service/internal/service" ) var ( diff --git a/src/internal/worker/ext.go b/src/internal/worker/ext.go index f8304ea..5d4c3d1 100644 --- a/src/internal/worker/ext.go +++ b/src/internal/worker/ext.go @@ -1,135 +1,35 @@ package worker -import ( - "bytes" - "encoding/json" - "os" - "time" +// func WithRegistry(c *cnf.Config) OptionFn { +// return func(w *Worker) error { +// registry, err := consul.NewService(c.RegistryAddr, c.Base.AppID, c.Base.AppName, c.Base.AppID, "", "", 0) +// if err != nil { +// w.Logger.Log("Error connecting to %s: %v", c.RegistryAddr, err) +// } - "github.com/go-redis/redis/v8" +// w.Registry = registry - "git.pbiernat.dev/egommerce/catalog-service/internal" - "git.pbiernat.dev/egommerce/catalog-service/pkg/database" +// go func(w *Worker) { // Fetch Consul KV config and store it in app config +// ticker := time.NewTicker(time.Second * 15) +// for range ticker.C { +// fetchKVConfig(w) // FIXME: duplicated in server +// } +// }(w) - "git.pbiernat.dev/egommerce/go-api-pkg/consul" - "git.pbiernat.dev/egommerce/go-api-pkg/fluentd" - "git.pbiernat.dev/egommerce/go-api-pkg/rabbitmq" -) +// return nil +// } -func WithCache(c *internal.Config) OptionFn { - return func(w *Worker) error { - conn := redis.NewClient(&redis.Options{ - Addr: c.CacheAddr, - Password: c.CachePassword, - DB: 0, - }) +// } - w.Cache = conn +// func fetchKVConfig(w *Worker) { // @FIXME: merge duplication in server.go and worker.go +// config, _, err := w.Registry.KV().Get(w.Config.KVNamespace, nil) +// if err != nil || config == nil { +// return +// } - return nil - } -} - -func WithDatabase(c *internal.Config) OptionFn { - return func(w *Worker) error { - conn, err := database.Connect(c.DbURL) - if err != nil { - w.Logger.Log("Failed to connect to Database server: %v\n", err) - os.Exit(1) - } - - w.Database = conn - - return nil - } -} - -func WithEventbus(c *internal.Config) OptionFn { - return func(w *Worker) error { - _, chn, err := rabbitmq.Open(c.EventBusURL) - if err != nil { - w.Logger.Log("Failed to connect to EventBus server: %v\n", err) - os.Exit(1) - } - - err = rabbitmq.NewExchange(chn, c.EventBusExchange) - if err != nil { - w.Logger.Log("Failed to declare EventBus exchange: %v\n", err) - os.Exit(1) - } - - _, err = chn.QueueDeclare( - c.EventBusQueue, // name - false, // durable - false, // delete when unused - false, // exclusive - false, // no-wait - nil, // arguments - ) - if err != nil { - w.Logger.Log("Failed to declare EventBus queue: %v\n", err) - os.Exit(1) - } - - // w.bindQueues() - rabbitmq.BindQueueToExchange(chn, c.EventBusQueue, c.EventBusExchange, "warehouse.catalog.stockUpdated") - - w.Eventbus = chn - - return nil - } -} - -func WithLogger(c *internal.Config) OptionFn { - return func(w *Worker) error { - logHost, logPort, err := fluentd.ParseAddr(c.LoggerAddr) - if err != nil { - w.Logger.Log("Failed to parse Fluentd address: %s. Err: %v", c.LoggerAddr, err) - os.Exit(1) - } - - logger, err := fluentd.NewLogger(c.Base.GetAppFullName(), logHost, logPort) - if err != nil { - w.Logger.Log("Failed to connect to the Fluentd on %s:%d. Err: %v", logHost, logPort, err) - os.Exit(1) - } - - w.Logger = logger - - return nil - } -} - -func WithRegistry(c *internal.Config) OptionFn { - return func(w *Worker) error { - registry, err := consul.NewService(c.RegistryAddr, c.Base.AppID, c.Base.AppName, c.Base.AppID, "", "", 0) - if err != nil { - w.Logger.Log("Error connecting to %s: %v", c.RegistryAddr, err) - } - - w.Registry = registry - - go func(w *Worker) { // Fetch Consul KV config and store it in app config - ticker := time.NewTicker(time.Second * 15) - for range ticker.C { - fetchKVConfig(w) // FIXME: duplicated in server - } - }(w) - - return nil - } - -} - -func fetchKVConfig(w *Worker) { // @FIXME: merge duplication in server.go and worker.go - config, _, err := w.Registry.KV().Get(w.Config.KVNamespace, nil) - if err != nil || config == nil { - return - } - - kvCnf := bytes.NewBuffer(config.Value) - decoder := json.NewDecoder(kvCnf) - if err := decoder.Decode(&w.Config); err != nil { - return - } -} +// kvCnf := bytes.NewBuffer(config.Value) +// decoder := json.NewDecoder(kvCnf) +// if err := decoder.Decode(&w.Config); err != nil { +// return +// } +// } diff --git a/src/internal/worker/worker.go b/src/internal/worker/worker.go index 5a919b8..1c7146c 100644 --- a/src/internal/worker/worker.go +++ b/src/internal/worker/worker.go @@ -11,20 +11,20 @@ import ( "github.com/go-redis/redis/v8" "github.com/jackc/pgx/v5/pgxpool" - "github.com/streadway/amqp" + amqp "github.com/rabbitmq/amqp091-go" - "git.pbiernat.dev/egommerce/go-api-pkg/consul" - "git.pbiernat.dev/egommerce/go-api-pkg/fluentd" - "git.pbiernat.dev/egommerce/go-api-pkg/rabbitmq" + "git.pbiernat.io/egommerce/go-api-pkg/consul" + "git.pbiernat.io/egommerce/go-api-pkg/fluentd" + "git.pbiernat.io/egommerce/go-api-pkg/rabbitmq" - "git.pbiernat.dev/egommerce/catalog-service/internal" - "git.pbiernat.dev/egommerce/catalog-service/internal/event" - "git.pbiernat.dev/egommerce/catalog-service/internal/service" + "git.pbiernat.io/egommerce/catalog-service/internal/event" + cnf "git.pbiernat.io/egommerce/catalog-service/internal/server" + "git.pbiernat.io/egommerce/catalog-service/internal/service" ) type ( Worker struct { - Config *internal.Config + Config *cnf.Config Cache *redis.Client Database *pgxpool.Pool Eventbus *amqp.Channel @@ -34,7 +34,7 @@ type ( OptionFn func(*Worker) error // FIXME: similar in server/server.go ) -func New(c *internal.Config, opts ...OptionFn) *Worker { +func New(c *cnf.Config, opts ...OptionFn) *Worker { w := &Worker{ Config: c, } @@ -157,5 +157,5 @@ func (w *Worker) processMsg(srvc *service.CatalogService, d amqp.Delivery) { } w.Logger.Log("Error processing \"%s\": %s (%v)", name, err.Error(), err) - d.Reject(false) // FIXME: or Nack(repeat until success - maybe message shout know...? + d.Reject(false) // FIXME: or Nack(repeat until success - maybe message shoud know...? } diff --git a/src/pkg/server/config.go b/src/pkg/server/config.go deleted file mode 100644 index 577644f..0000000 --- a/src/pkg/server/config.go +++ /dev/null @@ -1,34 +0,0 @@ -package server - -import ( - "fmt" - "net" - "os" - "time" -) - -type Config struct { - AppID string - AppName string - AppDomain string - NetAddr string - PathPrefix string - - IdleTimeout time.Duration // miliseconds - ReadTimeout time.Duration // miliseconds - WriteTimeout time.Duration // miliseconds -} - -func (c *Config) GetAppFullName() string { - return fmt.Sprintf("%s_%s", c.AppName, c.AppID) -} - -func (c *Config) GetIP() string { - host, _ := os.Hostname() - ips, _ := net.LookupIP(host) - for _, ip := range ips { - return ip.String() - } - - return host -} diff --git a/src/pkg/server/server.go b/src/pkg/server/server.go deleted file mode 100644 index a86e899..0000000 --- a/src/pkg/server/server.go +++ /dev/null @@ -1,101 +0,0 @@ -package server - -import ( - "log" - "net" - "os" - "os/signal" - "strconv" - "syscall" - "time" - - "github.com/gofiber/fiber/v2" - - "git.pbiernat.dev/egommerce/api-entities/http" -) - -type ( - Server struct { - *fiber.App - *Config - - addr string // e.g. "127.0.0.1:80" - - ShutdownFn - } - HeaderRequestID struct { - RequestID string `reqHeader:"x-request-id"` - } - OptionFn func(*Server) error - ShutdownFn func() error -) - -func New(conf *Config) *Server { - return &Server{ - App: fiber.New(fiber.Config{ - AppName: conf.AppID, - ServerHeader: conf.AppName + ":" + conf.AppID, - ReadTimeout: conf.ReadTimeout * time.Millisecond, - WriteTimeout: conf.WriteTimeout * time.Millisecond, - IdleTimeout: conf.IdleTimeout * time.Millisecond, - }), - Config: conf, - addr: conf.NetAddr, - } -} - -func (s *Server) Start(while chan struct{}) error { - go func() { - sigint := make(chan os.Signal, 1) - signal.Notify(sigint, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) - <-sigint - - if err := s.ShutdownFn(); err != nil { - log.Fatalf("Failed to shutdown server. Reason: %v\n", err) - } - - close(while) - }() - - run := s.createRunFile("./app.run") // FIXME path... TODO move to common library (shared between server and worker) - defer s.removeRunFile(run) - - ln, _ := net.Listen("tcp", s.addr) - // ln = tls.NewListener(ln, s.App.Server().TLSConfig) - err := s.Listener(ln) - if err != nil { - log.Fatalf("Failed to start server: %s. Reason: %v\n", s.Config.AppID, err) - close(while) - } - <-while - - return err -} - -func (s *Server) GetRequestID(c *fiber.Ctx) (string, error) { - var hdr = new(HeaderRequestID) - if err := c.ReqHeaderParser(hdr); err != nil { - return "", err - } - - return hdr.RequestID, nil -} - -func (s *Server) Error(c *fiber.Ctx, code int, msg string) error { - return c.Status(code).JSON(http.ErrorResponse{Error: msg}) -} - -func (s *Server) createRunFile(path string) *os.File { - run, err := os.Create(path) - if err != nil { - log.Fatalf("Failed to create run file. Reason: %v\n", err) - os.Exit(1) - } - run.WriteString(strconv.Itoa(os.Getpid())) - - return run -} - -func (s *Server) removeRunFile(f *os.File) error { - return f.Close() -}