From cfc15b6d9812188cb8258fce24631144779fcf3e Mon Sep 17 00:00:00 2001 From: iasergunin Date: Sun, 3 Dec 2023 20:59:42 +0300 Subject: [PATCH 01/13] Move packages in different directories --- .github/workflows/main.yaml | 4 +- Makefile | 11 + README.md | 38 +- trm/context.go => context.go | 2 +- {trm/context => context}/context.go | 4 +- {trm/context => context}/key.go | 2 +- {trm/context => context}/key_test.go | 0 {redis => drivers/go-redis-v8}/context.go | 12 +- .../go-redis-v8}/example_test.go | 26 +- {redis => drivers/go-redis-v8}/factory.go | 6 +- drivers/go-redis-v8/go.mod | 10 + {redis => drivers/go-redis-v8}/option.go | 4 +- .../go-redis-v8}/readonly_func_without_tx.go | 2 +- .../readonly_func_without_tx_test.go | 4 +- {redis => drivers/go-redis-v8}/settings.go | 12 +- {redis => drivers/go-redis-v8}/transaction.go | 4 +- .../go-redis-v8}/transaction_test.go | 18 +- {redis => drivers/go-redis-v8}/watcher.go | 2 +- .../go-redis-v8}/watcher_test.go | 28 +- {gorm => drivers/gorm}/context.go | 4 +- {gorm => drivers/gorm}/example_test.go | 7 +- {gorm => drivers/gorm}/factory.go | 2 +- drivers/gorm/go.mod | 9 + {gorm => drivers/gorm}/settings.go | 6 +- {gorm => drivers/gorm}/settings_test.go | 4 +- {gorm => drivers/gorm}/transaction.go | 2 +- {gorm => drivers/gorm}/transaction_test.go | 11 +- {mongo => drivers/mongo}/contract.go | 0 {mongo => drivers/mongo}/example_test.go | 10 +- {mongo => drivers/mongo}/factory.go | 2 +- drivers/mongo/go.mod | 9 + {mongo => drivers/mongo}/settings.go | 2 +- {mongo => drivers/mongo}/settings_test.go | 4 +- {mongo => drivers/mongo}/transaction.go | 0 {mongo => drivers/mongo}/transaction_test.go | 13 +- {pgxv4 => drivers/pgxv4}/context.go | 4 +- {pgxv4 => drivers/pgxv4}/contract.go | 0 {pgxv4 => drivers/pgxv4}/example_test.go | 6 +- {pgxv4 => drivers/pgxv4}/factory.go | 2 +- drivers/pgxv4/go.mod | 9 + {pgxv4 => drivers/pgxv4}/settings.go | 2 +- {pgxv4 => drivers/pgxv4}/settings_test.go | 4 +- {pgxv4 => drivers/pgxv4}/transaction.go | 2 +- {pgxv4 => drivers/pgxv4}/transaction_test.go | 13 +- {pgxv5 => drivers/pgxv5}/context.go | 4 +- {pgxv5 => drivers/pgxv5}/contract.go | 0 {pgxv5 => drivers/pgxv5}/example_test.go | 6 +- {pgxv5 => drivers/pgxv5}/factory.go | 2 +- drivers/pgxv5/go.mod | 9 + {pgxv5 => drivers/pgxv5}/settings.go | 2 +- {pgxv5 => drivers/pgxv5}/settings_test.go | 4 +- {pgxv5 => drivers/pgxv5}/transaction.go | 2 +- {pgxv5 => drivers/pgxv5}/transaction_test.go | 13 +- {sql => drivers/sql}/context.go | 4 +- {sql => drivers/sql}/contract.go | 0 {sql => drivers/sql}/example_test.go | 7 +- {sql => drivers/sql}/factory.go | 2 +- drivers/sql/go.mod | 9 + {sql => drivers/sql}/mock/savepoint.go | 0 {sql => drivers/sql}/savepoint.go | 0 {sql => drivers/sql}/settings.go | 2 +- {sql => drivers/sql}/settings_test.go | 4 +- {sql => drivers/sql}/transaction.go | 2 +- {sql => drivers/sql}/transaction_test.go | 13 +- .../sqlx}/chained_example_test.go | 12 +- {sqlx => drivers/sqlx}/context.go | 4 +- {sqlx => drivers/sqlx}/contract.go | 0 {sqlx => drivers/sqlx}/example_test.go | 11 +- {sqlx => drivers/sqlx}/factory.go | 3 +- drivers/sqlx/go.mod | 11 + {sqlx => drivers/sqlx}/transaction.go | 3 +- {sqlx => drivers/sqlx}/transaction_test.go | 13 +- go.mod | 20 +- go.sum | 419 ------------------ internal/benchmark/allocation/key_in_ctx.go | 2 +- internal/benchmark/allocation/tx_in_ctx.go | 2 +- internal/benchmark/map_vs_context/common.go | 2 +- .../benchmark/map_vs_context/context_test.go | 2 +- internal/benchmark/map_vs_context/map_test.go | 2 +- .../{trm_test.go => trm_test.go.skip} | 5 +- .../{trmrepo.go => trmrepo.go.skip} | 2 +- internal/example/habr/finished/.gitignore | 3 - .../example/habr/finished/domain/order.go | 43 -- .../habr/finished/domain/repository.go | 16 - internal/example/habr/finished/domain/user.go | 46 -- internal/example/habr/finished/go.mod | 9 - internal/example/habr/finished/go.sum | 210 --------- internal/example/habr/finished/main_test.go | 103 ----- internal/example/habr/finished/queue/queue.go | 11 - internal/example/habr/finished/repo/order.go | 95 ---- .../example/habr/finished/repo/tr/deps.go | 15 - internal/example/habr/finished/repo/user.go | 117 ----- .../habr/finished/usecase/decorator/struct.go | 52 --- .../finished/usecase/decorator/struct_test.go | 25 -- .../finished/usecase/fast_purchase/usecase.go | 66 --- .../habr/finished/usecase/purchase/usecase.go | 46 -- .../habr/finished/usecase/register/usecase.go | 45 -- internal/example/habr/init/.gitignore | 3 - internal/example/habr/init/domain/deps.go | 15 - internal/example/habr/init/domain/order.go | 43 -- .../example/habr/init/domain/repository.go | 12 - internal/example/habr/init/domain/user.go | 41 -- internal/example/habr/init/go.mod | 8 - internal/example/habr/init/go.sum | 9 - internal/example/habr/init/main_test.go | 98 ---- internal/example/habr/init/queue/queue.go | 9 - internal/example/habr/init/repo/order.go | 96 ---- internal/example/habr/init/repo/user.go | 114 ----- .../habr/init/repo/with_transaction.go | 39 -- .../example/habr/init/repo/withoutTx/user.go | 106 ----- .../init/usecase/fast_purchase/usecase.go | 72 --- .../habr/init/usecase/purchase/usecase.go | 60 --- .../habr/init/usecase/register/usecase.go | 59 --- .../register_withTransaction/usecase.go | 44 -- trm/manager.go => manager.go | 2 +- {trm/manager => manager}/chain.go | 2 +- {trm/manager => manager}/chain_test.go | 6 +- {trm/manager => manager}/closer.go | 2 +- {trm/manager => manager}/log.go | 0 {trm/manager => manager}/log_test.go | 0 {trm/manager => manager}/manager.go | 7 +- {trm/manager => manager}/manager_test.go | 12 +- {trm/manager => manager}/mock/log.go | 0 {trm/manager => manager}/option.go | 2 +- {trm/manager => manager}/struct_test.go | 2 +- trm/manager_test.go => manager_test.go | 2 +- {trm/mock => mock}/manager.go | 2 +- {trm/mock => mock}/settings.go | 2 +- {trm/mock => mock}/transaction.go | 2 +- trm/settings.go => settings.go | 2 +- {trm/settings => settings}/option.go | 2 +- {trm/settings => settings}/settings.go | 2 +- {trm/settings => settings}/settings_test.go | 2 +- sh/go.mod.tidy.sh | 7 + sh/go.mod.vendor.sh | 7 + trm/transaction.go => transaction.go | 2 +- 136 files changed, 325 insertions(+), 2386 deletions(-) rename trm/context.go => context.go (96%) rename {trm/context => context}/context.go (91%) rename {trm/context => context}/key.go (92%) rename {trm/context => context}/key_test.go (100%) rename {redis => drivers/go-redis-v8}/context.go (71%) rename {redis => drivers/go-redis-v8}/example_test.go (79%) rename {redis => drivers/go-redis-v8}/factory.go (64%) create mode 100644 drivers/go-redis-v8/go.mod rename {redis => drivers/go-redis-v8}/option.go (88%) rename {redis => drivers/go-redis-v8}/readonly_func_without_tx.go (99%) rename {redis => drivers/go-redis-v8}/readonly_func_without_tx_test.go (99%) rename {redis => drivers/go-redis-v8}/settings.go (90%) rename {redis => drivers/go-redis-v8}/transaction.go (94%) rename {redis => drivers/go-redis-v8}/transaction_test.go (89%) rename {redis => drivers/go-redis-v8}/watcher.go (97%) rename {redis => drivers/go-redis-v8}/watcher_test.go (65%) rename {gorm => drivers/gorm}/context.go (90%) rename {gorm => drivers/gorm}/example_test.go (90%) rename {gorm => drivers/gorm}/factory.go (87%) create mode 100644 drivers/gorm/go.mod rename {gorm => drivers/gorm}/settings.go (93%) rename {gorm => drivers/gorm}/settings_test.go (93%) rename {gorm => drivers/gorm}/transaction.go (97%) rename {gorm => drivers/gorm}/transaction_test.go (94%) rename {mongo => drivers/mongo}/contract.go (100%) rename {mongo => drivers/mongo}/example_test.go (88%) rename {mongo => drivers/mongo}/factory.go (86%) create mode 100644 drivers/mongo/go.mod rename {mongo => drivers/mongo}/settings.go (97%) rename {mongo => drivers/mongo}/settings_test.go (95%) rename {mongo => drivers/mongo}/transaction.go (100%) rename {mongo => drivers/mongo}/transaction_test.go (93%) rename {pgxv4 => drivers/pgxv4}/context.go (89%) rename {pgxv4 => drivers/pgxv4}/contract.go (100%) rename {pgxv4 => drivers/pgxv4}/example_test.go (92%) rename {pgxv4 => drivers/pgxv4}/factory.go (89%) create mode 100644 drivers/pgxv4/go.mod rename {pgxv4 => drivers/pgxv4}/settings.go (96%) rename {pgxv4 => drivers/pgxv4}/settings_test.go (93%) rename {pgxv4 => drivers/pgxv4}/transaction.go (96%) rename {pgxv4 => drivers/pgxv4}/transaction_test.go (94%) rename {pgxv5 => drivers/pgxv5}/context.go (89%) rename {pgxv5 => drivers/pgxv5}/contract.go (100%) rename {pgxv5 => drivers/pgxv5}/example_test.go (92%) rename {pgxv5 => drivers/pgxv5}/factory.go (89%) create mode 100644 drivers/pgxv5/go.mod rename {pgxv5 => drivers/pgxv5}/settings.go (96%) rename {pgxv5 => drivers/pgxv5}/settings_test.go (93%) rename {pgxv5 => drivers/pgxv5}/transaction.go (96%) rename {pgxv5 => drivers/pgxv5}/transaction_test.go (94%) rename {sql => drivers/sql}/context.go (89%) rename {sql => drivers/sql}/contract.go (100%) rename {sql => drivers/sql}/example_test.go (92%) rename {sql => drivers/sql}/factory.go (89%) create mode 100644 drivers/sql/go.mod rename {sql => drivers/sql}/mock/savepoint.go (100%) rename {sql => drivers/sql}/savepoint.go (100%) rename {sql => drivers/sql}/settings.go (96%) rename {sql => drivers/sql}/settings_test.go (93%) rename {sql => drivers/sql}/transaction.go (97%) rename {sql => drivers/sql}/transaction_test.go (94%) rename {sqlx => drivers/sqlx}/chained_example_test.go (84%) rename {sqlx => drivers/sqlx}/context.go (89%) rename {sqlx => drivers/sqlx}/contract.go (100%) rename {sqlx => drivers/sqlx}/example_test.go (89%) rename {sqlx => drivers/sqlx}/factory.go (82%) create mode 100644 drivers/sqlx/go.mod rename {sqlx => drivers/sqlx}/transaction.go (95%) rename {sqlx => drivers/sqlx}/transaction_test.go (94%) delete mode 100644 go.sum rename internal/benchmark/with_or_without_trm/{trm_test.go => trm_test.go.skip} (88%) rename internal/benchmark/with_or_without_trm/{trmrepo.go => trmrepo.go.skip} (92%) delete mode 100644 internal/example/habr/finished/.gitignore delete mode 100644 internal/example/habr/finished/domain/order.go delete mode 100644 internal/example/habr/finished/domain/repository.go delete mode 100644 internal/example/habr/finished/domain/user.go delete mode 100644 internal/example/habr/finished/go.mod delete mode 100644 internal/example/habr/finished/go.sum delete mode 100644 internal/example/habr/finished/main_test.go delete mode 100644 internal/example/habr/finished/queue/queue.go delete mode 100644 internal/example/habr/finished/repo/order.go delete mode 100644 internal/example/habr/finished/repo/tr/deps.go delete mode 100644 internal/example/habr/finished/repo/user.go delete mode 100644 internal/example/habr/finished/usecase/decorator/struct.go delete mode 100644 internal/example/habr/finished/usecase/decorator/struct_test.go delete mode 100644 internal/example/habr/finished/usecase/fast_purchase/usecase.go delete mode 100644 internal/example/habr/finished/usecase/purchase/usecase.go delete mode 100644 internal/example/habr/finished/usecase/register/usecase.go delete mode 100644 internal/example/habr/init/.gitignore delete mode 100644 internal/example/habr/init/domain/deps.go delete mode 100644 internal/example/habr/init/domain/order.go delete mode 100644 internal/example/habr/init/domain/repository.go delete mode 100644 internal/example/habr/init/domain/user.go delete mode 100644 internal/example/habr/init/go.mod delete mode 100644 internal/example/habr/init/go.sum delete mode 100644 internal/example/habr/init/main_test.go delete mode 100644 internal/example/habr/init/queue/queue.go delete mode 100644 internal/example/habr/init/repo/order.go delete mode 100644 internal/example/habr/init/repo/user.go delete mode 100644 internal/example/habr/init/repo/with_transaction.go delete mode 100644 internal/example/habr/init/repo/withoutTx/user.go delete mode 100644 internal/example/habr/init/usecase/fast_purchase/usecase.go delete mode 100644 internal/example/habr/init/usecase/purchase/usecase.go delete mode 100644 internal/example/habr/init/usecase/register/usecase.go delete mode 100644 internal/example/habr/init/usecase/register_withTransaction/usecase.go rename trm/manager.go => manager.go (97%) rename {trm/manager => manager}/chain.go (98%) rename {trm/manager => manager}/chain_test.go (96%) rename {trm/manager => manager}/closer.go (97%) rename {trm/manager => manager}/log.go (100%) rename {trm/manager => manager}/log_test.go (100%) rename {trm/manager => manager}/manager.go (95%) rename {trm/manager => manager}/manager_test.go (98%) rename {trm/manager => manager}/mock/log.go (100%) rename {trm/manager => manager}/option.go (88%) rename {trm/manager => manager}/struct_test.go (95%) rename trm/manager_test.go => manager_test.go (98%) rename {trm/mock => mock}/manager.go (97%) rename {trm/mock => mock}/settings.go (99%) rename {trm/mock => mock}/transaction.go (99%) rename trm/settings.go => settings.go (96%) rename {trm/settings => settings}/option.go (93%) rename {trm/settings => settings}/settings.go (98%) rename {trm/settings => settings}/settings_test.go (98%) create mode 100644 sh/go.mod.tidy.sh create mode 100644 sh/go.mod.vendor.sh rename trm/transaction.go => transaction.go (99%) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6c327e0..d4c4858 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -56,10 +56,10 @@ jobs: pull-requests: write services: redis: - image: redis + image: go-redis-v9 ports: - 6379:6379 - # Set health checks to wait until redis has started + # Set health checks to wait until go-redis-v9 has started options: >- --health-cmd "redis-cli ping" --health-interval 10s diff --git a/Makefile b/Makefile index 549c51c..9bcb20e 100644 --- a/Makefile +++ b/Makefile @@ -23,3 +23,14 @@ lint: generate: go generate ./... + + +go.update: go.tidy go.vendor + +go.prepare: go.vendor + +go.tidy: + ./sh/go.mod.tidy.sh + +go.vendor: + ./sh/go.mod.vendor.sh diff --git a/README.md b/README.md index cfba087..d60ba2a 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ Easiest way to get the perfect repository. ## Supported implementations -* [database/sql](https://pkg.go.dev/database/sql), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/sql) (Go 1.13) -* [jmoiron/sqlx](https://github.com/jmoiron/sqlx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/sqlx) (Go 1.13) -* [gorm](https://github.com/go-gorm/gorm), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/gorm) (Go 1.16) -* [mongo-go-driver](https://github.com/mongodb/mongo-go-driver), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/mongo) (Go 1.13) -* [go-redis/redis](https://github.com/go-redis/redis), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/redis) (Go 1.17) -* [pgx_v4](https://github.com/jackc/pgx/tree/v4), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/pgxv4) (Go 1.16) -* [pgx_v5](https://github.com/jackc/pgx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/pgxv5) (Go 1.19) +* [database/sql](https://pkg.go.dev/database/sql), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/sql/v2) (Go 1.13) +* [jmoiron/sqlx](https://github.com/jmoiron/sqlx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2) (Go 1.13) +* [gorm](https://github.com/go-gorm/gorm), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/gorm/v2) (Go 1.18) +* [mongo-go-driver](https://github.com/mongodb/mongo-go-driver), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/mongo/v2) (Go 1.13) +* [go-redis/redis](https://github.com/go-redis/redis), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2) (Go 1.17) +* [pgx_v4](https://github.com/jackc/pgx/tree/v4), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2) (Go 1.16) +* [pgx_v5](https://github.com/jackc/pgx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/pgxv5/v2) (Go 1.19) ## Installation @@ -33,23 +33,23 @@ Compatibility beyond that is not guaranteed. ## Usage -**To use multiple transactions from different databases**, you need to set CtxKey in [Settings](trm/settings.go) by [WithCtxKey](trm/settings/option.go). +**To use multiple transactions from different databases**, you need to set CtxKey in [Settings](trm/settings.go) by [WithCtxKey](settings/option.go). -**For nested transactions with different transaction managers**, you need to use [ChainedMW](trm/manager/chain.go) ([docs](https://pkg.go.dev/github.com/github.com/avito-tech/go-transaction-manager)). +**For nested transactions with different transaction managers**, you need to use [ChainedMW](manager/chain.go) ([docs](https://pkg.go.dev/github.com/github.com/avito-tech/go-transaction-manager)). -**To skip a transaction rollback due to an error, use [ErrSkip](trm/manager.go#L20) or [Skippable](trm/manager.go#L24)** +**To skip a transaction rollback due to an error, use [ErrSkip](manager.go#L20) or [Skippable](manager.go#L24)** ### Explanation of the approach ([English](https://www.youtube.com/watch?v=aRsea6FFAyA), [Russian](https://habr.com/ru/companies/avito/articles/727168/)) ### Examples with an ideal *repository* and nested transactions. -* [database/sql](sql/example_test.go) -* [jmoiron/sqlx](sqlx/example_test.go) -* [gorm](gorm/example_test.go) -* [mongo-go-driver](mongo/example_test.go) -* [go-redis/redis](redis/example_test.go) -* [pgx_v4](pgxv4/example_test.go) -* [pgx_v5](pgxv5/example_test.go) +* [database/sql](drivers/sql/example_test.go) +* [jmoiron/sqlx](drivers/sqlx/example_test.go) +* [gorm](drivers/gorm/example_test.go) +* [mongo-go-driver](drivers/mongo/example_test.go) +* [go-redis/redis](drivers/go-redis-v9/example_test.go) +* [pgx_v4](drivers/pgxv4/example_test.go) +* [pgx_v5](drivers/pgxv5/example_test.go) Below is an example how to start usage. @@ -64,8 +64,8 @@ import ( "github.com/jmoiron/sqlx" _ "github.com/mattn/go-sqlite3" - trmsqlx "github.com/avito-tech/go-transaction-manager/sqlx" - "github.com/avito-tech/go-transaction-manager/trm/manager" + trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" + "github.com/avito-tech/go-transaction-manager/v2/manager" ) func main() { diff --git a/trm/context.go b/context.go similarity index 96% rename from trm/context.go rename to context.go index 367ccac..623ce80 100644 --- a/trm/context.go +++ b/context.go @@ -1,4 +1,4 @@ -package trm +package go_transaction_manager import ( "context" diff --git a/trm/context/context.go b/context/context.go similarity index 91% rename from trm/context/context.go rename to context/context.go index 5fb4377..5a78c3e 100644 --- a/trm/context/context.go +++ b/context/context.go @@ -4,8 +4,8 @@ package context import ( "context" - "github.com/avito-tech/go-transaction-manager/trm" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/avito-tech/go-transaction-manager/v2/settings" ) // DefaultManager is a trm.СtxManager with settings.DefaultCtxKey. diff --git a/trm/context/key.go b/context/key.go similarity index 92% rename from trm/context/key.go rename to context/key.go index c6ace0c..93b6b73 100644 --- a/trm/context/key.go +++ b/context/key.go @@ -3,7 +3,7 @@ package context import ( "sync/atomic" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) //nolint:gochecknoglobals diff --git a/trm/context/key_test.go b/context/key_test.go similarity index 100% rename from trm/context/key_test.go rename to context/key_test.go diff --git a/redis/context.go b/drivers/go-redis-v8/context.go similarity index 71% rename from redis/context.go rename to drivers/go-redis-v8/context.go index 3084007..bb3b8ac 100644 --- a/redis/context.go +++ b/drivers/go-redis-v8/context.go @@ -1,18 +1,18 @@ -package redis +package go_redis_v8 import ( "context" "github.com/go-redis/redis/v8" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" + trm "github.com/avito-tech/go-transaction-manager/v2" + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" ) // DefaultCtxGetter is the CtxGetter with settings.DefaultCtxKey. var DefaultCtxGetter = NewCtxGetter(trmcontext.DefaultManager) -// CtxGetter gets redis.Pipeliner from trm.СtxManager by casting trm.Transaction to redis.UniversalClient. +// CtxGetter gets go-redis-v9.Pipeliner from trm.СtxManager by casting trm.Transaction to go-redis-v9.UniversalClient. type CtxGetter struct { ctxManager trm.СtxManager } @@ -22,7 +22,7 @@ func NewCtxGetter(c trm.СtxManager) *CtxGetter { return &CtxGetter{ctxManager: c} } -// DefaultTrOrDB returns Cmdable from context.Context or DB(redis.Cmdable) otherwise. +// DefaultTrOrDB returns Cmdable from context.Context or DB(go-redis-v9.Cmdable) otherwise. func (c *CtxGetter) DefaultTrOrDB(ctx context.Context, db redis.Cmdable) redis.Cmdable { if tr := c.ctxManager.Default(ctx); tr != nil { return c.convert(tr) @@ -31,7 +31,7 @@ func (c *CtxGetter) DefaultTrOrDB(ctx context.Context, db redis.Cmdable) redis.C return db } -// TrOrDB returns Cmdable from context.Context by trm.CtxKey or DB(redis.Cmdable) otherwise. +// TrOrDB returns Cmdable from context.Context by trm.CtxKey or DB(go-redis-v9.Cmdable) otherwise. func (c *CtxGetter) TrOrDB(ctx context.Context, key trm.CtxKey, db redis.Cmdable) redis.Cmdable { if tr := c.ctxManager.ByKey(ctx, key); tr != nil { return c.convert(tr) diff --git a/redis/example_test.go b/drivers/go-redis-v8/example_test.go similarity index 79% rename from redis/example_test.go rename to drivers/go-redis-v8/example_test.go index f4f5a90..17d4943 100644 --- a/redis/example_test.go +++ b/drivers/go-redis-v8/example_test.go @@ -1,19 +1,15 @@ //go:build with_real_db // +build with_real_db -package redis_test +package go_redis_v8_test import ( "context" "encoding/json" "fmt" - "github.com/go-redis/redis/v8" - - trmredis "github.com/avito-tech/go-transaction-manager/redis" - "github.com/avito-tech/go-transaction-manager/trm" - "github.com/avito-tech/go-transaction-manager/trm/manager" - "github.com/avito-tech/go-transaction-manager/trm/settings" + "github.com/avito-tech/go-transaction-manager/v2/manager" + "github.com/avito-tech/go-transaction-manager/v2/settings" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. @@ -25,7 +21,7 @@ func Example() { ctx := context.Background() rdb.FlushDB(ctx) - r := newRepo(rdb, trmredis.DefaultCtxGetter) + r := newRepo(rdb, DefaultCtxGetter) u1 := &user{ Username: "username1", @@ -35,11 +31,11 @@ func Example() { } trManager := manager.Must( - trmredis.NewDefaultFactory(rdb), - manager.WithSettings(trmredis.MustSettings( + NewDefaultFactory(rdb), + manager.WithSettings(MustSettings( settings.Must( settings.WithPropagation(trm.PropagationNested)), - trmredis.WithTxDecorator(trmredis.ReadOnlyFuncWithoutTxDecorator), + WithTxDecorator(ReadOnlyFuncWithoutTxDecorator), )), ) @@ -49,7 +45,7 @@ func Example() { var cmds []redis.Cmder err = trManager.DoWithSettings( ctx, - trmredis.MustSettings(settings.Must(), trmredis.WithRet(&cmds)), + MustSettings(settings.Must(), WithRet(&cmds)), func(ctx context.Context) error { if err := r.Save(ctx, u2); err != nil { return err @@ -85,10 +81,10 @@ func Example() { type repo struct { db redis.UniversalClient - getter *trmredis.CtxGetter + getter *CtxGetter } -func newRepo(db redis.UniversalClient, c *trmredis.CtxGetter) *repo { +func newRepo(db redis.UniversalClient, c *CtxGetter) *repo { return &repo{ db: db, getter: c, @@ -118,7 +114,7 @@ type user struct { } type userRecord struct { - Username string `redis:"username"` + Username string `go-redis-v9:"username"` } func (r userRecord) MarshalBinary() (data []byte, err error) { diff --git a/redis/factory.go b/drivers/go-redis-v8/factory.go similarity index 64% rename from redis/factory.go rename to drivers/go-redis-v8/factory.go index 714799e..bb4c463 100644 --- a/redis/factory.go +++ b/drivers/go-redis-v8/factory.go @@ -1,14 +1,14 @@ -package redis +package go_redis_v8 import ( "context" "github.com/go-redis/redis/v8" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) -// NewDefaultFactory creates default trm.Transaction(redis.UniversalClient). +// NewDefaultFactory creates default trm.Transaction(go-redis-v9.UniversalClient). func NewDefaultFactory(db redis.UniversalClient) trm.TrFactory { return func(ctx context.Context, trms trm.Settings) (context.Context, trm.Transaction, error) { s, _ := trms.(Settings) diff --git a/drivers/go-redis-v8/go.mod b/drivers/go-redis-v8/go.mod new file mode 100644 index 0000000..a5e3311 --- /dev/null +++ b/drivers/go-redis-v8/go.mod @@ -0,0 +1,10 @@ +module github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2 + +go 1.13 + +require ( + github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/stretchr/testify v1.8.2 +) + +replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ diff --git a/redis/option.go b/drivers/go-redis-v8/option.go similarity index 88% rename from redis/option.go rename to drivers/go-redis-v8/option.go index 2ebc3a4..c3e7a48 100644 --- a/redis/option.go +++ b/drivers/go-redis-v8/option.go @@ -1,4 +1,4 @@ -package redis +package go_redis_v8 import "github.com/go-redis/redis/v8" @@ -29,7 +29,7 @@ func WithTxDecorator(in TxDecorator) Opt { } } -// WithRet sets link on []redis.Cmder to get responses of commands in Transaction +// WithRet sets link on []go-redis-v9.Cmder to get responses of commands in Transaction // WARNING: Responses don't clean automatically, use WithRet only with DoWithSettings of trm.Manager. func WithRet(in *[]redis.Cmder) Opt { return func(s *Settings) error { diff --git a/redis/readonly_func_without_tx.go b/drivers/go-redis-v8/readonly_func_without_tx.go similarity index 99% rename from redis/readonly_func_without_tx.go rename to drivers/go-redis-v8/readonly_func_without_tx.go index 3acc3fd..8dd936a 100644 --- a/redis/readonly_func_without_tx.go +++ b/drivers/go-redis-v8/readonly_func_without_tx.go @@ -1,4 +1,4 @@ -package redis +package go_redis_v8 import ( "context" diff --git a/redis/readonly_func_without_tx_test.go b/drivers/go-redis-v8/readonly_func_without_tx_test.go similarity index 99% rename from redis/readonly_func_without_tx_test.go rename to drivers/go-redis-v8/readonly_func_without_tx_test.go index a069285..88bc816 100644 --- a/redis/readonly_func_without_tx_test.go +++ b/drivers/go-redis-v8/readonly_func_without_tx_test.go @@ -1,14 +1,12 @@ //go:build go1.14 // +build go1.14 -package redis +package go_redis_v8 import ( "context" "testing" - "github.com/go-redis/redis/v8" - "github.com/go-redis/redismock/v8" "github.com/stretchr/testify/require" ) diff --git a/redis/settings.go b/drivers/go-redis-v8/settings.go similarity index 90% rename from redis/settings.go rename to drivers/go-redis-v8/settings.go index f834c60..059fd86 100644 --- a/redis/settings.go +++ b/drivers/go-redis-v8/settings.go @@ -1,9 +1,9 @@ -package redis +package go_redis_v8 import ( "github.com/go-redis/redis/v8" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) const ( @@ -14,7 +14,7 @@ const ( // Opt is a type to configure Settings. type Opt func(*Settings) error -// Settings contains settings for redis.Transaction. +// Settings contains settings for go-redis-v9.Transaction. type Settings struct { trm.Settings isMulti *bool @@ -78,7 +78,7 @@ func (s Settings) EnrichBy(in trm.Settings) trm.Settings { return s } -// IsMulti - true uses redis MULTI cmd. +// IsMulti - true uses go-redis-v9 MULTI cmd. func (s Settings) IsMulti() bool { if s.isMulti == nil { return DefaultMulti @@ -135,12 +135,12 @@ func (s Settings) setTxDecorator(in ...TxDecorator) Settings { return s } -// Return returns []redis.Cmder from Transaction. +// Return returns []go-redis-v9.Cmder from Transaction. func (s Settings) Return() *[]redis.Cmder { return s.ret } -// SetReturn sets link to save []redis.Cmder from Transaction. +// SetReturn sets link to save []go-redis-v9.Cmder from Transaction. func (s Settings) SetReturn(in *[]redis.Cmder) Settings { return s.setReturn(in) } diff --git a/redis/transaction.go b/drivers/go-redis-v8/transaction.go similarity index 94% rename from redis/transaction.go rename to drivers/go-redis-v8/transaction.go index c296829..ec00e4a 100644 --- a/redis/transaction.go +++ b/drivers/go-redis-v8/transaction.go @@ -1,5 +1,5 @@ -// Package redis is an implementation of trm.Transaction interface by Transaction for redis.UniversalClient. -package redis +// Package go-redis-v9 is an implementation of trm.Transaction interface by Transaction for go-redis-v9.UniversalClient. +package go_redis_v8 import ( "context" diff --git a/redis/transaction_test.go b/drivers/go-redis-v8/transaction_test.go similarity index 89% rename from redis/transaction_test.go rename to drivers/go-redis-v8/transaction_test.go index 5452f87..1df6528 100644 --- a/redis/transaction_test.go +++ b/drivers/go-redis-v8/transaction_test.go @@ -1,7 +1,7 @@ //go:build go1.14 // +build go1.14 -package redis +package go_redis_v8 import ( "context" @@ -10,15 +10,17 @@ import ( "testing" "time" - "github.com/go-redis/redismock/v8" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/avito-tech/go-transaction-manager/internal/mock" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" - "github.com/avito-tech/go-transaction-manager/trm/manager" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" + + "github.com/avito-tech/go-transaction-manager/v2/manager" + + "github.com/avito-tech/go-transaction-manager/v2/settings" ) const OK = "OK" @@ -79,7 +81,7 @@ func TestTransaction(t *testing.T) { ctx: context.Background(), }, wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { - return assert.ErrorContains(t, err, "redis: nil") && + return assert.ErrorContains(t, err, "go-redis-v9: nil") && assert.ErrorIs(t, err, trm.ErrCommit) }, }, diff --git a/redis/watcher.go b/drivers/go-redis-v8/watcher.go similarity index 97% rename from redis/watcher.go rename to drivers/go-redis-v8/watcher.go index 25ed8c2..bc3b815 100644 --- a/redis/watcher.go +++ b/drivers/go-redis-v8/watcher.go @@ -1,4 +1,4 @@ -package redis +package go_redis_v8 import ( "context" diff --git a/redis/watcher_test.go b/drivers/go-redis-v8/watcher_test.go similarity index 65% rename from redis/watcher_test.go rename to drivers/go-redis-v8/watcher_test.go index 30e5ffd..18d2ac5 100644 --- a/redis/watcher_test.go +++ b/drivers/go-redis-v8/watcher_test.go @@ -1,19 +1,15 @@ //go:build with_real_db // +build with_real_db -package redis_test +package go_redis_v8_test import ( "context" "fmt" "time" - "github.com/go-redis/redis/v8" - - trmredis "github.com/avito-tech/go-transaction-manager/redis" - "github.com/avito-tech/go-transaction-manager/trm" - "github.com/avito-tech/go-transaction-manager/trm/manager" - "github.com/avito-tech/go-transaction-manager/trm/settings" + "github.com/avito-tech/go-transaction-manager/v2/manager" + "github.com/avito-tech/go-transaction-manager/v2/settings" ) // Example demonstrates the watching of updated keys. @@ -25,7 +21,7 @@ func Example_watch() { ctx := context.Background() rdb.FlushDB(ctx) - r := newRepo(rdb, trmredis.DefaultCtxGetter) + r := newRepo(rdb, DefaultCtxGetter) u := &user{ ID: uuid1, @@ -33,12 +29,12 @@ func Example_watch() { } trManager := manager.Must( - trmredis.NewDefaultFactory(rdb), - manager.WithSettings(trmredis.MustSettings( + NewDefaultFactory(rdb), + manager.WithSettings(MustSettings( settings.Must( settings.WithPropagation(trm.PropagationNested)), - trmredis.WithTxDecorator(newWatchDecorator), - trmredis.WithMulti(true), + WithTxDecorator(newWatchDecorator), + WithMulti(true), )), ) @@ -66,7 +62,7 @@ func Example_watch() { err = r.Save(ctx, u) // Unwatch keys - cmd := trmredis.DefaultCtxGetter.DefaultTrOrDB(ctx, nil).(trmredis.Watch). + cmd := DefaultCtxGetter.DefaultTrOrDB(ctx, nil).(Watch). Unwatch(ctx) checkErr(cmd.Err()) @@ -78,15 +74,15 @@ func Example_watch() { ) fmt.Println(err) - // Output: transaction: commit; redis: transaction failed + // Output: transaction: commit; go-redis-v9: transaction failed // } type watchDecoratorExample struct { - trmredis.Cmdable + Cmdable } -func newWatchDecorator(tx trmredis.Cmdable, _ redis.Cmdable) trmredis.Cmdable { +func newWatchDecorator(tx Cmdable, _ redis.Cmdable) Cmdable { return &watchDecoratorExample{Cmdable: tx} } diff --git a/gorm/context.go b/drivers/gorm/context.go similarity index 90% rename from gorm/context.go rename to drivers/gorm/context.go index 6bcf5b8..70b4ac2 100644 --- a/gorm/context.go +++ b/drivers/gorm/context.go @@ -8,8 +8,8 @@ import ( "gorm.io/gorm" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" + trm "github.com/avito-tech/go-transaction-manager/v2" + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" ) // DefaultCtxGetter is the CtxGetter with settings.DefaultCtxKey. diff --git a/gorm/example_test.go b/drivers/gorm/example_test.go similarity index 90% rename from gorm/example_test.go rename to drivers/gorm/example_test.go index be97dac..eca31e4 100644 --- a/gorm/example_test.go +++ b/drivers/gorm/example_test.go @@ -11,10 +11,9 @@ import ( "gorm.io/driver/sqlite" "gorm.io/gorm" - trmgorm "github.com/avito-tech/go-transaction-manager/gorm" - "github.com/avito-tech/go-transaction-manager/trm" - "github.com/avito-tech/go-transaction-manager/trm/manager" - "github.com/avito-tech/go-transaction-manager/trm/settings" +trmgorm github.com/avito-tech/go-transaction-manager/v2/gorm" +"github.com/avito-tech/go-transaction-manager/v2/manager" +"github.com/avito-tech/go-transaction-manager/v2/settings" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. diff --git a/gorm/factory.go b/drivers/gorm/factory.go similarity index 87% rename from gorm/factory.go rename to drivers/gorm/factory.go index 2af6348..3142126 100644 --- a/gorm/factory.go +++ b/drivers/gorm/factory.go @@ -8,7 +8,7 @@ import ( "gorm.io/gorm" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // NewDefaultFactory creates default trm.Transaction(sqlx.Tx). diff --git a/drivers/gorm/go.mod b/drivers/gorm/go.mod new file mode 100644 index 0000000..4972f03 --- /dev/null +++ b/drivers/gorm/go.mod @@ -0,0 +1,9 @@ +module github.com/avito-tech/go-transaction-manager/drivers/gorm/v2 + +go 1.18 + +require ( + github.com/avito-tech/go-transaction-manager/v2 v2.0.0 +) + +replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ \ No newline at end of file diff --git a/gorm/settings.go b/drivers/gorm/settings.go similarity index 93% rename from gorm/settings.go rename to drivers/gorm/settings.go index a649978..07120b9 100644 --- a/gorm/settings.go +++ b/drivers/gorm/settings.go @@ -1,12 +1,12 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.18 +// +build go1.18 package gorm import ( "database/sql" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // Opt is a type to configure Settings. diff --git a/gorm/settings_test.go b/drivers/gorm/settings_test.go similarity index 93% rename from gorm/settings_test.go rename to drivers/gorm/settings_test.go index 1ee5b5d..a912671 100644 --- a/gorm/settings_test.go +++ b/drivers/gorm/settings_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/avito-tech/go-transaction-manager/trm" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/avito-tech/go-transaction-manager/v2/settings" ) func TestSettings_EnrichBy(t *testing.T) { diff --git a/gorm/transaction.go b/drivers/gorm/transaction.go similarity index 97% rename from gorm/transaction.go rename to drivers/gorm/transaction.go index 18693e8..0e2354a 100644 --- a/gorm/transaction.go +++ b/drivers/gorm/transaction.go @@ -13,7 +13,7 @@ import ( "gorm.io/gorm" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) var errRollbackTx = errors.New("rollback transaction") diff --git a/gorm/transaction_test.go b/drivers/gorm/transaction_test.go similarity index 94% rename from gorm/transaction_test.go rename to drivers/gorm/transaction_test.go index 57a99bc..f7b566c 100644 --- a/gorm/transaction_test.go +++ b/drivers/gorm/transaction_test.go @@ -17,11 +17,12 @@ import ( "gorm.io/driver/sqlite" "gorm.io/gorm" - "github.com/avito-tech/go-transaction-manager/internal/mock" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" - "github.com/avito-tech/go-transaction-manager/trm/manager" - "github.com/avito-tech/go-transaction-manager/trm/settings" + "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" + + "github.com/avito-tech/go-transaction-manager/v2/manager" + "github.com/avito-tech/go-transaction-manager/v2/settings" ) func TestTransaction(t *testing.T) { diff --git a/mongo/contract.go b/drivers/mongo/contract.go similarity index 100% rename from mongo/contract.go rename to drivers/mongo/contract.go diff --git a/mongo/example_test.go b/drivers/mongo/example_test.go similarity index 88% rename from mongo/example_test.go rename to drivers/mongo/example_test.go index 425dc75..cf61777 100644 --- a/mongo/example_test.go +++ b/drivers/mongo/example_test.go @@ -12,10 +12,12 @@ import ( "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - trmmongo "github.com/avito-tech/go-transaction-manager/mongo" - trmsql "github.com/avito-tech/go-transaction-manager/sql" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" - "github.com/avito-tech/go-transaction-manager/trm/manager" +trmsql github.com/avito-tech/go-transaction-manager/v2/sql" + +trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" +"github.com/avito-tech/go-transaction-manager/v2/manager" + +trmmongo "github.com/avito-tech/go-transaction-manager/drivers/mongo/v2" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. diff --git a/mongo/factory.go b/drivers/mongo/factory.go similarity index 86% rename from mongo/factory.go rename to drivers/mongo/factory.go index 5426a61..e53b59c 100644 --- a/mongo/factory.go +++ b/drivers/mongo/factory.go @@ -3,7 +3,7 @@ package mongo import ( "context" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // NewDefaultFactory creates default trm.Transaction(mongo.Session). diff --git a/drivers/mongo/go.mod b/drivers/mongo/go.mod new file mode 100644 index 0000000..8f99474 --- /dev/null +++ b/drivers/mongo/go.mod @@ -0,0 +1,9 @@ +module github.com/avito-tech/go-transaction-manager/drivers/mongo/v2 + +go 1.13 + +require ( + github.com/avito-tech/go-transaction-manager/v2 v2.0.0 +) + +replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ \ No newline at end of file diff --git a/mongo/settings.go b/drivers/mongo/settings.go similarity index 97% rename from mongo/settings.go rename to drivers/mongo/settings.go index c22ef62..012942e 100644 --- a/mongo/settings.go +++ b/drivers/mongo/settings.go @@ -3,7 +3,7 @@ package mongo import ( "go.mongodb.org/mongo-driver/mongo/options" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // Opt is a type to configure Settings. diff --git a/mongo/settings_test.go b/drivers/mongo/settings_test.go similarity index 95% rename from mongo/settings_test.go rename to drivers/mongo/settings_test.go index de299a1..b78e120 100644 --- a/mongo/settings_test.go +++ b/drivers/mongo/settings_test.go @@ -7,8 +7,8 @@ import ( "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/readconcern" - "github.com/avito-tech/go-transaction-manager/trm" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/avito-tech/go-transaction-manager/v2/settings" ) func TestSettings_EnrichBy(t *testing.T) { diff --git a/mongo/transaction.go b/drivers/mongo/transaction.go similarity index 100% rename from mongo/transaction.go rename to drivers/mongo/transaction.go diff --git a/mongo/transaction_test.go b/drivers/mongo/transaction_test.go similarity index 93% rename from mongo/transaction_test.go rename to drivers/mongo/transaction_test.go index 9ac9d34..4410072 100644 --- a/mongo/transaction_test.go +++ b/drivers/mongo/transaction_test.go @@ -15,11 +15,14 @@ import ( "go.mongodb.org/mongo-driver/mongo/options" "go.mongodb.org/mongo-driver/mongo/writeconcern" - "github.com/avito-tech/go-transaction-manager/internal/mock" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" - "github.com/avito-tech/go-transaction-manager/trm/manager" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" + + "github.com/avito-tech/go-transaction-manager/v2/settings" + + "github.com/avito-tech/go-transaction-manager/v2/manager" ) type user struct { diff --git a/pgxv4/context.go b/drivers/pgxv4/context.go similarity index 89% rename from pgxv4/context.go rename to drivers/pgxv4/context.go index bcb4f0b..799fcef 100644 --- a/pgxv4/context.go +++ b/drivers/pgxv4/context.go @@ -6,8 +6,8 @@ package pgxv4 import ( "context" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" + trm "github.com/avito-tech/go-transaction-manager/v2" + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" ) // DefaultCtxGetter is the CtxGetter with settings.DefaultCtxKey. diff --git a/pgxv4/contract.go b/drivers/pgxv4/contract.go similarity index 100% rename from pgxv4/contract.go rename to drivers/pgxv4/contract.go diff --git a/pgxv4/example_test.go b/drivers/pgxv4/example_test.go similarity index 92% rename from pgxv4/example_test.go rename to drivers/pgxv4/example_test.go index 70b4d24..643284c 100644 --- a/pgxv4/example_test.go +++ b/drivers/pgxv4/example_test.go @@ -9,8 +9,8 @@ import ( "github.com/jackc/pgx/v4/pgxpool" - trmpgx "github.com/avito-tech/go-transaction-manager/pgxv4" - "github.com/avito-tech/go-transaction-manager/trm/manager" +"github.com/avito-tech/go-transaction-manager/v2/manager" +trmpgx "github.com/avito-tech/go-transaction-manager/v2/pgxv4" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. @@ -26,7 +26,7 @@ func Example() { defer pool.Close() - sqlStmt := `CREATE TABLE IF NOT EXISTS users_v4 (user_id serial, username TEXT)` + sqlStmt := `CREATE TABLE IF NOT EXISTS users_v4 (user_id SERIAL, username TEXT)` _, err = pool.Exec(ctx, sqlStmt) checkErr(err, sqlStmt) diff --git a/pgxv4/factory.go b/drivers/pgxv4/factory.go similarity index 89% rename from pgxv4/factory.go rename to drivers/pgxv4/factory.go index 687b076..2f1b375 100644 --- a/pgxv4/factory.go +++ b/drivers/pgxv4/factory.go @@ -6,7 +6,7 @@ package pgxv4 import ( "context" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // NewDefaultFactory creates default trm.Transaction(pgx.Tx). diff --git a/drivers/pgxv4/go.mod b/drivers/pgxv4/go.mod new file mode 100644 index 0000000..3c386f2 --- /dev/null +++ b/drivers/pgxv4/go.mod @@ -0,0 +1,9 @@ +module github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2 + +go 1.13 + +require ( + github.com/avito-tech/go-transaction-manager/v2 v2.0.0 +) + +replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ \ No newline at end of file diff --git a/pgxv4/settings.go b/drivers/pgxv4/settings.go similarity index 96% rename from pgxv4/settings.go rename to drivers/pgxv4/settings.go index f749198..b03e41e 100644 --- a/pgxv4/settings.go +++ b/drivers/pgxv4/settings.go @@ -6,7 +6,7 @@ package pgxv4 import ( "github.com/jackc/pgx/v4" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // Opt is a type to configure Settings. diff --git a/pgxv4/settings_test.go b/drivers/pgxv4/settings_test.go similarity index 93% rename from pgxv4/settings_test.go rename to drivers/pgxv4/settings_test.go index 9423fb3..474ee6c 100644 --- a/pgxv4/settings_test.go +++ b/drivers/pgxv4/settings_test.go @@ -9,8 +9,8 @@ import ( "github.com/jackc/pgx/v4" "github.com/stretchr/testify/assert" - "github.com/avito-tech/go-transaction-manager/trm" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/avito-tech/go-transaction-manager/v2/settings" ) func TestSettings_EnrichBy(t *testing.T) { diff --git a/pgxv4/transaction.go b/drivers/pgxv4/transaction.go similarity index 96% rename from pgxv4/transaction.go rename to drivers/pgxv4/transaction.go index 55673ce..9b95c74 100644 --- a/pgxv4/transaction.go +++ b/drivers/pgxv4/transaction.go @@ -9,7 +9,7 @@ import ( "github.com/jackc/pgx/v4" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // Transaction is trm.Transaction for pgx.Tx. diff --git a/pgxv4/transaction_test.go b/drivers/pgxv4/transaction_test.go similarity index 94% rename from pgxv4/transaction_test.go rename to drivers/pgxv4/transaction_test.go index a1b6b01..4f7b09d 100644 --- a/pgxv4/transaction_test.go +++ b/drivers/pgxv4/transaction_test.go @@ -15,11 +15,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/avito-tech/go-transaction-manager/internal/mock" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" - "github.com/avito-tech/go-transaction-manager/trm/manager" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" + + "github.com/avito-tech/go-transaction-manager/v2/settings" + + "github.com/avito-tech/go-transaction-manager/v2/manager" ) func TestTransaction(t *testing.T) { diff --git a/pgxv5/context.go b/drivers/pgxv5/context.go similarity index 89% rename from pgxv5/context.go rename to drivers/pgxv5/context.go index 988b243..3c65499 100644 --- a/pgxv5/context.go +++ b/drivers/pgxv5/context.go @@ -6,8 +6,8 @@ package pgxv5 import ( "context" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" + trm "github.com/avito-tech/go-transaction-manager/v2" + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" ) // DefaultCtxGetter is the CtxGetter with settings.DefaultCtxKey. diff --git a/pgxv5/contract.go b/drivers/pgxv5/contract.go similarity index 100% rename from pgxv5/contract.go rename to drivers/pgxv5/contract.go diff --git a/pgxv5/example_test.go b/drivers/pgxv5/example_test.go similarity index 92% rename from pgxv5/example_test.go rename to drivers/pgxv5/example_test.go index 17e2e03..4cff472 100644 --- a/pgxv5/example_test.go +++ b/drivers/pgxv5/example_test.go @@ -9,8 +9,8 @@ import ( "github.com/jackc/pgx/v5/pgxpool" - trmpgx "github.com/avito-tech/go-transaction-manager/pgxv5" - "github.com/avito-tech/go-transaction-manager/trm/manager" +"github.com/avito-tech/go-transaction-manager/v2/manager" +trmpgx "github.com/avito-tech/go-transaction-manager/v2/pgxv5" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. @@ -26,7 +26,7 @@ func Example() { defer pool.Close() - sqlStmt := `CREATE TABLE IF NOT EXISTS users_v5 (user_id serial, username TEXT)` + sqlStmt := `CREATE TABLE IF NOT EXISTS users_v5 (user_id SERIAL, username TEXT)` _, err = pool.Exec(ctx, sqlStmt) checkErr(err, sqlStmt) diff --git a/pgxv5/factory.go b/drivers/pgxv5/factory.go similarity index 89% rename from pgxv5/factory.go rename to drivers/pgxv5/factory.go index 82295c8..1391816 100644 --- a/pgxv5/factory.go +++ b/drivers/pgxv5/factory.go @@ -6,7 +6,7 @@ package pgxv5 import ( "context" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // NewDefaultFactory creates default trm.Transaction(pgx.Tx). diff --git a/drivers/pgxv5/go.mod b/drivers/pgxv5/go.mod new file mode 100644 index 0000000..f27bd16 --- /dev/null +++ b/drivers/pgxv5/go.mod @@ -0,0 +1,9 @@ +module github.com/avito-tech/go-transaction-manager/drivers/pgxv5/v2 + +go 1.13 + +require ( + github.com/avito-tech/go-transaction-manager/v2 v2.0.0 +) + +replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ \ No newline at end of file diff --git a/pgxv5/settings.go b/drivers/pgxv5/settings.go similarity index 96% rename from pgxv5/settings.go rename to drivers/pgxv5/settings.go index 82ed2cb..99e2565 100644 --- a/pgxv5/settings.go +++ b/drivers/pgxv5/settings.go @@ -6,7 +6,7 @@ package pgxv5 import ( "github.com/jackc/pgx/v5" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // Opt is a type to configure Settings. diff --git a/pgxv5/settings_test.go b/drivers/pgxv5/settings_test.go similarity index 93% rename from pgxv5/settings_test.go rename to drivers/pgxv5/settings_test.go index 9a5e3aa..d683380 100644 --- a/pgxv5/settings_test.go +++ b/drivers/pgxv5/settings_test.go @@ -9,8 +9,8 @@ import ( "github.com/jackc/pgx/v5" "github.com/stretchr/testify/assert" - "github.com/avito-tech/go-transaction-manager/trm" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/avito-tech/go-transaction-manager/v2/settings" ) func TestSettings_EnrichBy(t *testing.T) { diff --git a/pgxv5/transaction.go b/drivers/pgxv5/transaction.go similarity index 96% rename from pgxv5/transaction.go rename to drivers/pgxv5/transaction.go index 7e713f0..fdb15d5 100644 --- a/pgxv5/transaction.go +++ b/drivers/pgxv5/transaction.go @@ -9,7 +9,7 @@ import ( "github.com/jackc/pgx/v5" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // Transaction is trm.Transaction for pgx.Tx. diff --git a/pgxv5/transaction_test.go b/drivers/pgxv5/transaction_test.go similarity index 94% rename from pgxv5/transaction_test.go rename to drivers/pgxv5/transaction_test.go index 709f308..012216f 100644 --- a/pgxv5/transaction_test.go +++ b/drivers/pgxv5/transaction_test.go @@ -15,11 +15,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/avito-tech/go-transaction-manager/internal/mock" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" - "github.com/avito-tech/go-transaction-manager/trm/manager" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" + + "github.com/avito-tech/go-transaction-manager/v2/settings" + + "github.com/avito-tech/go-transaction-manager/v2/manager" ) func TestTransaction(t *testing.T) { diff --git a/sql/context.go b/drivers/sql/context.go similarity index 89% rename from sql/context.go rename to drivers/sql/context.go index dac65a4..43d31d7 100644 --- a/sql/context.go +++ b/drivers/sql/context.go @@ -4,8 +4,8 @@ import ( "context" "database/sql" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" + trm "github.com/avito-tech/go-transaction-manager/v2" + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" ) // DefaultCtxGetter is the CtxGetter with settings.DefaultCtxKey. diff --git a/sql/contract.go b/drivers/sql/contract.go similarity index 100% rename from sql/contract.go rename to drivers/sql/contract.go diff --git a/sql/example_test.go b/drivers/sql/example_test.go similarity index 92% rename from sql/example_test.go rename to drivers/sql/example_test.go index 0d6a508..ab3bd87 100644 --- a/sql/example_test.go +++ b/drivers/sql/example_test.go @@ -7,9 +7,10 @@ import ( _ "github.com/mattn/go-sqlite3" - trmsql "github.com/avito-tech/go-transaction-manager/sql" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" - "github.com/avito-tech/go-transaction-manager/trm/manager" + trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" + + "github.com/avito-tech/go-transaction-manager/v2/manager" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. diff --git a/sql/factory.go b/drivers/sql/factory.go similarity index 89% rename from sql/factory.go rename to drivers/sql/factory.go index 14abb9f..dc2467f 100644 --- a/sql/factory.go +++ b/drivers/sql/factory.go @@ -4,7 +4,7 @@ import ( "context" "database/sql" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // NewDefaultFactory creates default trm.Transaction(sql.Tx). diff --git a/drivers/sql/go.mod b/drivers/sql/go.mod new file mode 100644 index 0000000..6ca597c --- /dev/null +++ b/drivers/sql/go.mod @@ -0,0 +1,9 @@ +module github.com/avito-tech/go-transaction-manager/drivers/sql/v2 + +go 1.13 + +require ( + github.com/avito-tech/go-transaction-manager/v2 v2.0.0 +) + +replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ \ No newline at end of file diff --git a/sql/mock/savepoint.go b/drivers/sql/mock/savepoint.go similarity index 100% rename from sql/mock/savepoint.go rename to drivers/sql/mock/savepoint.go diff --git a/sql/savepoint.go b/drivers/sql/savepoint.go similarity index 100% rename from sql/savepoint.go rename to drivers/sql/savepoint.go diff --git a/sql/settings.go b/drivers/sql/settings.go similarity index 96% rename from sql/settings.go rename to drivers/sql/settings.go index 8295a82..7ec34b6 100644 --- a/sql/settings.go +++ b/drivers/sql/settings.go @@ -3,7 +3,7 @@ package sql import ( "database/sql" - "github.com/avito-tech/go-transaction-manager/trm" +trm "github.com/avito-tech/go-transaction-manager/v2" ) // Opt is a type to configure Settings. diff --git a/sql/settings_test.go b/drivers/sql/settings_test.go similarity index 93% rename from sql/settings_test.go rename to drivers/sql/settings_test.go index cd329c5..5f3446d 100644 --- a/sql/settings_test.go +++ b/drivers/sql/settings_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/avito-tech/go-transaction-manager/trm" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/avito-tech/go-transaction-manager/v2/settings" ) func TestSettings_EnrichBy(t *testing.T) { diff --git a/sql/transaction.go b/drivers/sql/transaction.go similarity index 97% rename from sql/transaction.go rename to drivers/sql/transaction.go index e8e6d1a..aab1519 100644 --- a/sql/transaction.go +++ b/drivers/sql/transaction.go @@ -8,7 +8,7 @@ import ( "go.uber.org/multierr" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // Transaction is trm.Transaction for sql.Tx. diff --git a/sql/transaction_test.go b/drivers/sql/transaction_test.go similarity index 94% rename from sql/transaction_test.go rename to drivers/sql/transaction_test.go index 7d1eefa..6cd1da1 100644 --- a/sql/transaction_test.go +++ b/drivers/sql/transaction_test.go @@ -11,11 +11,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/avito-tech/go-transaction-manager/internal/mock" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" - "github.com/avito-tech/go-transaction-manager/trm/manager" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" + + "github.com/avito-tech/go-transaction-manager/v2/settings" + + "github.com/avito-tech/go-transaction-manager/v2/manager" ) func TestTransaction(t *testing.T) { diff --git a/sqlx/chained_example_test.go b/drivers/sqlx/chained_example_test.go similarity index 84% rename from sqlx/chained_example_test.go rename to drivers/sqlx/chained_example_test.go index 2ff7c48..b863503 100644 --- a/sqlx/chained_example_test.go +++ b/drivers/sqlx/chained_example_test.go @@ -6,11 +6,13 @@ import ( _ "github.com/mattn/go-sqlite3" - trmsqlx "github.com/avito-tech/go-transaction-manager/sqlx" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" - "github.com/avito-tech/go-transaction-manager/trm/manager" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" + trm "github.com/avito-tech/go-transaction-manager/v2" + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" + + "github.com/avito-tech/go-transaction-manager/v2/settings" + + "github.com/avito-tech/go-transaction-manager/v2/manager" ) // Example demonstrates a work of manager.ChainedMW. diff --git a/sqlx/context.go b/drivers/sqlx/context.go similarity index 89% rename from sqlx/context.go rename to drivers/sqlx/context.go index 59c6399..386e0bf 100644 --- a/sqlx/context.go +++ b/drivers/sqlx/context.go @@ -5,8 +5,8 @@ import ( "github.com/jmoiron/sqlx" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" + trm "github.com/avito-tech/go-transaction-manager/v2" + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" ) // DefaultCtxGetter is the CtxGetter with settings.DefaultCtxKey. diff --git a/sqlx/contract.go b/drivers/sqlx/contract.go similarity index 100% rename from sqlx/contract.go rename to drivers/sqlx/contract.go diff --git a/sqlx/example_test.go b/drivers/sqlx/example_test.go similarity index 89% rename from sqlx/example_test.go rename to drivers/sqlx/example_test.go index 60a7fdd..1c1498b 100644 --- a/sqlx/example_test.go +++ b/drivers/sqlx/example_test.go @@ -7,8 +7,7 @@ import ( "github.com/jmoiron/sqlx" _ "github.com/mattn/go-sqlite3" - trmsqlx "github.com/avito-tech/go-transaction-manager/sqlx" - "github.com/avito-tech/go-transaction-manager/trm/manager" +"github.com/avito-tech/go-transaction-manager/v2/manager" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. @@ -21,14 +20,14 @@ func Example() { _, err := db.Exec(sqlStmt) checkErr(err, sqlStmt) - r := newRepo(db, trmsqlx.DefaultCtxGetter) + r := newRepo(db, DefaultCtxGetter) u := &user{ Username: "username", } ctx := context.Background() - trManager := manager.Must(trmsqlx.NewDefaultFactory(db)) + trManager := manager.Must(NewDefaultFactory(db)) err = trManager.Do(ctx, func(ctx context.Context) error { if err := r.Save(ctx, u); err != nil { @@ -60,10 +59,10 @@ func newDB() *sqlx.DB { type repo struct { db *sqlx.DB - getter *trmsqlx.CtxGetter + getter *CtxGetter } -func newRepo(db *sqlx.DB, c *trmsqlx.CtxGetter) *repo { +func newRepo(db *sqlx.DB, c *CtxGetter) *repo { return &repo{ db: db, getter: c, diff --git a/sqlx/factory.go b/drivers/sqlx/factory.go similarity index 82% rename from sqlx/factory.go rename to drivers/sqlx/factory.go index 59daaf3..fabe090 100644 --- a/sqlx/factory.go +++ b/drivers/sqlx/factory.go @@ -5,8 +5,7 @@ import ( "github.com/jmoiron/sqlx" - trmsql "github.com/avito-tech/go-transaction-manager/sql" - "github.com/avito-tech/go-transaction-manager/trm" + trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" ) // NewDefaultFactory creates default trm.Transaction(sqlx.Tx). diff --git a/drivers/sqlx/go.mod b/drivers/sqlx/go.mod new file mode 100644 index 0000000..2c9e005 --- /dev/null +++ b/drivers/sqlx/go.mod @@ -0,0 +1,11 @@ +module github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2 + +go 1.13 + +require ( + github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 +) + +replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ +replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 => ../sql \ No newline at end of file diff --git a/sqlx/transaction.go b/drivers/sqlx/transaction.go similarity index 95% rename from sqlx/transaction.go rename to drivers/sqlx/transaction.go index c8873b2..18723cc 100644 --- a/sqlx/transaction.go +++ b/drivers/sqlx/transaction.go @@ -9,8 +9,7 @@ import ( "github.com/jmoiron/sqlx" "go.uber.org/multierr" - trmsql "github.com/avito-tech/go-transaction-manager/sql" - "github.com/avito-tech/go-transaction-manager/trm" +trmsql github.com/avito-tech/go-transaction-manager/v2/sql" ) // Transaction is trm.Transaction for sqlx.Tx. diff --git a/sqlx/transaction_test.go b/drivers/sqlx/transaction_test.go similarity index 94% rename from sqlx/transaction_test.go rename to drivers/sqlx/transaction_test.go index 3d048cb..d7477e7 100644 --- a/sqlx/transaction_test.go +++ b/drivers/sqlx/transaction_test.go @@ -12,11 +12,14 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/avito-tech/go-transaction-manager/internal/mock" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" - "github.com/avito-tech/go-transaction-manager/trm/manager" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" + + "github.com/avito-tech/go-transaction-manager/v2/settings" + + "github.com/avito-tech/go-transaction-manager/v2/manager" ) func TestTransaction(t *testing.T) { diff --git a/go.mod b/go.mod index 55a9164..e68c5d5 100644 --- a/go.mod +++ b/go.mod @@ -1,25 +1,11 @@ -module github.com/avito-tech/go-transaction-manager +module github.com/avito-tech/go-transaction-manager/v2 go 1.13 require ( - github.com/DATA-DOG/go-sqlmock v1.5.1 - github.com/go-redis/redis/v8 v8.11.5 - github.com/go-redis/redismock/v8 v8.11.5 github.com/golang/mock v1.6.0 - github.com/jackc/pgconn v1.14.1 - github.com/jackc/pgx/v4 v4.18.1 - github.com/jackc/pgx/v5 v5.5.1 - github.com/jinzhu/copier v0.3.5 - github.com/jmoiron/sqlx v1.3.5 - github.com/mattn/go-sqlite3 v1.14.16 - github.com/onsi/gomega v1.24.1 // indirect - github.com/pashagolub/pgxmock v1.8.0 - github.com/pashagolub/pgxmock/v2 v2.12.0 + github.com/kr/pretty v0.3.0 // indirect github.com/stretchr/testify v1.8.2 - go.mongodb.org/mongo-driver v1.12.1 go.uber.org/multierr v1.9.0 - gorm.io/driver/mysql v1.5.2 - gorm.io/driver/sqlite v1.5.1 - gorm.io/gorm v1.25.3 + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) diff --git a/go.sum b/go.sum deleted file mode 100644 index ff5e7d2..0000000 --- a/go.sum +++ /dev/null @@ -1,419 +0,0 @@ -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DATA-DOG/go-sqlmock v1.5.1 h1:FK6RCIUSfmbnI/imIICmboyQBkOckutaa6R5YYlLZyo= -github.com/DATA-DOG/go-sqlmock v1.5.1/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= -github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= -github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= -github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -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-redis/redismock/v8 v8.11.5 h1:RJFIiua58hrBrSpXhnGX3on79AU3S271H4ZhRI1wyVo= -github.com/go-redis/redismock/v8 v8.11.5/go.mod h1:UaAU9dEe1C+eGr+FHV5prCWIt0hafyPWbGMEWE0UWdA= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= -github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= -github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= -github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= -github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= -github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= -github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= -github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= -github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= -github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= -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/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= -github.com/jackc/pgconn v1.14.0/go.mod h1:9mBNlny0UvkgJdCDvdVHYSjI+8tD2rnKK69Wz8ti++E= -github.com/jackc/pgconn v1.14.1 h1:smbxIaZA08n6YuxEX1sDyjV/qkbtUtkH20qLkR9MUR4= -github.com/jackc/pgconn v1.14.1/go.mod h1:9mBNlny0UvkgJdCDvdVHYSjI+8tD2rnKK69Wz8ti++E= -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= -github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= -github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc= -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= -github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= -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.0.7/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/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.3.2 h1:7eY55bdBeCz1F2fTzSz69QC+pG46jYq9/jtSPiJ5nn0= -github.com/jackc/pgproto3/v2 v2.3.2/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.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= -github.com/jackc/pgtype v1.14.0 h1:y+xUdabmyMkJLyApYuPj38mW+aAIqCe5uuBB51rH3Vw= -github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= -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/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.17.0/go.mod h1:Gd6RmOhtFLTu8cp/Fhq4kP195KrshxYJH3oW8AWJ1pw= -github.com/jackc/pgx/v4 v4.18.1 h1:YP7G1KABtKpB5IHrO9vYwSrCOhs7p3uqhvhhQBptya0= -github.com/jackc/pgx/v4 v4.18.1/go.mod h1:FydWkUyadDmdNH/mHnGob881GawxeEm7TcMCzkb+qQE= -github.com/jackc/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA= -github.com/jackc/pgx/v5 v5.5.1 h1:5I9etrGkLrN+2XPCsi6XLlV5DITbSL/xBZdmAxFcXPI= -github.com/jackc/pgx/v5 v5.5.1/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA= -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.2.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v1.3.0 h1:eHK/5clGOatcjX3oWGBO/MpxpbHzSwud5EWTSCI+MX0= -github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= -github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= -github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg= -github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= -github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= -github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= -github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= -github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= -github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= -github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -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/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= -github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= -github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= -github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= -github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= -github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= -github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= -github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= -github.com/onsi/ginkgo/v2 v2.3.0/go.mod h1:Eew0uilEqZmIEZr8JrvYlvOM7Rr6xzTmMV8AyFNU9d0= -github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo= -github.com/onsi/ginkgo/v2 v2.5.0 h1:TRtrvv2vdQqzkwrQ1ke6vtXf7IK34RBUJafIy1wMwls= -github.com/onsi/ginkgo/v2 v2.5.0/go.mod h1:Luc4sArBICYCS8THh8v3i3i5CuSZO+RaQRaJoeNwomw= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= -github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= -github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= -github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= -github.com/onsi/gomega v1.21.1/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8luStNc= -github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM= -github.com/onsi/gomega v1.24.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= -github.com/onsi/gomega v1.24.1 h1:KORJXNNTzJXzu4ScJWssJfJMnJ+2QJqhoQSRwNlze9E= -github.com/onsi/gomega v1.24.1/go.mod h1:3AOiACssS3/MajrniINInwbfOOtfZvplPzuRSmvt1jM= -github.com/pashagolub/pgxmock v1.8.0 h1:05JB+jng7yPdeC6i04i8TC4H1Kr7TfcFeQyf4JP6534= -github.com/pashagolub/pgxmock v1.8.0/go.mod h1:kDkER7/KJdD3HQjNvFw5siwR7yREKmMvwf8VhAgTK5o= -github.com/pashagolub/pgxmock/v2 v2.12.0 h1:IVRmQtVFNCoq7NOZ+PdfvB6fwnLJmEuWDhnc3yrDxBs= -github.com/pashagolub/pgxmock/v2 v2.12.0/go.mod h1:D3YslkN/nJ4+umVqWmbwfSXugJIjPMChkGBG47OJpNw= -github.com/pashagolub/pgxstruct v0.0.0-20210217101842-40d357eec200/go.mod h1:fOTLLi1PtVUDXx28olVT/D2UMFCmBEYpnY5QIzghmDc= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.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= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= -github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= -github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= -github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= -github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= -github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= -github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -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= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -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 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= -github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= -github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= -github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= -github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= -go.mongodb.org/mongo-driver v1.12.1 h1:nLkghSU8fQNaK7oUmDhQFsnrtcoNy7Z6LVFKsEecqgE= -go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ= -go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -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.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -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= -go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= -go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= -go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/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-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -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-20220622213112-05595931fe9d/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/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -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-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -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.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/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-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 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/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-20211019181941-9d821ace8654/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-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/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.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -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.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -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/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -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.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= -golang.org/x/text v0.4.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 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -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= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/driver/mysql v1.5.2 h1:QC2HRskSE75wBuOxe0+iCkyJZ+RqpudsQtqkp+IMuXs= -gorm.io/driver/mysql v1.5.2/go.mod h1:pQLhh1Ut/WUAySdTHwBpBv6+JKcj+ua4ZFx1QQTBzb8= -gorm.io/driver/sqlite v1.5.1 h1:hYyrLkAWE71bcarJDPdZNTLWtr8XrSjOWyjUYI6xdL4= -gorm.io/driver/sqlite v1.5.1/go.mod h1:7MZZ2Z8bqyfSQA1gYEV6MagQWj3cpUkJj9Z+d1HEMEQ= -gorm.io/gorm v1.25.0/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= -gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= -gorm.io/gorm v1.25.3 h1:zi4rHZj1anhZS2EuEODMhDisGy+Daq9jtPrNGgbQYD8= -gorm.io/gorm v1.25.3/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/internal/benchmark/allocation/key_in_ctx.go b/internal/benchmark/allocation/key_in_ctx.go index fdb8d4f..e979184 100644 --- a/internal/benchmark/allocation/key_in_ctx.go +++ b/internal/benchmark/allocation/key_in_ctx.go @@ -4,7 +4,7 @@ import ( "context" "sync" - "github.com/avito-tech/go-transaction-manager/internal/benchmark/common" + "github.com/avito-tech/go-transaction-manager/v2/internal/benchmark/common" ) func keyInContext() { diff --git a/internal/benchmark/allocation/tx_in_ctx.go b/internal/benchmark/allocation/tx_in_ctx.go index cc7089a..af1fc36 100644 --- a/internal/benchmark/allocation/tx_in_ctx.go +++ b/internal/benchmark/allocation/tx_in_ctx.go @@ -6,7 +6,7 @@ import ( "github.com/jmoiron/sqlx" - "github.com/avito-tech/go-transaction-manager/internal/benchmark/common" + "github.com/avito-tech/go-transaction-manager/v2/internal/benchmark/common" ) func trInContext() { diff --git a/internal/benchmark/map_vs_context/common.go b/internal/benchmark/map_vs_context/common.go index fd59957..5f8e625 100644 --- a/internal/benchmark/map_vs_context/common.go +++ b/internal/benchmark/map_vs_context/common.go @@ -6,7 +6,7 @@ import ( "github.com/jinzhu/copier" - "github.com/avito-tech/go-transaction-manager/internal/benchmark/common" + "github.com/avito-tech/go-transaction-manager/v2/internal/benchmark/common" ) func getDB() *sql.DB { diff --git a/internal/benchmark/map_vs_context/context_test.go b/internal/benchmark/map_vs_context/context_test.go index b42570a..faa3ecf 100644 --- a/internal/benchmark/map_vs_context/context_test.go +++ b/internal/benchmark/map_vs_context/context_test.go @@ -8,7 +8,7 @@ import ( _ "github.com/mattn/go-sqlite3" - "github.com/avito-tech/go-transaction-manager/internal/benchmark/common" + "github.com/avito-tech/go-transaction-manager/v2/internal/benchmark/common" ) const ( diff --git a/internal/benchmark/map_vs_context/map_test.go b/internal/benchmark/map_vs_context/map_test.go index 64f2bde..9cb4c92 100644 --- a/internal/benchmark/map_vs_context/map_test.go +++ b/internal/benchmark/map_vs_context/map_test.go @@ -8,7 +8,7 @@ import ( _ "github.com/mattn/go-sqlite3" - "github.com/avito-tech/go-transaction-manager/internal/benchmark/common" + "github.com/avito-tech/go-transaction-manager/v2/internal/benchmark/common" ) // run with -test.benchtime=1s -test.benchmem diff --git a/internal/benchmark/with_or_without_trm/trm_test.go b/internal/benchmark/with_or_without_trm/trm_test.go.skip similarity index 88% rename from internal/benchmark/with_or_without_trm/trm_test.go rename to internal/benchmark/with_or_without_trm/trm_test.go.skip index 57f980b..9c16573 100644 --- a/internal/benchmark/with_or_without_trm/trm_test.go +++ b/internal/benchmark/with_or_without_trm/trm_test.go.skip @@ -8,8 +8,9 @@ import ( _ "github.com/mattn/go-sqlite3" "github.com/stretchr/testify/require" - trmsqlx "github.com/avito-tech/go-transaction-manager/sqlx" - "github.com/avito-tech/go-transaction-manager/trm/manager" + trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" + + "github.com/avito-tech/go-transaction-manager/v2/manager" ) func BenchmarkTRM_MockDB(b *testing.B) { diff --git a/internal/benchmark/with_or_without_trm/trmrepo.go b/internal/benchmark/with_or_without_trm/trmrepo.go.skip similarity index 92% rename from internal/benchmark/with_or_without_trm/trmrepo.go rename to internal/benchmark/with_or_without_trm/trmrepo.go.skip index aa67a4b..7a21865 100644 --- a/internal/benchmark/with_or_without_trm/trmrepo.go +++ b/internal/benchmark/with_or_without_trm/trmrepo.go.skip @@ -5,7 +5,7 @@ import ( "github.com/jmoiron/sqlx" - trmsqlx "github.com/avito-tech/go-transaction-manager/sqlx" + trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" ) type trmRepo struct { diff --git a/internal/example/habr/finished/.gitignore b/internal/example/habr/finished/.gitignore deleted file mode 100644 index 05ba2b1..0000000 --- a/internal/example/habr/finished/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/vendor - -/test.db \ No newline at end of file diff --git a/internal/example/habr/finished/domain/order.go b/internal/example/habr/finished/domain/order.go deleted file mode 100644 index 6ddcae3..0000000 --- a/internal/example/habr/finished/domain/order.go +++ /dev/null @@ -1,43 +0,0 @@ -package domain - -import "errors" - -var ( - ErrInvalidUserID = errors.New("invalid user id") - ErrInvalidProductID = errors.New("invalid product id") - ErrInvalidQuantity = errors.New("quantity should be more 1") -) - -type OrderID int64 -type ProductID int64 - -type Order struct { - ID OrderID - ProductID ProductID - UserID UserID - Quantity int64 -} - -func NewOrder(userID UserID, productID ProductID, quantity int64) (*Order, error) { - if userID <= 0 { - return nil, ErrInvalidUserID - } - - if productID <= 0 { - return nil, ErrInvalidProductID - } - - if quantity <= 0 { - return nil, ErrInvalidQuantity - } - - return &Order{ - UserID: userID, - ProductID: productID, - Quantity: quantity, - }, nil -} - -type Purchased struct { - ID OrderID -} diff --git a/internal/example/habr/finished/domain/repository.go b/internal/example/habr/finished/domain/repository.go deleted file mode 100644 index c884044..0000000 --- a/internal/example/habr/finished/domain/repository.go +++ /dev/null @@ -1,16 +0,0 @@ -package domain - -import ( - "context" -) - -type UserRepo interface { - GetByID(context.Context, UserID) (*User, error) - Save(context.Context, *User) error -} - -type OrderRepo interface { - GetByID(context.Context, OrderID) (*Order, error) - GetByUserID(context.Context, UserID) (*Order, error) - Save(context.Context, *Order) error -} diff --git a/internal/example/habr/finished/domain/user.go b/internal/example/habr/finished/domain/user.go deleted file mode 100644 index fa1286a..0000000 --- a/internal/example/habr/finished/domain/user.go +++ /dev/null @@ -1,46 +0,0 @@ -package domain - -import "errors" - -var ( - ErrEmptyUsername = errors.New("empty username") - ErrEmptyPassword = errors.New("empty password") -) - -type UserID int64 - -type User struct { - ID UserID - Username string - // В реальном проекте Пароли храните в захэшированном виде! - Password string - Notification Notification -} - -func NewUser(username string, password string) (*User, error) { - if username == "" { - return nil, ErrEmptyUsername - } - - if password == "" { - return nil, ErrEmptyPassword - } - - return &User{ - Username: username, - Password: password, - Notification: Notification{ - Email: false, - SMS: true, - }, - }, nil -} - -type Notification struct { - Email bool - SMS bool -} - -type Registered struct { - ID UserID -} diff --git a/internal/example/habr/finished/go.mod b/internal/example/habr/finished/go.mod deleted file mode 100644 index da4321e..0000000 --- a/internal/example/habr/finished/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module finish - -go 1.18 - -require ( - github.com/avito-tech/go-transaction-manager v1.2.1 - github.com/jmoiron/sqlx v1.3.5 - github.com/mattn/go-sqlite3 v1.14.16 -) diff --git a/internal/example/habr/finished/go.sum b/internal/example/habr/finished/go.sum deleted file mode 100644 index 15dd76c..0000000 --- a/internal/example/habr/finished/go.sum +++ /dev/null @@ -1,210 +0,0 @@ -github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= -github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/avito-tech/go-transaction-manager v1.2.1 h1:E1e7jkAr3Ng2eKTl8RiUEGZrc52r7T9MHSpLrWlxUII= -github.com/avito-tech/go-transaction-manager v1.2.1/go.mod h1:7U3IXmoi/YiuGVLZQIEinTQhm2OD2ED3P8i9PLiaLL8= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= -github.com/go-redis/redismock/v8 v8.11.5/go.mod h1:UaAU9dEe1C+eGr+FHV5prCWIt0hafyPWbGMEWE0UWdA= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= -github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= -github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= -github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= -github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= -github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= -github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= -github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= -github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= -github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= -github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= -github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk= -github.com/onsi/ginkgo/v2 v2.3.0/go.mod h1:Eew0uilEqZmIEZr8JrvYlvOM7Rr6xzTmMV8AyFNU9d0= -github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo= -github.com/onsi/ginkgo/v2 v2.5.0/go.mod h1:Luc4sArBICYCS8THh8v3i3i5CuSZO+RaQRaJoeNwomw= -github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= -github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= -github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= -github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo= -github.com/onsi/gomega v1.21.1/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8luStNc= -github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM= -github.com/onsi/gomega v1.24.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg= -github.com/onsi/gomega v1.24.1/go.mod h1:3AOiACssS3/MajrniINInwbfOOtfZvplPzuRSmvt1jM= -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= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= -github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g= -github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= -github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver v1.11.3/go.mod h1:PTSz5yu21bkT/wXpkS7WR5f0ddqw5quethTUn9WM+2g= -go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= -go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -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-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -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.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/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-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/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/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-20211019181941-9d821ace8654/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-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/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.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -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.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/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.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/driver/mysql v1.4.7/go.mod h1:SxzItlnT1cb6e1e4ZRpgJN2VYtcqJgqnHxWr4wsP8oc= -gorm.io/driver/sqlite v1.4.4/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI= -gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= -gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= -gorm.io/gorm v1.24.6/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= diff --git a/internal/example/habr/finished/main_test.go b/internal/example/habr/finished/main_test.go deleted file mode 100644 index 630da45..0000000 --- a/internal/example/habr/finished/main_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package main - -import ( - "context" - "encoding/json" - "fmt" - "log" - - trmsqlx "github.com/avito-tech/go-transaction-manager/sqlx" - "github.com/avito-tech/go-transaction-manager/trm/manager" - "github.com/jmoiron/sqlx" - _ "github.com/mattn/go-sqlite3" - - "finish/domain" - "finish/queue" - "finish/repo" - "finish/usecase/fast_purchase" - purchaseUC "finish/usecase/purchase" - registerUC "finish/usecase/register" -) - -// language=SQLite -const sqlStmt = ` -DROP TABLE IF EXISTS "user"; -CREATE TABLE IF NOT EXISTS "user" -( - id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - username TEXT NOT NULL, - password TEXT NOT NULL, - notification TEXT -); -INSERT INTO "user" (username, password, notification) VALUES ('user1', 'password1', 'email1'); - -DROP TABLE IF EXISTS "order"; -CREATE TABLE IF NOT EXISTS "order" -( - id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - user_id INTEGER NOT NULL, - product_id INTEGER NOT NULL, - quantity INTEGER NOT NULL -); -` - -func Example() { - db, err := sqlx.Open("sqlite3", "file:test.db") - if err != nil { - log.Fatal(err) - } - - _, err = db.Exec(sqlStmt) - if err != nil { - log.Fatal(err) - } - - // Repo - trManager := manager.Must(trmsqlx.NewDefaultFactory(db)) - userRepo := repo.NewUserRepo(db, trmsqlx.DefaultCtxGetter) - orderRepo := repo.NewOrderRepo(db, trmsqlx.DefaultCtxGetter) - - queueRegistered := queue.Queue[domain.Registered]{} - queuePurchased := queue.Queue[domain.Purchased]{} - - // usecase - register := registerUC.New(userRepo, trManager, queueRegistered) - purchase := purchaseUC.New(orderRepo, trManager, queuePurchased) - fastPurchase := fast_purchase.New(trManager, register, purchase) - - ctx := context.Background() - - out, err := fastPurchase.Handle(ctx, fast_purchase.In{ - Register: fast_purchase.RegisterIn{ - Username: "username", - }, - Purchase: fast_purchase.PurchaseIn{ - ProductID: 1, - Quantity: 10, - }, - }) - if err != nil { - log.Fatal(err) - } - - res, _ := json.MarshalIndent(out, "", "\t") - fmt.Println(string(res)) - - // Output: { - // "User": { - // "ID": 2, - // "Username": "username", - // "Password": "", - // "Notification": { - // "Email": false, - // "SMS": true - // } - // }, - // "Order": { - // "ID": 1, - // "ProductID": 1, - // "UserID": 2, - // "Quantity": 10 - // } - //} -} diff --git a/internal/example/habr/finished/queue/queue.go b/internal/example/habr/finished/queue/queue.go deleted file mode 100644 index bfe37ba..0000000 --- a/internal/example/habr/finished/queue/queue.go +++ /dev/null @@ -1,11 +0,0 @@ -package queue - -import ( - "context" -) - -type Queue[In any] struct{} - -func (Queue[In]) Publish(_ context.Context, in In) error { - return nil -} diff --git a/internal/example/habr/finished/repo/order.go b/internal/example/habr/finished/repo/order.go deleted file mode 100644 index 6268edb..0000000 --- a/internal/example/habr/finished/repo/order.go +++ /dev/null @@ -1,95 +0,0 @@ -package repo - -import ( - "context" - - trmsqlx "github.com/avito-tech/go-transaction-manager/sqlx" - "github.com/jmoiron/sqlx" - - "finish/domain" -) - -type orderRow struct { - ID domain.OrderID `db:"id"` - ProductID domain.ProductID `db:"product_id"` - UserID domain.UserID `db:"user_id"` - Quantity int64 `db:"quantity"` -} - -type orderRepo struct { - db *sqlx.DB - getter *trmsqlx.CtxGetter -} - -func NewOrderRepo(db *sqlx.DB, getter *trmsqlx.CtxGetter) *orderRepo { - return &orderRepo{db: db, getter: getter} -} - -func (r *orderRepo) GetByID(ctx context.Context, id domain.OrderID) (*domain.Order, error) { - query := `SELECT * FROM "order" WHERE id = ?;` - row := orderRow{} - - err := r.getter.DefaultTrOrDB(ctx, r.db).GetContext(ctx, &row, r.db.Rebind(query), id) - if err != nil { - return nil, err - } - - return r.toModel(row), nil -} - -func (r *orderRepo) GetByUserID(ctx context.Context, id domain.UserID) (*domain.Order, error) { - query := `SELECT * FROM "order" WHERE user_id = ?;` - row := orderRow{} - - err := r.getter.DefaultTrOrDB(ctx, r.db).GetContext(ctx, &row, r.db.Rebind(query), id) - if err != nil { - return nil, err - } - - return r.toModel(row), nil -} - -func (r *orderRepo) Save(ctx context.Context, o *domain.Order) error { - query := `INSERT INTO "order" (product_id, user_id, quantity) -VALUES (:product_id, :user_id, :quantity) -ON CONFLICT (id) DO UPDATE SET product_id = excluded.product_id, - quantity = excluded.quantity -RETURNING id` - - rows, err := sqlx.NamedQueryContext( - ctx, - r.getter.DefaultTrOrDB(ctx, r.db), - r.db.Rebind(query), - r.toRow(o), - ) - if err != nil { - return err - } - - defer rows.Close() - if !rows.Next() { - return rows.Err() - } - - err = rows.Scan(&o.ID) - - return err -} - -func (r orderRepo) toModel(row orderRow) *domain.Order { - return &domain.Order{ - ID: row.ID, - ProductID: row.ProductID, - UserID: row.UserID, - Quantity: row.Quantity, - } -} - -func (r orderRepo) toRow(u *domain.Order) orderRow { - return orderRow{ - ID: u.ID, - ProductID: u.ProductID, - UserID: u.UserID, - Quantity: u.Quantity, - } -} diff --git a/internal/example/habr/finished/repo/tr/deps.go b/internal/example/habr/finished/repo/tr/deps.go deleted file mode 100644 index 7be3961..0000000 --- a/internal/example/habr/finished/repo/tr/deps.go +++ /dev/null @@ -1,15 +0,0 @@ -package tr - -import ( - "context" - - "github.com/jmoiron/sqlx" -) - -type Tr interface { - Get(dest interface{}, query string, args ...interface{}) error - GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error - - sqlx.Ext - sqlx.ExtContext -} diff --git a/internal/example/habr/finished/repo/user.go b/internal/example/habr/finished/repo/user.go deleted file mode 100644 index a02ef96..0000000 --- a/internal/example/habr/finished/repo/user.go +++ /dev/null @@ -1,117 +0,0 @@ -package repo - -import ( - "context" - "database/sql/driver" - "encoding/json" - "errors" - "fmt" - - trmsqlx "github.com/avito-tech/go-transaction-manager/sqlx" - "github.com/jmoiron/sqlx" - - "finish/domain" -) - -type userRow struct { - ID domain.UserID `db:"id"` - Username string `db:"username"` - Password string `db:"password"` - Notification notification `db:"notification"` -} - -type notification struct { - Email bool `json:"email"` - SMS bool `json:"sms"` -} - -func (n notification) Scan(src any) error { - switch v := src.(type) { - case []byte: - return json.Unmarshal(v, &n) - case string: - return json.Unmarshal([]byte(v), &n) - default: - return errors.New(fmt.Sprintf("Unsupported type: %T", v)) - } -} - -func (n notification) Value() (driver.Value, error) { - return json.Marshal(n) -} - -type userRepo struct { - db *sqlx.DB - getter *trmsqlx.CtxGetter -} - -func NewUserRepo(db *sqlx.DB, getter *trmsqlx.CtxGetter) *userRepo { - return &userRepo{ - db: db, - getter: getter, - } -} -func (r *userRepo) GetByID(ctx context.Context, id domain.UserID) (*domain.User, error) { - query := `SELECT * FROM "user" WHERE id = ?;` - row := userRow{} - - err := r.getter.DefaultTrOrDB(ctx, r.db).GetContext(ctx, &row, r.db.Rebind(query), id) - if err != nil { - return nil, err - } - - return r.toModel(row), nil -} - -func (r *userRepo) Save(ctx context.Context, u *domain.User) error { - query := `INSERT INTO "user" (username, password, notification) -VALUES (:username, :password, :notification) -ON CONFLICT (id) - DO UPDATE SET username = excluded.username, - password = excluded.password, - notification = excluded.notification -RETURNING id;` - - rows, err := sqlx.NamedQueryContext( - ctx, - r.getter.DefaultTrOrDB(ctx, r.db), - r.db.Rebind(query), - r.toRow(u), - ) - if err != nil { - return err - } - - defer rows.Close() - if !rows.Next() { - return rows.Err() - } - - err = rows.Scan(&u.ID) - - return err -} - -func (r userRepo) toModel(row userRow) *domain.User { - return &domain.User{ - ID: row.ID, - Username: row.Username, - Password: row.Password, - Notification: domain.Notification{ - Email: row.Notification.Email, - SMS: row.Notification.SMS, - }, - } -} - -func (r userRepo) toRow(u *domain.User) userRow { - return userRow{ - ID: u.ID, - Username: u.Username, - Password: u.Password, - Notification: notification{ - Email: u.Notification.Email, - SMS: u.Notification.SMS, - }, - } -} diff --git a/internal/example/habr/finished/usecase/decorator/struct.go b/internal/example/habr/finished/usecase/decorator/struct.go deleted file mode 100644 index 2c41911..0000000 --- a/internal/example/habr/finished/usecase/decorator/struct.go +++ /dev/null @@ -1,52 +0,0 @@ -// detailed description https://threedots.tech/post/increasing-cohesion-in-go-with-generic-decorators/ -package decorator - -import ( - "context" - "fmt" - - "github.com/avito-tech/go-transaction-manager/trm" -) - -type Usecase[In any, Out any] interface { - Handle(ctx context.Context, in In) (Out, error) -} - -type txDecorator[In any, Out any] struct { - manager trm.Manager - usecase Usecase[In, Out] -} - -func TxDecorate[In any, Out any](m trm.Manager, u Usecase[In, Out]) Usecase[In, Out] { - return &txDecorator[In, Out]{manager: m, usecase: u} -} - -func (d *txDecorator[In, Out]) Handle(ctx context.Context, in In) (out Out, err error) { - var emptyOut Out - - err = d.manager.Do(ctx, func(ctx context.Context) error { - out, err = d.usecase.Handle(ctx, in) - - return err - }) - if err != nil { - return emptyOut, err - } - - return out, nil -} - -type fmtDecorator[In any, Out any] struct { - usecase Usecase[In, Out] -} - -func FMTDecorator[In any, Out any](u Usecase[In, Out]) Usecase[In, Out] { - return &fmtDecorator[In, Out]{usecase: u} -} - -func (d *fmtDecorator[In, Out]) Handle(ctx context.Context, in In) (out Out, err error) { - fmt.Println("start") - defer fmt.Println("finish") - - return d.usecase.Handle(ctx, in) -} diff --git a/internal/example/habr/finished/usecase/decorator/struct_test.go b/internal/example/habr/finished/usecase/decorator/struct_test.go deleted file mode 100644 index 637beb8..0000000 --- a/internal/example/habr/finished/usecase/decorator/struct_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package decorator - -import ( - "context" - "fmt" -) - -type usecase struct{} - -func (u usecase) Handle(ctx context.Context, in string) (string, error) { - fmt.Println("inside", in) - - return "result", nil -} - -func ExampleFMTDecorator() { - uc := FMTDecorator[string, string](usecase{}) - - fmt.Println(uc.Handle(context.Background(), "in")) - - // Output: start - //inside in - //finish - //result -} diff --git a/internal/example/habr/finished/usecase/fast_purchase/usecase.go b/internal/example/habr/finished/usecase/fast_purchase/usecase.go deleted file mode 100644 index 543a132..0000000 --- a/internal/example/habr/finished/usecase/fast_purchase/usecase.go +++ /dev/null @@ -1,66 +0,0 @@ -package fast_purchase - -import ( - "context" - - "github.com/avito-tech/go-transaction-manager/trm" - - "finish/domain" - "finish/usecase/purchase" - "finish/usecase/register" -) - -type In struct { - Register RegisterIn - Purchase PurchaseIn -} - -type RegisterIn struct { - Username string - Password string -} - -type PurchaseIn struct { - ProductID domain.ProductID - Quantity int64 -} - -type Out struct { - User *domain.User - Order *domain.Order -} - -type FastPurchase struct { - trm trm.Manager - register *register.Register - purchase *purchase.Purchase -} - -func New(trm trm.Manager, register *register.Register, purchase *purchase.Purchase) *FastPurchase { - return &FastPurchase{trm: trm, register: register, purchase: purchase} -} - -func (u *FastPurchase) Handle(ctx context.Context, in In) (out Out, err error) { - err = u.trm.Do(ctx, func(ctx context.Context) error { - out.User, err = u.register.Handle(ctx, register.In{ - Username: in.Register.Username, - Password: in.Register.Password, - }) - if err != nil { - return err - } - - out.Order, err = u.purchase.Handle(ctx, purchase.In{ - UserID: out.User.ID, - ProductID: in.Purchase.ProductID, - Quantity: in.Purchase.Quantity, - }) - - return err - }) - if err != nil { - return Out{}, err - } - - return out, nil -} diff --git a/internal/example/habr/finished/usecase/purchase/usecase.go b/internal/example/habr/finished/usecase/purchase/usecase.go deleted file mode 100644 index a6c577e..0000000 --- a/internal/example/habr/finished/usecase/purchase/usecase.go +++ /dev/null @@ -1,46 +0,0 @@ -package purchase - -import ( - "context" - - "github.com/avito-tech/go-transaction-manager/trm" - - "finish/domain" - "finish/queue" -) - -type In struct { - UserID domain.UserID - ProductID domain.ProductID - Quantity int64 -} - -type Purchase struct { - orderRepo domain.OrderRepo - trm trm.Manager - queue queue.Queue[domain.Purchased] -} - -func New(orderRepo domain.OrderRepo, trm trm.Manager, queue queue.Queue[domain.Purchased]) *Purchase { - return &Purchase{orderRepo: orderRepo, trm: trm, queue: queue} -} - -func (u *Purchase) Handle(ctx context.Context, in In) (order *domain.Order, err error) { - order, err = domain.NewOrder(in.UserID, in.ProductID, in.Quantity) - if err != nil { - return nil, err - } - - err = u.trm.Do(ctx, func(ctx context.Context) error { - if err = u.orderRepo.Save(ctx, order); err != nil { - return err - } - - return u.queue.Publish(ctx, domain.Purchased{ID: order.ID}) - }) - if err != nil { - return nil, err - } - - return order, nil -} diff --git a/internal/example/habr/finished/usecase/register/usecase.go b/internal/example/habr/finished/usecase/register/usecase.go deleted file mode 100644 index ecd55f7..0000000 --- a/internal/example/habr/finished/usecase/register/usecase.go +++ /dev/null @@ -1,45 +0,0 @@ -package register - -import ( - "context" - - "github.com/avito-tech/go-transaction-manager/trm" - - "finish/domain" - "finish/queue" -) - -type In struct { - Username string - Password string -} - -type Register struct { - userRepo domain.UserRepo - trm trm.Manager - queue queue.Queue[domain.Registered] -} - -func New(userRepo domain.UserRepo, trm trm.Manager, queue queue.Queue[domain.Registered]) *Register { - return &Register{userRepo: userRepo, trm: trm, queue: queue} -} - -func (u *Register) Handle(ctx context.Context, in In) (user *domain.User, err error) { - user, err = domain.NewUser(in.Username, in.Password) - if err != nil { - return nil, err - } - - err = u.trm.Do(ctx, func(ctx context.Context) error { - if err = u.userRepo.Save(ctx, user); err != nil { - return err - } - - return u.queue.Publish(ctx, domain.Registered{ID: user.ID}) - }) - if err != nil { - return nil, err - } - - return user, nil -} diff --git a/internal/example/habr/init/.gitignore b/internal/example/habr/init/.gitignore deleted file mode 100644 index 05ba2b1..0000000 --- a/internal/example/habr/init/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/vendor - -/test.db \ No newline at end of file diff --git a/internal/example/habr/init/domain/deps.go b/internal/example/habr/init/domain/deps.go deleted file mode 100644 index cafc669..0000000 --- a/internal/example/habr/init/domain/deps.go +++ /dev/null @@ -1,15 +0,0 @@ -package domain - -import ( - "context" - - "github.com/jmoiron/sqlx" -) - -type Tr interface { - Get(dest interface{}, query string, args ...interface{}) error - GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error - - sqlx.Ext - sqlx.ExtContext -} diff --git a/internal/example/habr/init/domain/order.go b/internal/example/habr/init/domain/order.go deleted file mode 100644 index 6ddcae3..0000000 --- a/internal/example/habr/init/domain/order.go +++ /dev/null @@ -1,43 +0,0 @@ -package domain - -import "errors" - -var ( - ErrInvalidUserID = errors.New("invalid user id") - ErrInvalidProductID = errors.New("invalid product id") - ErrInvalidQuantity = errors.New("quantity should be more 1") -) - -type OrderID int64 -type ProductID int64 - -type Order struct { - ID OrderID - ProductID ProductID - UserID UserID - Quantity int64 -} - -func NewOrder(userID UserID, productID ProductID, quantity int64) (*Order, error) { - if userID <= 0 { - return nil, ErrInvalidUserID - } - - if productID <= 0 { - return nil, ErrInvalidProductID - } - - if quantity <= 0 { - return nil, ErrInvalidQuantity - } - - return &Order{ - UserID: userID, - ProductID: productID, - Quantity: quantity, - }, nil -} - -type Purchased struct { - ID OrderID -} diff --git a/internal/example/habr/init/domain/repository.go b/internal/example/habr/init/domain/repository.go deleted file mode 100644 index a848fc2..0000000 --- a/internal/example/habr/init/domain/repository.go +++ /dev/null @@ -1,12 +0,0 @@ -package domain - -type UserRepo interface { - GetByID(Tr, UserID) (*User, error) - Save(Tr, *User) error -} - -type OrderRepo interface { - GetByID(Tr, OrderID) (*Order, error) - GetByUserID(Tr, UserID) (*Order, error) - Save(Tr, *Order) error -} diff --git a/internal/example/habr/init/domain/user.go b/internal/example/habr/init/domain/user.go deleted file mode 100644 index dd2615e..0000000 --- a/internal/example/habr/init/domain/user.go +++ /dev/null @@ -1,41 +0,0 @@ -package domain - -import "errors" - -var ( - ErrEmptyUsername = errors.New("empty username") -) - -type UserID int64 - -type User struct { - ID UserID - Username string - // В реальном проекте Пароли храните в захэшированном виде! - Password string - Notification Notification -} - -func NewUser(username string, password string) (*User, error) { - if username == "" { - return nil, ErrEmptyUsername - } - - return &User{ - Username: username, - Password: password, - Notification: Notification{ - Email: false, - SMS: true, - }, - }, nil -} - -type Notification struct { - Email bool - SMS bool -} - -type Registered struct { - ID UserID -} diff --git a/internal/example/habr/init/go.mod b/internal/example/habr/init/go.mod deleted file mode 100644 index 8b75753..0000000 --- a/internal/example/habr/init/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module init - -go 1.18 - -require ( - github.com/jmoiron/sqlx v1.3.5 - github.com/mattn/go-sqlite3 v1.14.16 -) diff --git a/internal/example/habr/init/go.sum b/internal/example/habr/init/go.sum deleted file mode 100644 index d167db2..0000000 --- a/internal/example/habr/init/go.sum +++ /dev/null @@ -1,9 +0,0 @@ -github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= -github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= -github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= -github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= diff --git a/internal/example/habr/init/main_test.go b/internal/example/habr/init/main_test.go deleted file mode 100644 index c1f3065..0000000 --- a/internal/example/habr/init/main_test.go +++ /dev/null @@ -1,98 +0,0 @@ -package main - -import ( - "encoding/json" - "fmt" - "log" - - "github.com/jmoiron/sqlx" - _ "github.com/mattn/go-sqlite3" - - "init/domain" - "init/queue" - "init/repo" - "init/usecase/fast_purchase" - purchaseUC "init/usecase/purchase" - registerUC "init/usecase/register" -) - -// language=SQLite -const sqlStmt = ` -DROP TABLE IF EXISTS "user"; -CREATE TABLE IF NOT EXISTS "user" -( - id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - username TEXT NOT NULL, - password TEXT NOT NULL, - notification TEXT -); -INSERT INTO "user" (username, password, notification) VALUES ('user1', 'password1', 'email1'); - -DROP TABLE IF EXISTS "order"; -CREATE TABLE IF NOT EXISTS "order" -( - id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, - user_id INTEGER NOT NULL, - product_id INTEGER NOT NULL, - quantity INTEGER NOT NULL -); -` - -func Example() { - db, err := sqlx.Open("sqlite3", "file:test.db") - if err != nil { - log.Fatal(err) - } - - _, err = db.Exec(sqlStmt) - if err != nil { - log.Fatal(err) - } - - // Repo - userRepo := repo.NewUserRepo(db) - orderRepo := repo.NewOrdrRepo(db) - - queueRegistered := queue.Queue[domain.Registered]{} - queuePurchased := queue.Queue[domain.Purchased]{} - - // usecase - register := registerUC.New(userRepo, db, queueRegistered) - purchase := purchaseUC.New(orderRepo, db, queuePurchased) - fastPurchase := fast_purchase.New(db, register, purchase) - - out, err := fastPurchase.Handle(fast_purchase.In{ - Register: fast_purchase.RegisterIn{ - Username: "username", - Password: "password", - }, - Purchase: fast_purchase.PurchaseIn{ - ProductID: 1, - Quantity: 10, - }, - }) - if err != nil { - log.Fatal(err) - } - - res, _ := json.MarshalIndent(out, "", "\t") - fmt.Println(string(res)) - - // Output: { - // "User": { - // "ID": 2, - // "Username": "username", - // "Password": "", - // "Notification": { - // "Email": false, - // "SMS": true - // } - // }, - // "Order": { - // "ID": 1, - // "ProductID": 1, - // "UserID": 2, - // "Quantity": 10 - // } - //} -} diff --git a/internal/example/habr/init/queue/queue.go b/internal/example/habr/init/queue/queue.go deleted file mode 100644 index b84a22f..0000000 --- a/internal/example/habr/init/queue/queue.go +++ /dev/null @@ -1,9 +0,0 @@ -package queue - -import "init/domain" - -type Queue[In any] struct{} - -func (Queue[In]) Publish(_ domain.Tr, in In) error { - return nil -} diff --git a/internal/example/habr/init/repo/order.go b/internal/example/habr/init/repo/order.go deleted file mode 100644 index f3e3d1b..0000000 --- a/internal/example/habr/init/repo/order.go +++ /dev/null @@ -1,96 +0,0 @@ -package repo - -import ( - "github.com/jmoiron/sqlx" - - "init/domain" -) - -type orderRow struct { - ID domain.OrderID `db:"id"` - ProductID domain.ProductID `db:"product_id"` - UserID domain.UserID `db:"user_id"` - Quantity int64 `db:"quantity"` -} - -type ordrRepo struct { - db *sqlx.DB -} - -func NewOrdrRepo(db *sqlx.DB) *ordrRepo { - return &ordrRepo{db: db} -} - -func (r *ordrRepo) GetByID(tr domain.Tr, id domain.OrderID) (*domain.Order, error) { - query := `SELECT * FROM "order" WHERE id = ?;` - row := orderRow{} - - if tr != nil { - tr = r.db - } - - if err := tr.Get(&row, r.db.Rebind(query), id); err != nil { - return nil, err - } - - return r.toModel(row), nil -} - -func (r *ordrRepo) GetByUserID(tr domain.Tr, id domain.UserID) (*domain.Order, error) { - query := `SELECT * FROM "order" WHERE user_id = ?;` - row := orderRow{} - - if tr != nil { - tr = r.db - } - - if err := tr.Get(&row, r.db.Rebind(query), id); err != nil { - return nil, err - } - - return r.toModel(row), nil -} - -func (r *ordrRepo) Save(tr domain.Tr, o *domain.Order) error { - query := `INSERT INTO "order" (product_id, user_id, quantity) -VALUES (:product_id, :user_id, :quantity) -ON CONFLICT (id) DO UPDATE SET product_id = excluded.product_id, - quantity = excluded.quantity -RETURNING id` - - if tr != nil { - tr = r.db - } - - rows, err := sqlx.NamedQuery(tr, query, r.toRow(o)) - if err != nil { - return err - } - - defer rows.Close() - if !rows.Next() { - return rows.Err() - } - - err = rows.Scan(&o.ID) - - return err -} - -func (r ordrRepo) toModel(row orderRow) *domain.Order { - return &domain.Order{ - ID: row.ID, - ProductID: row.ProductID, - UserID: row.UserID, - Quantity: row.Quantity, - } -} - -func (r ordrRepo) toRow(u *domain.Order) orderRow { - return orderRow{ - ID: u.ID, - ProductID: u.ProductID, - UserID: u.UserID, - Quantity: u.Quantity, - } -} diff --git a/internal/example/habr/init/repo/user.go b/internal/example/habr/init/repo/user.go deleted file mode 100644 index 47a19c7..0000000 --- a/internal/example/habr/init/repo/user.go +++ /dev/null @@ -1,114 +0,0 @@ -package repo - -import ( - "database/sql/driver" - "encoding/json" - "errors" - "fmt" - - "github.com/jmoiron/sqlx" - - "init/domain" -) - -type userRow struct { - ID domain.UserID `db:"id"` - Username string `db:"username"` - Password string `db:"password"` - Notification notification `db:"notification"` -} - -type notification struct { - Email bool `json:"email"` - SMS bool `json:"sms"` -} - -func (n notification) Scan(src any) error { - switch v := src.(type) { - case []byte: - return json.Unmarshal(v, &n) - case string: - return json.Unmarshal([]byte(v), &n) - default: - return errors.New(fmt.Sprintf("Unsupported type: %T", v)) - } -} - -func (n notification) Value() (driver.Value, error) { - return json.Marshal(n) -} - -type userRepo struct { - db *sqlx.DB -} - -func NewUserRepo(db *sqlx.DB) *userRepo { - return &userRepo{db: db} -} - -func (r *userRepo) GetByID(tr domain.Tr, id domain.UserID) (*domain.User, error) { - query := `SELECT * FROM "user" WHERE id = ?;` - uRow := userRow{} - - if tr != nil { - tr = r.db - } - - if err := tr.Get(&uRow, r.db.Rebind(query), id); err != nil { - return nil, err - } - - return r.toModel(uRow), nil -} - -func (r *userRepo) Save(tr domain.Tr, u *domain.User) error { - query := `INSERT INTO "user" (username, password, notification) -VALUES (:username, :password, :notification) -ON CONFLICT (id) - DO UPDATE SET username = excluded.username, - password = excluded.password, - notification = excluded.notification -RETURNING id;` - - if tr != nil { - tr = r.db - } - - rows, err := sqlx.NamedQuery(tr, query, r.toRow(u)) - if err != nil { - return err - } - - defer rows.Close() - if !rows.Next() { - return rows.Err() - } - - err = rows.Scan(&u.ID) - - return err -} - -func (r userRepo) toModel(row userRow) *domain.User { - return &domain.User{ - ID: row.ID, - Username: row.Username, - Password: row.Password, - Notification: domain.Notification{ - Email: row.Notification.Email, - SMS: row.Notification.SMS, - }, - } -} - -func (r userRepo) toRow(u *domain.User) userRow { - return userRow{ - ID: u.ID, - Username: u.Username, - Password: u.Password, - Notification: notification{ - Email: u.Notification.Email, - SMS: u.Notification.SMS, - }, - } -} diff --git a/internal/example/habr/init/repo/with_transaction.go b/internal/example/habr/init/repo/with_transaction.go deleted file mode 100644 index 7d3a90b..0000000 --- a/internal/example/habr/init/repo/with_transaction.go +++ /dev/null @@ -1,39 +0,0 @@ -package repo - -import ( - "github.com/jmoiron/sqlx" -) - -var DB *sqlx.DB - -func SetDB(db *sqlx.DB) { - DB = db -} - -func WithTransaction(tx *sqlx.Tx, fn func(*sqlx.Tx) error) (err error) { - hasExternalTx := true - if tx == nil { - tx, err = DB.Beginx() - if err != nil { - return err - } - hasExternalTx = false - } - - defer func() { - if !hasExternalTx && err != nil { - tx.Rollback() - } - }() - - err = fn(tx) // call a usecase - if err != nil { - return err - } - - if !hasExternalTx { - err = tx.Commit() // or tr.Rollback() - } - - return nil -} diff --git a/internal/example/habr/init/repo/withoutTx/user.go b/internal/example/habr/init/repo/withoutTx/user.go deleted file mode 100644 index c70b80e..0000000 --- a/internal/example/habr/init/repo/withoutTx/user.go +++ /dev/null @@ -1,106 +0,0 @@ -package withoutTx - -import ( - "database/sql/driver" - "encoding/json" - "errors" - "fmt" - - "github.com/jmoiron/sqlx" - - "init/domain" -) - -type userRow struct { - ID domain.UserID `db:"id"` - Username string `db:"username"` - Password string `db:"password"` - Notification notification `db:"notification"` -} - -type notification struct { - Email bool `json:"email"` - SMS bool `json:"sms"` -} - -func (n notification) Scan(src any) error { - switch v := src.(type) { - case []byte: - return json.Unmarshal(v, &n) - case string: - return json.Unmarshal([]byte(v), &n) - default: - return errors.New(fmt.Sprintf("Unsupported type: %T", v)) - } -} - -func (n notification) Value() (driver.Value, error) { - return json.Marshal(n) -} - -type userRepo struct { - db *sqlx.DB -} - -func NewUserRepo(db *sqlx.DB) *userRepo { - return &userRepo{db: db} -} - -func (r *userRepo) GetByID(id domain.UserID) (*domain.User, error) { - query := `SELECT * FROM "user" WHERE id = ?;` - uRow := userRow{} - - if err := r.db.Get(&uRow, r.db.Rebind(query), id); err != nil { - return nil, err - } - - return r.toModel(uRow), nil -} - -func (r *userRepo) Save(u *domain.User) error { - query := `INSERT INTO "user" (username, password, notification) -VALUES (:username, :password, :notification) -ON CONFLICT (id) - DO UPDATE SET excluded.username = :username, - excluded.password = :password, - excluded.notification = :notification -RETURNING id;` - - rows, err := r.db.Query(query, r.toRow(u)) - if err != nil { - return err - } - - defer rows.Close() - if !rows.Next() { - return rows.Err() - } - - err = rows.Scan(&u.ID) - - return err -} - -func (r userRepo) toModel(row userRow) *domain.User { - return &domain.User{ - ID: row.ID, - Username: row.Username, - Password: row.Password, - Notification: domain.Notification{ - Email: row.Notification.Email, - SMS: row.Notification.SMS, - }, - } -} - -func (r userRepo) toRow(u *domain.User) userRow { - return userRow{ - ID: u.ID, - Username: u.Username, - Password: u.Password, - Notification: notification{ - Email: u.Notification.Email, - SMS: u.Notification.SMS, - }, - } -} diff --git a/internal/example/habr/init/usecase/fast_purchase/usecase.go b/internal/example/habr/init/usecase/fast_purchase/usecase.go deleted file mode 100644 index e25cf37..0000000 --- a/internal/example/habr/init/usecase/fast_purchase/usecase.go +++ /dev/null @@ -1,72 +0,0 @@ -package fast_purchase - -import ( - "github.com/jmoiron/sqlx" - - "init/domain" - "init/usecase/purchase" - "init/usecase/register" -) - -type In struct { - Register RegisterIn - Purchase PurchaseIn -} - -type RegisterIn struct { - Username string - Password string -} - -type PurchaseIn struct { - ProductID domain.ProductID - Quantity int64 -} - -type Out struct { - User *domain.User - Order *domain.Order -} - -type FastPurchase struct { - db *sqlx.DB - register *register.Register - purchase *purchase.Purchase -} - -func New(db *sqlx.DB, register *register.Register, purchase *purchase.Purchase) *FastPurchase { - return &FastPurchase{db: db, register: register, purchase: purchase} -} - -func (u *FastPurchase) Handle(in In) (out Out, err error) { - tx, err := u.db.Beginx() - if err != nil { - return Out{}, err - } - - defer func() { - if err != nil { - tx.Rollback() - } - }() - - if out.User, err = u.register.Handle(tx, register.In{ - Username: in.Register.Username, - }); err != nil { - return Out{}, err - } - - if out.Order, err = u.purchase.Handle(tx, purchase.In{ - UserID: out.User.ID, - ProductID: in.Purchase.ProductID, - Quantity: in.Purchase.Quantity, - }); err != nil { - return Out{}, err - } - - if err = tx.Commit(); err != nil { - return Out{}, err - } - - return out, nil -} diff --git a/internal/example/habr/init/usecase/purchase/usecase.go b/internal/example/habr/init/usecase/purchase/usecase.go deleted file mode 100644 index 29a056f..0000000 --- a/internal/example/habr/init/usecase/purchase/usecase.go +++ /dev/null @@ -1,60 +0,0 @@ -package purchase - -import ( - "github.com/jmoiron/sqlx" - - "init/domain" - "init/queue" -) - -type In struct { - UserID domain.UserID - ProductID domain.ProductID - Quantity int64 -} - -type Purchase struct { - orderRepo domain.OrderRepo - db *sqlx.DB - queue queue.Queue[domain.Purchased] -} - -func New(orderRepo domain.OrderRepo, db *sqlx.DB, queue queue.Queue[domain.Purchased]) *Purchase { - return &Purchase{orderRepo: orderRepo, db: db, queue: queue} -} - -func (u *Purchase) Handle(tx *sqlx.Tx, in In) (order *domain.Order, err error) { - hasExternalTx := true - tr := domain.Tr(tx) - if tx == nil { - if tr, err = u.db.Beginx(); err != nil { - return nil, err - } - hasExternalTx = false - } - - defer func() { - if !hasExternalTx && err != nil { - tx.Rollback() - } - }() - - order, err = domain.NewOrder(in.UserID, in.ProductID, in.Quantity) - if err != nil { - return nil, err - } - - if err = u.orderRepo.Save(tr, order); err != nil { - return nil, err - } - - if err = u.queue.Publish(tr, domain.Purchased{ID: order.ID}); err != nil { - return nil, err - } - - if !hasExternalTx { - return nil, tx.Commit() - } - - return order, nil -} diff --git a/internal/example/habr/init/usecase/register/usecase.go b/internal/example/habr/init/usecase/register/usecase.go deleted file mode 100644 index 70e8e57..0000000 --- a/internal/example/habr/init/usecase/register/usecase.go +++ /dev/null @@ -1,59 +0,0 @@ -package register - -import ( - "github.com/jmoiron/sqlx" - - "init/domain" - "init/queue" -) - -type In struct { - Username string - Password string -} - -type Register struct { - userRepo domain.UserRepo - db *sqlx.DB - queue queue.Queue[domain.Registered] -} - -func New(userRepo domain.UserRepo, db *sqlx.DB, queue queue.Queue[domain.Registered]) *Register { - return &Register{userRepo: userRepo, db: db, queue: queue} -} - -func (u *Register) Handle(tx *sqlx.Tx, in In) (user *domain.User, err error) { - hasExternalTx := true - tr := domain.Tr(tx) - if tx == nil { - if tr, err = u.db.Beginx(); err != nil { - return nil, err - } - hasExternalTx = false - } - - defer func() { - if !hasExternalTx && err != nil { - tx.Rollback() - } - }() - - user, err = domain.NewUser(in.Username, in.Password) - if err != nil { - return nil, err - } - - if err = u.userRepo.Save(tr, user); err != nil { - return nil, err - } - - if err = u.queue.Publish(tr, domain.Registered{ID: user.ID}); err != nil { - return nil, err - } - - if !hasExternalTx { - return nil, tx.Commit() - } - - return user, nil -} diff --git a/internal/example/habr/init/usecase/register_withTransaction/usecase.go b/internal/example/habr/init/usecase/register_withTransaction/usecase.go deleted file mode 100644 index 4b12f40..0000000 --- a/internal/example/habr/init/usecase/register_withTransaction/usecase.go +++ /dev/null @@ -1,44 +0,0 @@ -package register - -import ( - "github.com/jmoiron/sqlx" - - "init/domain" - "init/queue" - "init/repo" -) - -type In struct { - Username string - Password string -} - -type Register struct { - userRepo domain.UserRepo - db *sqlx.DB - queue queue.Queue[domain.Registered] -} - -func New(userRepo domain.UserRepo, db *sqlx.DB, queue queue.Queue[domain.Registered]) *Register { - return &Register{userRepo: userRepo, db: db, queue: queue} -} - -func (u *Register) Handle(tx *sqlx.Tx, in In) (user *domain.User, err error) { - user, err = domain.NewUser(in.Username, in.Password) - if err != nil { - return nil, err - } - - err = repo.WithTransaction(tx, func(tx *sqlx.Tx) error { - if err = u.userRepo.Save(tx, user); err != nil { - return err - } - - return u.queue.Publish(tx, domain.Registered{ID: user.ID}) - }) - if err != nil { - return nil, err - } - - return user, nil -} diff --git a/trm/manager.go b/manager.go similarity index 97% rename from trm/manager.go rename to manager.go index 186917e..4bddb37 100644 --- a/trm/manager.go +++ b/manager.go @@ -1,4 +1,4 @@ -package trm +package go_transaction_manager //go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock diff --git a/trm/manager/chain.go b/manager/chain.go similarity index 98% rename from trm/manager/chain.go rename to manager/chain.go index 6f3d401..1e80651 100644 --- a/trm/manager/chain.go +++ b/manager/chain.go @@ -3,7 +3,7 @@ package manager import ( "context" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // ChainedMW starts transactions in the order given and commit/rollback in reverse order. diff --git a/trm/manager/chain_test.go b/manager/chain_test.go similarity index 96% rename from trm/manager/chain_test.go rename to manager/chain_test.go index eca8a6e..bfa628a 100644 --- a/trm/manager/chain_test.go +++ b/manager/chain_test.go @@ -8,9 +8,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/avito-tech/go-transaction-manager/trm" - "github.com/avito-tech/go-transaction-manager/trm/mock" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/avito-tech/go-transaction-manager/v2/mock" + "github.com/avito-tech/go-transaction-manager/v2/settings" ) func TestChainedMW_Do(t *testing.T) { diff --git a/trm/manager/closer.go b/manager/closer.go similarity index 97% rename from trm/manager/closer.go rename to manager/closer.go index 6a99cfd..78192c5 100644 --- a/trm/manager/closer.go +++ b/manager/closer.go @@ -7,7 +7,7 @@ import ( "go.uber.org/multierr" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // Closer closes trm.Transaction. diff --git a/trm/manager/log.go b/manager/log.go similarity index 100% rename from trm/manager/log.go rename to manager/log.go diff --git a/trm/manager/log_test.go b/manager/log_test.go similarity index 100% rename from trm/manager/log_test.go rename to manager/log_test.go diff --git a/trm/manager/manager.go b/manager/manager.go similarity index 95% rename from trm/manager/manager.go rename to manager/manager.go index 8466b5d..a18b0f8 100644 --- a/trm/manager/manager.go +++ b/manager/manager.go @@ -6,9 +6,10 @@ import ( "go.uber.org/multierr" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" + + "github.com/avito-tech/go-transaction-manager/v2/settings" ) // Opt is a type to configure Manager. diff --git a/trm/manager/manager_test.go b/manager/manager_test.go similarity index 98% rename from trm/manager/manager_test.go rename to manager/manager_test.go index 53712fa..1c5da6b 100644 --- a/trm/manager/manager_test.go +++ b/manager/manager_test.go @@ -11,12 +11,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - trmmock "github.com/avito-tech/go-transaction-manager/internal/mock" - "github.com/avito-tech/go-transaction-manager/trm" - trmcontext "github.com/avito-tech/go-transaction-manager/trm/context" - mock_log "github.com/avito-tech/go-transaction-manager/trm/manager/mock" - "github.com/avito-tech/go-transaction-manager/trm/mock" - "github.com/avito-tech/go-transaction-manager/trm/settings" + trm "github.com/avito-tech/go-transaction-manager/v2" + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" + trmmock "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + mock_log "github.com/avito-tech/go-transaction-manager/v2/manager/mock" + "github.com/avito-tech/go-transaction-manager/v2/mock" + "github.com/avito-tech/go-transaction-manager/v2/settings" ) func Test_transactionManager_Do(t *testing.T) { diff --git a/trm/manager/mock/log.go b/manager/mock/log.go similarity index 100% rename from trm/manager/mock/log.go rename to manager/mock/log.go diff --git a/trm/manager/option.go b/manager/option.go similarity index 88% rename from trm/manager/option.go rename to manager/option.go index 20dd0e3..9e316d1 100644 --- a/trm/manager/option.go +++ b/manager/option.go @@ -1,6 +1,6 @@ package manager -import "github.com/avito-tech/go-transaction-manager/trm" +import trm "github.com/avito-tech/go-transaction-manager/v2" // WithLog sets logger for Manager. func WithLog(l logger) Opt { diff --git a/trm/manager/struct_test.go b/manager/struct_test.go similarity index 95% rename from trm/manager/struct_test.go rename to manager/struct_test.go index a94171e..19a874a 100644 --- a/trm/manager/struct_test.go +++ b/manager/struct_test.go @@ -4,7 +4,7 @@ package manager import ( "time" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) type s struct{} diff --git a/trm/manager_test.go b/manager_test.go similarity index 98% rename from trm/manager_test.go rename to manager_test.go index f383f3c..0ee175f 100644 --- a/trm/manager_test.go +++ b/manager_test.go @@ -1,4 +1,4 @@ -package trm +package go_transaction_manager import ( "errors" diff --git a/trm/mock/manager.go b/mock/manager.go similarity index 97% rename from trm/mock/manager.go rename to mock/manager.go index b6d3db2..0df08ec 100644 --- a/trm/mock/manager.go +++ b/mock/manager.go @@ -8,7 +8,7 @@ import ( context "context" reflect "reflect" - trm "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" gomock "github.com/golang/mock/gomock" ) diff --git a/trm/mock/settings.go b/mock/settings.go similarity index 99% rename from trm/mock/settings.go rename to mock/settings.go index f7cbb71..0e20834 100644 --- a/trm/mock/settings.go +++ b/mock/settings.go @@ -8,7 +8,7 @@ import ( reflect "reflect" time "time" - trm "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" gomock "github.com/golang/mock/gomock" ) diff --git a/trm/mock/transaction.go b/mock/transaction.go similarity index 99% rename from trm/mock/transaction.go rename to mock/transaction.go index f02025b..ebb19ca 100644 --- a/trm/mock/transaction.go +++ b/mock/transaction.go @@ -8,7 +8,7 @@ import ( context "context" reflect "reflect" - trm "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" gomock "github.com/golang/mock/gomock" ) diff --git a/trm/settings.go b/settings.go similarity index 96% rename from trm/settings.go rename to settings.go index ca92fa8..42eea60 100644 --- a/trm/settings.go +++ b/settings.go @@ -1,4 +1,4 @@ -package trm +package go_transaction_manager //go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock diff --git a/trm/settings/option.go b/settings/option.go similarity index 93% rename from trm/settings/option.go rename to settings/option.go index 99ee51b..d6a3cfd 100644 --- a/trm/settings/option.go +++ b/settings/option.go @@ -3,7 +3,7 @@ package settings import ( "time" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // WithCtxKey sets up trm.CtxKey for the trm.Settings. diff --git a/trm/settings/settings.go b/settings/settings.go similarity index 98% rename from trm/settings/settings.go rename to settings/settings.go index 284ae78..dc05fe4 100644 --- a/trm/settings/settings.go +++ b/settings/settings.go @@ -4,7 +4,7 @@ package settings import ( "time" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // DefaultCtxKey is a default key to store Transaction. diff --git a/trm/settings/settings_test.go b/settings/settings_test.go similarity index 98% rename from trm/settings/settings_test.go rename to settings/settings_test.go index 6099ec0..0e80b7c 100644 --- a/trm/settings/settings_test.go +++ b/settings/settings_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/avito-tech/go-transaction-manager/trm" + trm "github.com/avito-tech/go-transaction-manager/v2" ) func TestSettings_EnrichBy(t *testing.T) { diff --git a/sh/go.mod.tidy.sh b/sh/go.mod.tidy.sh new file mode 100644 index 0000000..ec13aac --- /dev/null +++ b/sh/go.mod.tidy.sh @@ -0,0 +1,7 @@ +cd ../ && go mod tidy + +for driver in */../drivers/ ; do + if [ -d "$driver" ]; then + cd $driver && go mod tidy + fi +done \ No newline at end of file diff --git a/sh/go.mod.vendor.sh b/sh/go.mod.vendor.sh new file mode 100644 index 0000000..f62b6ee --- /dev/null +++ b/sh/go.mod.vendor.sh @@ -0,0 +1,7 @@ +cd ../ && go mod tidy + +for driver in */../drivers/ ; do + if [ -d "$driver" ]; then + cd $driver && go mod vendor + fi +done \ No newline at end of file diff --git a/trm/transaction.go b/transaction.go similarity index 99% rename from trm/transaction.go rename to transaction.go index 265be90..d1b3ac7 100644 --- a/trm/transaction.go +++ b/transaction.go @@ -1,5 +1,5 @@ // Package trm contains of interfaces to programmatic transaction management. -package trm +package go_transaction_manager //go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock From dceb39326aeec521d56c04ec2939750f5187a465 Mon Sep 17 00:00:00 2001 From: iasergunin Date: Sun, 3 Dec 2023 22:14:14 +0300 Subject: [PATCH 02/13] Fixed go.mod --- README.md | 4 +- drivers/go-redis-v8/example_test.go | 19 +- drivers/go-redis-v8/go.mod | 2 + drivers/go-redis-v8/go.sum | 161 ++++++++++++ .../readonly_func_without_tx_test.go | 2 + drivers/go-redis-v8/transaction_test.go | 3 +- drivers/go-redis-v8/watcher_test.go | 20 +- drivers/gorm/example_test.go | 7 +- drivers/gorm/go.mod | 24 +- drivers/gorm/go.sum | 84 ++++++ drivers/gorm/transaction_test.go | 3 +- drivers/mongo/example_test.go | 8 +- drivers/mongo/go.mod | 10 +- drivers/mongo/go.sum | 112 ++++++++ drivers/mongo/transaction_test.go | 2 +- drivers/pgxv4/example_test.go | 4 +- drivers/pgxv4/go.mod | 8 +- drivers/pgxv4/go.sum | 245 ++++++++++++++++++ drivers/pgxv4/transaction_test.go | 2 +- drivers/pgxv5/example_test.go | 4 +- drivers/pgxv5/go.mod | 7 +- drivers/pgxv5/go.sum | 108 ++++++++ drivers/pgxv5/transaction_test.go | 2 +- drivers/sql/go.mod | 7 +- drivers/sql/go.sum | 71 +++++ drivers/sql/transaction_test.go | 2 +- drivers/sqlx/example_test.go | 11 +- drivers/sqlx/factory.go | 1 + drivers/sqlx/go.mod | 12 +- drivers/sqlx/go.sum | 74 ++++++ drivers/sqlx/transaction.go | 4 +- drivers/sqlx/transaction_test.go | 2 +- go.mod | 4 + go.sum | 75 ++++++ manager/manager_test.go | 5 +- {internal/mock => mock}/log.go | 0 sh/go.mod.tidy.sh | 13 +- sh/go.mod.vendor.sh | 13 +- 38 files changed, 1073 insertions(+), 62 deletions(-) create mode 100644 drivers/go-redis-v8/go.sum create mode 100644 drivers/gorm/go.sum create mode 100644 drivers/mongo/go.sum create mode 100644 drivers/pgxv4/go.sum create mode 100644 drivers/pgxv5/go.sum create mode 100644 drivers/sql/go.sum create mode 100644 drivers/sqlx/go.sum create mode 100644 go.sum rename {internal/mock => mock}/log.go (100%) diff --git a/README.md b/README.md index d60ba2a..76774a8 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ Easiest way to get the perfect repository. ## Supported implementations -* [database/sql](https://pkg.go.dev/database/sql), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/sql/v2) (Go 1.13) +* [database/sql](https://pkg.go.dev/database/sql), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/sql/v2) (Go 1.13) * [jmoiron/sqlx](https://github.com/jmoiron/sqlx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2) (Go 1.13) -* [gorm](https://github.com/go-gorm/gorm), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/gorm/v2) (Go 1.18) +* [gorm](https://github.com/go-gorm/gorm), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/gorm/v2) (Go 1.18) * [mongo-go-driver](https://github.com/mongodb/mongo-go-driver), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/mongo/v2) (Go 1.13) * [go-redis/redis](https://github.com/go-redis/redis), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2) (Go 1.17) * [pgx_v4](https://github.com/jackc/pgx/tree/v4), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2) (Go 1.16) diff --git a/drivers/go-redis-v8/example_test.go b/drivers/go-redis-v8/example_test.go index 17d4943..b07e62a 100644 --- a/drivers/go-redis-v8/example_test.go +++ b/drivers/go-redis-v8/example_test.go @@ -8,8 +8,13 @@ import ( "encoding/json" "fmt" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/go-redis/redis/v8" + "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" + + trmredis "github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. @@ -21,7 +26,7 @@ func Example() { ctx := context.Background() rdb.FlushDB(ctx) - r := newRepo(rdb, DefaultCtxGetter) + r := newRepo(rdb, trmredis.DefaultCtxGetter) u1 := &user{ Username: "username1", @@ -31,11 +36,11 @@ func Example() { } trManager := manager.Must( - NewDefaultFactory(rdb), - manager.WithSettings(MustSettings( + trmredis.NewDefaultFactory(rdb), + manager.WithSettings(trmredis.MustSettings( settings.Must( settings.WithPropagation(trm.PropagationNested)), - WithTxDecorator(ReadOnlyFuncWithoutTxDecorator), + trmredis.WithTxDecorator(trmredis.ReadOnlyFuncWithoutTxDecorator), )), ) @@ -45,7 +50,7 @@ func Example() { var cmds []redis.Cmder err = trManager.DoWithSettings( ctx, - MustSettings(settings.Must(), WithRet(&cmds)), + trmredis.MustSettings(settings.Must(), trmredis.WithRet(&cmds)), func(ctx context.Context) error { if err := r.Save(ctx, u2); err != nil { return err @@ -81,10 +86,10 @@ func Example() { type repo struct { db redis.UniversalClient - getter *CtxGetter + getter *trmredis.CtxGetter } -func newRepo(db redis.UniversalClient, c *CtxGetter) *repo { +func newRepo(db redis.UniversalClient, c *trmredis.CtxGetter) *repo { return &repo{ db: db, getter: c, diff --git a/drivers/go-redis-v8/go.mod b/drivers/go-redis-v8/go.mod index a5e3311..db2dadb 100644 --- a/drivers/go-redis-v8/go.mod +++ b/drivers/go-redis-v8/go.mod @@ -4,6 +4,8 @@ go 1.13 require ( github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/go-redis/redis/v8 v8.11.5 + github.com/go-redis/redismock/v8 v8.11.5 github.com/stretchr/testify v1.8.2 ) diff --git a/drivers/go-redis-v8/go.sum b/drivers/go-redis-v8/go.sum new file mode 100644 index 0000000..492931b --- /dev/null +++ b/drivers/go-redis-v8/go.sum @@ -0,0 +1,161 @@ +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= +github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +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-redis/redismock/v8 v8.11.5 h1:RJFIiua58hrBrSpXhnGX3on79AU3S271H4ZhRI1wyVo= +github.com/go-redis/redismock/v8 v8.11.5/go.mod h1:UaAU9dEe1C+eGr+FHV5prCWIt0hafyPWbGMEWE0UWdA= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= +github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.18/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= +github.com/onsi/ginkgo/v2 v2.0.0 h1:CcuG/HvWNkkaqCUpJifQY8z7qEMBJya6aLPx6ftGyjQ= +github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= +github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/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-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/drivers/go-redis-v8/readonly_func_without_tx_test.go b/drivers/go-redis-v8/readonly_func_without_tx_test.go index 88bc816..283c829 100644 --- a/drivers/go-redis-v8/readonly_func_without_tx_test.go +++ b/drivers/go-redis-v8/readonly_func_without_tx_test.go @@ -7,6 +7,8 @@ import ( "context" "testing" + "github.com/go-redis/redis/v8" + redismock "github.com/go-redis/redismock/v8" "github.com/stretchr/testify/require" ) diff --git a/drivers/go-redis-v8/transaction_test.go b/drivers/go-redis-v8/transaction_test.go index 1df6528..9d41504 100644 --- a/drivers/go-redis-v8/transaction_test.go +++ b/drivers/go-redis-v8/transaction_test.go @@ -14,7 +14,8 @@ import ( "github.com/stretchr/testify/require" trm "github.com/avito-tech/go-transaction-manager/v2" - "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + "github.com/avito-tech/go-transaction-manager/v2/mock" + "github.com/go-redis/redismock/v8" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" diff --git a/drivers/go-redis-v8/watcher_test.go b/drivers/go-redis-v8/watcher_test.go index 18d2ac5..4b54b47 100644 --- a/drivers/go-redis-v8/watcher_test.go +++ b/drivers/go-redis-v8/watcher_test.go @@ -8,8 +8,12 @@ import ( "fmt" "time" + trm "github.com/avito-tech/go-transaction-manager/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" + "github.com/go-redis/redis/v8" + + trmredis "github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2" ) // Example demonstrates the watching of updated keys. @@ -21,7 +25,7 @@ func Example_watch() { ctx := context.Background() rdb.FlushDB(ctx) - r := newRepo(rdb, DefaultCtxGetter) + r := newRepo(rdb, trmredis.DefaultCtxGetter) u := &user{ ID: uuid1, @@ -29,12 +33,12 @@ func Example_watch() { } trManager := manager.Must( - NewDefaultFactory(rdb), - manager.WithSettings(MustSettings( + trmredis.NewDefaultFactory(rdb), + manager.WithSettings(trmredis.MustSettings( settings.Must( settings.WithPropagation(trm.PropagationNested)), - WithTxDecorator(newWatchDecorator), - WithMulti(true), + trmredis.WithTxDecorator(newWatchDecorator), + trmredis.WithMulti(true), )), ) @@ -62,7 +66,7 @@ func Example_watch() { err = r.Save(ctx, u) // Unwatch keys - cmd := DefaultCtxGetter.DefaultTrOrDB(ctx, nil).(Watch). + cmd := trmredis.DefaultCtxGetter.DefaultTrOrDB(ctx, nil).(trmredis.Watch). Unwatch(ctx) checkErr(cmd.Err()) @@ -79,10 +83,10 @@ func Example_watch() { } type watchDecoratorExample struct { - Cmdable + trmredis.Cmdable } -func newWatchDecorator(tx Cmdable, _ redis.Cmdable) Cmdable { +func newWatchDecorator(tx trmredis.Cmdable, _ redis.Cmdable) trmredis.Cmdable { return &watchDecoratorExample{Cmdable: tx} } diff --git a/drivers/gorm/example_test.go b/drivers/gorm/example_test.go index eca31e4..83a5b17 100644 --- a/drivers/gorm/example_test.go +++ b/drivers/gorm/example_test.go @@ -11,9 +11,10 @@ import ( "gorm.io/driver/sqlite" "gorm.io/gorm" -trmgorm github.com/avito-tech/go-transaction-manager/v2/gorm" -"github.com/avito-tech/go-transaction-manager/v2/manager" -"github.com/avito-tech/go-transaction-manager/v2/settings" + trmgorm "github.com/avito-tech/go-transaction-manager/drivers/gorm/v2" + trm "github.com/avito-tech/go-transaction-manager/v2" + "github.com/avito-tech/go-transaction-manager/v2/manager" + "github.com/avito-tech/go-transaction-manager/v2/settings" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. diff --git a/drivers/gorm/go.mod b/drivers/gorm/go.mod index 4972f03..0c4ca9c 100644 --- a/drivers/gorm/go.mod +++ b/drivers/gorm/go.mod @@ -3,7 +3,27 @@ module github.com/avito-tech/go-transaction-manager/drivers/gorm/v2 go 1.18 require ( - github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/DATA-DOG/go-sqlmock v1.5.0 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/mattn/go-sqlite3 v1.14.18 + github.com/stretchr/testify v1.8.2 + gorm.io/driver/mysql v1.5.2 + gorm.io/driver/sqlite v1.5.4 + gorm.io/gorm v1.25.5 ) -replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ \ No newline at end of file +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/go-sql-driver/mysql v1.7.0 // indirect + github.com/golang/mock v1.6.0 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + go.uber.org/atomic v1.7.0 // indirect + go.uber.org/multierr v1.9.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 => ../sql + +replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ diff --git a/drivers/gorm/go.sum b/drivers/gorm/go.sum new file mode 100644 index 0000000..87f9a29 --- /dev/null +++ b/drivers/gorm/go.sum @@ -0,0 +1,84 @@ +github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= +github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.18 h1:JL0eqdCOq6DJVNPSvArO/bIV9/P7fbGrV00LZHc+5aI= +github.com/mattn/go-sqlite3 v1.14.18/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/mysql v1.5.2 h1:QC2HRskSE75wBuOxe0+iCkyJZ+RqpudsQtqkp+IMuXs= +gorm.io/driver/mysql v1.5.2/go.mod h1:pQLhh1Ut/WUAySdTHwBpBv6+JKcj+ua4ZFx1QQTBzb8= +gorm.io/driver/sqlite v1.5.4 h1:IqXwXi8M/ZlPzH/947tn5uik3aYQslP9BVveoax0nV0= +gorm.io/driver/sqlite v1.5.4/go.mod h1:qxAuCol+2r6PannQDpOP1FP6ag3mKi4esLnB/jHed+4= +gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= +gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls= +gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= diff --git a/drivers/gorm/transaction_test.go b/drivers/gorm/transaction_test.go index f7b566c..e0d95ff 100644 --- a/drivers/gorm/transaction_test.go +++ b/drivers/gorm/transaction_test.go @@ -17,8 +17,9 @@ import ( "gorm.io/driver/sqlite" "gorm.io/gorm" - "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + "github.com/avito-tech/go-transaction-manager/v2/mock" + trm "github.com/avito-tech/go-transaction-manager/v2" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" "github.com/avito-tech/go-transaction-manager/v2/manager" diff --git a/drivers/mongo/example_test.go b/drivers/mongo/example_test.go index cf61777..ec19556 100644 --- a/drivers/mongo/example_test.go +++ b/drivers/mongo/example_test.go @@ -12,12 +12,12 @@ import ( "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" -trmsql github.com/avito-tech/go-transaction-manager/v2/sql" + trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" -trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" -"github.com/avito-tech/go-transaction-manager/v2/manager" + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" + "github.com/avito-tech/go-transaction-manager/v2/manager" -trmmongo "github.com/avito-tech/go-transaction-manager/drivers/mongo/v2" + trmmongo "github.com/avito-tech/go-transaction-manager/drivers/mongo/v2" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. diff --git a/drivers/mongo/go.mod b/drivers/mongo/go.mod index 8f99474..7400992 100644 --- a/drivers/mongo/go.mod +++ b/drivers/mongo/go.mod @@ -3,7 +3,13 @@ module github.com/avito-tech/go-transaction-manager/drivers/mongo/v2 go 1.13 require ( - github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/mattn/go-sqlite3 v1.14.18 + github.com/stretchr/testify v1.8.2 + go.mongodb.org/mongo-driver v1.12.1 ) -replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ \ No newline at end of file +replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 => ../sql + +replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ diff --git a/drivers/mongo/go.sum b/drivers/mongo/go.sum new file mode 100644 index 0000000..c464d64 --- /dev/null +++ b/drivers/mongo/go.sum @@ -0,0 +1,112 @@ +github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= +github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= +github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.18 h1:JL0eqdCOq6DJVNPSvArO/bIV9/P7fbGrV00LZHc+5aI= +github.com/mattn/go-sqlite3 v1.14.18/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= +github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= +github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= +github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= +github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.mongodb.org/mongo-driver v1.12.1 h1:nLkghSU8fQNaK7oUmDhQFsnrtcoNy7Z6LVFKsEecqgE= +go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ= +go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY= +golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/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 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/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-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +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/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/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.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/drivers/mongo/transaction_test.go b/drivers/mongo/transaction_test.go index 4410072..f1c5def 100644 --- a/drivers/mongo/transaction_test.go +++ b/drivers/mongo/transaction_test.go @@ -16,7 +16,7 @@ import ( "go.mongodb.org/mongo-driver/mongo/writeconcern" trm "github.com/avito-tech/go-transaction-manager/v2" - "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + "github.com/avito-tech/go-transaction-manager/v2/mock" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" diff --git a/drivers/pgxv4/example_test.go b/drivers/pgxv4/example_test.go index 643284c..8711af2 100644 --- a/drivers/pgxv4/example_test.go +++ b/drivers/pgxv4/example_test.go @@ -9,8 +9,8 @@ import ( "github.com/jackc/pgx/v4/pgxpool" -"github.com/avito-tech/go-transaction-manager/v2/manager" -trmpgx "github.com/avito-tech/go-transaction-manager/v2/pgxv4" + trmpgx "github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2" + "github.com/avito-tech/go-transaction-manager/v2/manager" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. diff --git a/drivers/pgxv4/go.mod b/drivers/pgxv4/go.mod index 3c386f2..dd30b5a 100644 --- a/drivers/pgxv4/go.mod +++ b/drivers/pgxv4/go.mod @@ -3,7 +3,11 @@ module github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2 go 1.13 require ( - github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/jackc/pgconn v1.14.1 + github.com/jackc/pgx/v4 v4.18.1 + github.com/pashagolub/pgxmock v1.8.0 + github.com/stretchr/testify v1.8.2 ) -replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ \ No newline at end of file +replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ diff --git a/drivers/pgxv4/go.sum b/drivers/pgxv4/go.sum new file mode 100644 index 0000000..b2efab3 --- /dev/null +++ b/drivers/pgxv4/go.sum @@ -0,0 +1,245 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= +github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= +github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= +github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= +github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= +github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= +github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= +github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= +github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= +github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= +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/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= +github.com/jackc/pgconn v1.14.0/go.mod h1:9mBNlny0UvkgJdCDvdVHYSjI+8tD2rnKK69Wz8ti++E= +github.com/jackc/pgconn v1.14.1 h1:smbxIaZA08n6YuxEX1sDyjV/qkbtUtkH20qLkR9MUR4= +github.com/jackc/pgconn v1.14.1/go.mod h1:9mBNlny0UvkgJdCDvdVHYSjI+8tD2rnKK69Wz8ti++E= +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= +github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= +github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc= +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= +github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= +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.0.7/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/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.3.2 h1:7eY55bdBeCz1F2fTzSz69QC+pG46jYq9/jtSPiJ5nn0= +github.com/jackc/pgproto3/v2 v2.3.2/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.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgtype v1.14.0 h1:y+xUdabmyMkJLyApYuPj38mW+aAIqCe5uuBB51rH3Vw= +github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +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/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= +github.com/jackc/pgx/v4 v4.17.0/go.mod h1:Gd6RmOhtFLTu8cp/Fhq4kP195KrshxYJH3oW8AWJ1pw= +github.com/jackc/pgx/v4 v4.18.1 h1:YP7G1KABtKpB5IHrO9vYwSrCOhs7p3uqhvhhQBptya0= +github.com/jackc/pgx/v4 v4.18.1/go.mod h1:FydWkUyadDmdNH/mHnGob881GawxeEm7TcMCzkb+qQE= +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.2.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jackc/puddle v1.3.0 h1:eHK/5clGOatcjX3oWGBO/MpxpbHzSwud5EWTSCI+MX0= +github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= +github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= +github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +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/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= +github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.18/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/pashagolub/pgxmock v1.8.0 h1:05JB+jng7yPdeC6i04i8TC4H1Kr7TfcFeQyf4JP6534= +github.com/pashagolub/pgxmock v1.8.0/go.mod h1:kDkER7/KJdD3HQjNvFw5siwR7yREKmMvwf8VhAgTK5o= +github.com/pashagolub/pgxstruct v0.0.0-20210217101842-40d357eec200/go.mod h1:fOTLLi1PtVUDXx28olVT/D2UMFCmBEYpnY5QIzghmDc= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.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= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= +github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= +github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= +github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= +github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= +github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +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= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +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 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +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.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +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= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/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-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +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-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/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/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/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-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.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +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.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +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.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +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= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/drivers/pgxv4/transaction_test.go b/drivers/pgxv4/transaction_test.go index 4f7b09d..f69436b 100644 --- a/drivers/pgxv4/transaction_test.go +++ b/drivers/pgxv4/transaction_test.go @@ -16,7 +16,7 @@ import ( "github.com/stretchr/testify/require" trm "github.com/avito-tech/go-transaction-manager/v2" - "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + "github.com/avito-tech/go-transaction-manager/v2/mock" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" diff --git a/drivers/pgxv5/example_test.go b/drivers/pgxv5/example_test.go index 4cff472..e1cb83b 100644 --- a/drivers/pgxv5/example_test.go +++ b/drivers/pgxv5/example_test.go @@ -9,8 +9,8 @@ import ( "github.com/jackc/pgx/v5/pgxpool" -"github.com/avito-tech/go-transaction-manager/v2/manager" -trmpgx "github.com/avito-tech/go-transaction-manager/v2/pgxv5" + trmpgx "github.com/avito-tech/go-transaction-manager/drivers/pgxv5/v2" + "github.com/avito-tech/go-transaction-manager/v2/manager" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. diff --git a/drivers/pgxv5/go.mod b/drivers/pgxv5/go.mod index f27bd16..f2ec91d 100644 --- a/drivers/pgxv5/go.mod +++ b/drivers/pgxv5/go.mod @@ -3,7 +3,10 @@ module github.com/avito-tech/go-transaction-manager/drivers/pgxv5/v2 go 1.13 require ( - github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/jackc/pgx/v5 v5.5.0 + github.com/pashagolub/pgxmock/v2 v2.12.0 + github.com/stretchr/testify v1.8.2 ) -replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ \ No newline at end of file +replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ diff --git a/drivers/pgxv5/go.sum b/drivers/pgxv5/go.sum new file mode 100644 index 0000000..e1edf2f --- /dev/null +++ b/drivers/pgxv5/go.sum @@ -0,0 +1,108 @@ +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +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/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/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA= +github.com/jackc/pgx/v5 v5.5.0 h1:NxstgwndsTRy7eq9/kqYc/BZh5w2hHJV86wjvO+1xPw= +github.com/jackc/pgx/v5 v5.5.0/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA= +github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= +github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= +github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= +github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.18/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/pashagolub/pgxmock/v2 v2.12.0 h1:IVRmQtVFNCoq7NOZ+PdfvB6fwnLJmEuWDhnc3yrDxBs= +github.com/pashagolub/pgxmock/v2 v2.12.0/go.mod h1:D3YslkN/nJ4+umVqWmbwfSXugJIjPMChkGBG47OJpNw= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +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 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= +golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/mod v0.4.2/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.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +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/sync v0.0.0-20190423024810-112230192c58/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 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/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-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.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +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.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/drivers/pgxv5/transaction_test.go b/drivers/pgxv5/transaction_test.go index 012216f..6c1c0c3 100644 --- a/drivers/pgxv5/transaction_test.go +++ b/drivers/pgxv5/transaction_test.go @@ -16,7 +16,7 @@ import ( "github.com/stretchr/testify/require" trm "github.com/avito-tech/go-transaction-manager/v2" - "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + "github.com/avito-tech/go-transaction-manager/v2/mock" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" diff --git a/drivers/sql/go.mod b/drivers/sql/go.mod index 6ca597c..92569d0 100644 --- a/drivers/sql/go.mod +++ b/drivers/sql/go.mod @@ -3,7 +3,12 @@ module github.com/avito-tech/go-transaction-manager/drivers/sql/v2 go 1.13 require ( + github.com/DATA-DOG/go-sqlmock v1.5.0 github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/golang/mock v1.6.0 + github.com/mattn/go-sqlite3 v1.14.18 + github.com/stretchr/testify v1.8.2 + go.uber.org/multierr v1.9.0 ) -replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ \ No newline at end of file +replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ diff --git a/drivers/sql/go.sum b/drivers/sql/go.sum new file mode 100644 index 0000000..d42c0bb --- /dev/null +++ b/drivers/sql/go.sum @@ -0,0 +1,71 @@ +github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= +github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.18 h1:JL0eqdCOq6DJVNPSvArO/bIV9/P7fbGrV00LZHc+5aI= +github.com/mattn/go-sqlite3 v1.14.18/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/drivers/sql/transaction_test.go b/drivers/sql/transaction_test.go index 6cd1da1..ede0fc8 100644 --- a/drivers/sql/transaction_test.go +++ b/drivers/sql/transaction_test.go @@ -12,7 +12,7 @@ import ( "github.com/stretchr/testify/require" trm "github.com/avito-tech/go-transaction-manager/v2" - "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + "github.com/avito-tech/go-transaction-manager/v2/mock" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" diff --git a/drivers/sqlx/example_test.go b/drivers/sqlx/example_test.go index 1c1498b..c9132dc 100644 --- a/drivers/sqlx/example_test.go +++ b/drivers/sqlx/example_test.go @@ -7,7 +7,8 @@ import ( "github.com/jmoiron/sqlx" _ "github.com/mattn/go-sqlite3" -"github.com/avito-tech/go-transaction-manager/v2/manager" + trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" + "github.com/avito-tech/go-transaction-manager/v2/manager" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. @@ -20,14 +21,14 @@ func Example() { _, err := db.Exec(sqlStmt) checkErr(err, sqlStmt) - r := newRepo(db, DefaultCtxGetter) + r := newRepo(db, trmsqlx.DefaultCtxGetter) u := &user{ Username: "username", } ctx := context.Background() - trManager := manager.Must(NewDefaultFactory(db)) + trManager := manager.Must(trmsqlx.NewDefaultFactory(db)) err = trManager.Do(ctx, func(ctx context.Context) error { if err := r.Save(ctx, u); err != nil { @@ -59,10 +60,10 @@ func newDB() *sqlx.DB { type repo struct { db *sqlx.DB - getter *CtxGetter + getter *trmsqlx.CtxGetter } -func newRepo(db *sqlx.DB, c *CtxGetter) *repo { +func newRepo(db *sqlx.DB, c *trmsqlx.CtxGetter) *repo { return &repo{ db: db, getter: c, diff --git a/drivers/sqlx/factory.go b/drivers/sqlx/factory.go index fabe090..6a39487 100644 --- a/drivers/sqlx/factory.go +++ b/drivers/sqlx/factory.go @@ -6,6 +6,7 @@ import ( "github.com/jmoiron/sqlx" trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // NewDefaultFactory creates default trm.Transaction(sqlx.Tx). diff --git a/drivers/sqlx/go.mod b/drivers/sqlx/go.mod index 2c9e005..ad13e74 100644 --- a/drivers/sqlx/go.mod +++ b/drivers/sqlx/go.mod @@ -3,9 +3,15 @@ module github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2 go 1.13 require ( - github.com/avito-tech/go-transaction-manager/v2 v2.0.0 - github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 + github.com/DATA-DOG/go-sqlmock v1.5.0 + github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/jmoiron/sqlx v1.3.5 + github.com/mattn/go-sqlite3 v1.14.18 + github.com/stretchr/testify v1.8.2 + go.uber.org/multierr v1.9.0 ) replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ -replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 => ../sql \ No newline at end of file + +replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 => ../sql diff --git a/drivers/sqlx/go.sum b/drivers/sqlx/go.sum new file mode 100644 index 0000000..32399e0 --- /dev/null +++ b/drivers/sqlx/go.sum @@ -0,0 +1,74 @@ +github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= +github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= +github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.18 h1:JL0eqdCOq6DJVNPSvArO/bIV9/P7fbGrV00LZHc+5aI= +github.com/mattn/go-sqlite3 v1.14.18/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/drivers/sqlx/transaction.go b/drivers/sqlx/transaction.go index 18723cc..9f12b8c 100644 --- a/drivers/sqlx/transaction.go +++ b/drivers/sqlx/transaction.go @@ -9,7 +9,9 @@ import ( "github.com/jmoiron/sqlx" "go.uber.org/multierr" -trmsql github.com/avito-tech/go-transaction-manager/v2/sql" + trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" + + trm "github.com/avito-tech/go-transaction-manager/v2" ) // Transaction is trm.Transaction for sqlx.Tx. diff --git a/drivers/sqlx/transaction_test.go b/drivers/sqlx/transaction_test.go index d7477e7..1067e6f 100644 --- a/drivers/sqlx/transaction_test.go +++ b/drivers/sqlx/transaction_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/require" trm "github.com/avito-tech/go-transaction-manager/v2" - "github.com/avito-tech/go-transaction-manager/v2/internal/mock" + "github.com/avito-tech/go-transaction-manager/v2/mock" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" diff --git a/go.mod b/go.mod index e68c5d5..e1dcbae 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,12 @@ module github.com/avito-tech/go-transaction-manager/v2 go 1.13 require ( + github.com/DATA-DOG/go-sqlmock v1.5.0 github.com/golang/mock v1.6.0 + github.com/jinzhu/copier v0.4.0 + github.com/jmoiron/sqlx v1.3.5 github.com/kr/pretty v0.3.0 // indirect + github.com/mattn/go-sqlite3 v1.14.18 github.com/stretchr/testify v1.8.2 go.uber.org/multierr v1.9.0 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..ebcc7eb --- /dev/null +++ b/go.sum @@ -0,0 +1,75 @@ +github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8= +github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= +github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= +github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lib/pq v1.2.0 h1:LXpIM/LZ5xGFhOpXAQUIMM1HdyqzVYM13zNdjCEEcA0= +github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= +github.com/mattn/go-sqlite3 v1.14.18 h1:JL0eqdCOq6DJVNPSvArO/bIV9/P7fbGrV00LZHc+5aI= +github.com/mattn/go-sqlite3 v1.14.18/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= +go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/manager/manager_test.go b/manager/manager_test.go index 1c5da6b..a164d0d 100644 --- a/manager/manager_test.go +++ b/manager/manager_test.go @@ -13,7 +13,6 @@ import ( trm "github.com/avito-tech/go-transaction-manager/v2" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" - trmmock "github.com/avito-tech/go-transaction-manager/v2/internal/mock" mock_log "github.com/avito-tech/go-transaction-manager/v2/manager/mock" "github.com/avito-tech/go-transaction-manager/v2/mock" "github.com/avito-tech/go-transaction-manager/v2/settings" @@ -573,7 +572,7 @@ func Test_transactionManager_Do_Panic(t *testing.T) { testPanic := "panic" testRollbackErr := errors.New("rollback error") - log := trmmock.NewLog() + log := mock.NewLog() factory := func(ctx context.Context, _ trm.Settings) (context.Context, trm.Transaction, error) { tx := mock.NewMockTransaction(ctrl) @@ -776,7 +775,7 @@ func TestManager_WithOpts(t *testing.T) { t.Run("set", func(t *testing.T) { t.Parallel() - l := trmmock.NewZeroLog() + l := mock.NewZeroLog() m := Must(nil, WithLog(l), WithSettings(s{})) assert.Equal(t, l, m.log) diff --git a/internal/mock/log.go b/mock/log.go similarity index 100% rename from internal/mock/log.go rename to mock/log.go diff --git a/sh/go.mod.tidy.sh b/sh/go.mod.tidy.sh index ec13aac..5a402ad 100644 --- a/sh/go.mod.tidy.sh +++ b/sh/go.mod.tidy.sh @@ -1,7 +1,14 @@ -cd ../ && go mod tidy +cd ../ -for driver in */../drivers/ ; do +ROOT=$(pwd) + +go mod tidy + +for driver in ./drivers/*/; do if [ -d "$driver" ]; then + echo "\n$driver" cd $driver && go mod tidy + + cd $ROOT fi -done \ No newline at end of file +done diff --git a/sh/go.mod.vendor.sh b/sh/go.mod.vendor.sh index f62b6ee..9797e77 100644 --- a/sh/go.mod.vendor.sh +++ b/sh/go.mod.vendor.sh @@ -1,7 +1,14 @@ -cd ../ && go mod tidy +cd ../ -for driver in */../drivers/ ; do +ROOT=$(pwd) + +go mod vendor + +for driver in ./drivers/*; do if [ -d "$driver" ]; then + echo "\n$driver" cd $driver && go mod vendor + + cd $ROOT fi -done \ No newline at end of file +done From abfdc40b46a2e2f7ebd894a2f88ccd01e1f9bb52 Mon Sep 17 00:00:00 2001 From: iasergunin Date: Sun, 3 Dec 2023 23:11:23 +0300 Subject: [PATCH 03/13] 1. Fixed redis naming 2. Run tests for all submodules --- .github/workflows/main.yaml | 4 ++-- Makefile | 20 +++++++++----------- README.md | 2 +- context.go | 2 +- drivers/go-redis-v8/context.go | 6 +++--- drivers/go-redis-v8/example_test.go | 2 +- drivers/go-redis-v8/factory.go | 2 +- drivers/go-redis-v8/option.go | 2 +- drivers/go-redis-v8/settings.go | 8 ++++---- drivers/go-redis-v8/transaction.go | 2 +- drivers/go-redis-v8/transaction_test.go | 2 +- drivers/go-redis-v8/watcher_test.go | 2 +- manager.go | 2 +- manager_test.go | 2 +- mock/log.go | 4 +++- settings.go | 2 +- sh/go.test.sh | 25 +++++++++++++++++++++++++ transaction.go | 2 +- 18 files changed, 58 insertions(+), 33 deletions(-) create mode 100644 sh/go.test.sh diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d4c4858..6c327e0 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -56,10 +56,10 @@ jobs: pull-requests: write services: redis: - image: go-redis-v9 + image: redis ports: - 6379:6379 - # Set health checks to wait until go-redis-v9 has started + # Set health checks to wait until redis has started options: >- --health-cmd "redis-cli ping" --health-interval 10s diff --git a/Makefile b/Makefile index 9bcb20e..be253c4 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ -CVPKG=go list ./... | grep -v mocks | grep -v internal/ -GO_TEST=go test `$(CVPKG)` -race +GO_TEST=cd ./sh && sh ./go.test.sh GO_TEST_WITH_REAL_DB=$(GO_TEST) --tags=with_real_db -COVERAGE_FILE="coverage.out" + +DIR=$(PWD) +COVERAGE_FILE=`echo $(DIR)/coverage.out` test: $(GO_TEST) @@ -9,6 +10,7 @@ test: test.with_real_db: $(GO_TEST_WITH_REAL_DB) +# TODO see in https://gist.github.com/skarllot/13ebe8220822bc19494c8b076aabe9fc test.coverage: $(GO_TEST) -covermode=atomic -coverprofile=$(COVERAGE_FILE) @@ -25,12 +27,8 @@ generate: go generate ./... -go.update: go.tidy go.vendor - -go.prepare: go.vendor - -go.tidy: - ./sh/go.mod.tidy.sh +go.mod.tidy: + cd sh && sh ./go.mod.tidy.sh -go.vendor: - ./sh/go.mod.vendor.sh +go.mod.vendor: + cd sh && sh ./go.mod.vendor.sh diff --git a/README.md b/README.md index 76774a8..ef2f006 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Compatibility beyond that is not guaranteed. * [jmoiron/sqlx](drivers/sqlx/example_test.go) * [gorm](drivers/gorm/example_test.go) * [mongo-go-driver](drivers/mongo/example_test.go) -* [go-redis/redis](drivers/go-redis-v9/example_test.go) +* [go-redis/redis](drivers/go-redis-v8/example_test.go) * [pgx_v4](drivers/pgxv4/example_test.go) * [pgx_v5](drivers/pgxv5/example_test.go) diff --git a/context.go b/context.go index 623ce80..367ccac 100644 --- a/context.go +++ b/context.go @@ -1,4 +1,4 @@ -package go_transaction_manager +package trm import ( "context" diff --git a/drivers/go-redis-v8/context.go b/drivers/go-redis-v8/context.go index bb3b8ac..dc7cc96 100644 --- a/drivers/go-redis-v8/context.go +++ b/drivers/go-redis-v8/context.go @@ -12,7 +12,7 @@ import ( // DefaultCtxGetter is the CtxGetter with settings.DefaultCtxKey. var DefaultCtxGetter = NewCtxGetter(trmcontext.DefaultManager) -// CtxGetter gets go-redis-v9.Pipeliner from trm.СtxManager by casting trm.Transaction to go-redis-v9.UniversalClient. +// CtxGetter gets go-redis-v8.Pipeliner from trm.СtxManager by casting trm.Transaction to redis.UniversalClient. type CtxGetter struct { ctxManager trm.СtxManager } @@ -22,7 +22,7 @@ func NewCtxGetter(c trm.СtxManager) *CtxGetter { return &CtxGetter{ctxManager: c} } -// DefaultTrOrDB returns Cmdable from context.Context or DB(go-redis-v9.Cmdable) otherwise. +// DefaultTrOrDB returns Cmdable from context.Context or DB(go-redis-v8.Cmdable) otherwise. func (c *CtxGetter) DefaultTrOrDB(ctx context.Context, db redis.Cmdable) redis.Cmdable { if tr := c.ctxManager.Default(ctx); tr != nil { return c.convert(tr) @@ -31,7 +31,7 @@ func (c *CtxGetter) DefaultTrOrDB(ctx context.Context, db redis.Cmdable) redis.C return db } -// TrOrDB returns Cmdable from context.Context by trm.CtxKey or DB(go-redis-v9.Cmdable) otherwise. +// TrOrDB returns Cmdable from context.Context by trm.CtxKey or DB(go-redis-v8.Cmdable) otherwise. func (c *CtxGetter) TrOrDB(ctx context.Context, key trm.CtxKey, db redis.Cmdable) redis.Cmdable { if tr := c.ctxManager.ByKey(ctx, key); tr != nil { return c.convert(tr) diff --git a/drivers/go-redis-v8/example_test.go b/drivers/go-redis-v8/example_test.go index b07e62a..38be219 100644 --- a/drivers/go-redis-v8/example_test.go +++ b/drivers/go-redis-v8/example_test.go @@ -119,7 +119,7 @@ type user struct { } type userRecord struct { - Username string `go-redis-v9:"username"` + Username string `redis:"username"` } func (r userRecord) MarshalBinary() (data []byte, err error) { diff --git a/drivers/go-redis-v8/factory.go b/drivers/go-redis-v8/factory.go index bb4c463..426a43f 100644 --- a/drivers/go-redis-v8/factory.go +++ b/drivers/go-redis-v8/factory.go @@ -8,7 +8,7 @@ import ( trm "github.com/avito-tech/go-transaction-manager/v2" ) -// NewDefaultFactory creates default trm.Transaction(go-redis-v9.UniversalClient). +// NewDefaultFactory creates default trm.Transaction(redis.UniversalClient). func NewDefaultFactory(db redis.UniversalClient) trm.TrFactory { return func(ctx context.Context, trms trm.Settings) (context.Context, trm.Transaction, error) { s, _ := trms.(Settings) diff --git a/drivers/go-redis-v8/option.go b/drivers/go-redis-v8/option.go index c3e7a48..9ab72c6 100644 --- a/drivers/go-redis-v8/option.go +++ b/drivers/go-redis-v8/option.go @@ -29,7 +29,7 @@ func WithTxDecorator(in TxDecorator) Opt { } } -// WithRet sets link on []go-redis-v9.Cmder to get responses of commands in Transaction +// WithRet sets link on []redis.Cmder to get responses of commands in Transaction // WARNING: Responses don't clean automatically, use WithRet only with DoWithSettings of trm.Manager. func WithRet(in *[]redis.Cmder) Opt { return func(s *Settings) error { diff --git a/drivers/go-redis-v8/settings.go b/drivers/go-redis-v8/settings.go index 059fd86..23f1017 100644 --- a/drivers/go-redis-v8/settings.go +++ b/drivers/go-redis-v8/settings.go @@ -14,7 +14,7 @@ const ( // Opt is a type to configure Settings. type Opt func(*Settings) error -// Settings contains settings for go-redis-v9.Transaction. +// Settings contains settings for redis.Transaction. type Settings struct { trm.Settings isMulti *bool @@ -78,7 +78,7 @@ func (s Settings) EnrichBy(in trm.Settings) trm.Settings { return s } -// IsMulti - true uses go-redis-v9 MULTI cmd. +// IsMulti - true uses redis MULTI cmd. func (s Settings) IsMulti() bool { if s.isMulti == nil { return DefaultMulti @@ -135,12 +135,12 @@ func (s Settings) setTxDecorator(in ...TxDecorator) Settings { return s } -// Return returns []go-redis-v9.Cmder from Transaction. +// Return returns []redis.Cmder from Transaction. func (s Settings) Return() *[]redis.Cmder { return s.ret } -// SetReturn sets link to save []go-redis-v9.Cmder from Transaction. +// SetReturn sets link to save []redis.Cmder from Transaction. func (s Settings) SetReturn(in *[]redis.Cmder) Settings { return s.setReturn(in) } diff --git a/drivers/go-redis-v8/transaction.go b/drivers/go-redis-v8/transaction.go index ec00e4a..53a8cdd 100644 --- a/drivers/go-redis-v8/transaction.go +++ b/drivers/go-redis-v8/transaction.go @@ -1,4 +1,4 @@ -// Package go-redis-v9 is an implementation of trm.Transaction interface by Transaction for go-redis-v9.UniversalClient. +// Package go_redis_v8 is an implementation of trm.Transaction interface by Transaction for redis.UniversalClient. package go_redis_v8 import ( diff --git a/drivers/go-redis-v8/transaction_test.go b/drivers/go-redis-v8/transaction_test.go index 9d41504..512592f 100644 --- a/drivers/go-redis-v8/transaction_test.go +++ b/drivers/go-redis-v8/transaction_test.go @@ -82,7 +82,7 @@ func TestTransaction(t *testing.T) { ctx: context.Background(), }, wantErr: func(t assert.TestingT, err error, i ...interface{}) bool { - return assert.ErrorContains(t, err, "go-redis-v9: nil") && + return assert.ErrorContains(t, err, "redis: nil") && assert.ErrorIs(t, err, trm.ErrCommit) }, }, diff --git a/drivers/go-redis-v8/watcher_test.go b/drivers/go-redis-v8/watcher_test.go index 4b54b47..b5ae0a7 100644 --- a/drivers/go-redis-v8/watcher_test.go +++ b/drivers/go-redis-v8/watcher_test.go @@ -78,7 +78,7 @@ func Example_watch() { ) fmt.Println(err) - // Output: transaction: commit; go-redis-v9: transaction failed + // Output: transaction: commit; redis: transaction failed // } diff --git a/manager.go b/manager.go index 4bddb37..186917e 100644 --- a/manager.go +++ b/manager.go @@ -1,4 +1,4 @@ -package go_transaction_manager +package trm //go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock diff --git a/manager_test.go b/manager_test.go index 0ee175f..f383f3c 100644 --- a/manager_test.go +++ b/manager_test.go @@ -1,4 +1,4 @@ -package go_transaction_manager +package trm import ( "errors" diff --git a/mock/log.go b/mock/log.go index 7b2041d..daf08c1 100644 --- a/mock/log.go +++ b/mock/log.go @@ -14,7 +14,9 @@ type Log struct { // NewLog create mock Log. func NewLog() *Log { - return &Log{} + return &Log{ + Logged: nil, + } } func (l *Log) Warning(_ context.Context, msg string) { diff --git a/settings.go b/settings.go index 42eea60..ca92fa8 100644 --- a/settings.go +++ b/settings.go @@ -1,4 +1,4 @@ -package go_transaction_manager +package trm //go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock diff --git a/sh/go.test.sh b/sh/go.test.sh new file mode 100644 index 0000000..d14c676 --- /dev/null +++ b/sh/go.test.sh @@ -0,0 +1,25 @@ +cd ../ + +ROOT=$(pwd) + +golist() { + go list ./... | grep -v mock | grep -v internal/ +} + +gotest() { + cd $driver + + go test $(golist) -race "$@" + + cd $ROOT +} + +go test $(golist) -race "$@" + +for driver in ./drivers/*; do + if [ -d "$driver" ]; then + gotest "$@" & + fi +done + +wait diff --git a/transaction.go b/transaction.go index d1b3ac7..265be90 100644 --- a/transaction.go +++ b/transaction.go @@ -1,5 +1,5 @@ // Package trm contains of interfaces to programmatic transaction management. -package go_transaction_manager +package trm //go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock From a4727286186ec96c4107b1127958078d601503a2 Mon Sep 17 00:00:00 2001 From: iasergunin Date: Fri, 15 Dec 2023 23:01:08 +0400 Subject: [PATCH 04/13] 1. bumped library versions 2. added workspace --- drivers/go-redis-v8/go.sum | 3 ++- drivers/go-redis-v8/go.work | 6 ++++++ drivers/gorm/go.mod | 2 +- drivers/gorm/go.sum | 5 +++-- drivers/gorm/go.work | 6 ++++++ drivers/mongo/go.mod | 2 +- drivers/mongo/go.sum | 8 +++++--- drivers/mongo/go.work | 7 +++++++ drivers/mongo/transaction_test.go | 2 -- drivers/pgxv4/go.sum | 3 ++- drivers/pgxv4/go.work | 6 ++++++ drivers/pgxv5/go.mod | 2 +- drivers/pgxv5/go.sum | 7 ++++--- drivers/pgxv5/go.work | 6 ++++++ drivers/sql/go.mod | 2 +- drivers/sql/go.sum | 5 +++-- drivers/sql/go.work | 5 +++++ drivers/sqlx/go.mod | 2 +- drivers/sqlx/go.sum | 5 +++-- drivers/sqlx/go.work | 7 +++++++ go.mod | 2 +- go.sum | 5 +++-- 22 files changed, 74 insertions(+), 24 deletions(-) create mode 100644 drivers/go-redis-v8/go.work create mode 100644 drivers/gorm/go.work create mode 100644 drivers/mongo/go.work create mode 100644 drivers/pgxv4/go.work create mode 100644 drivers/pgxv5/go.work create mode 100644 drivers/sql/go.work create mode 100644 drivers/sqlx/go.work diff --git a/drivers/go-redis-v8/go.sum b/drivers/go-redis-v8/go.sum index 492931b..5594999 100644 --- a/drivers/go-redis-v8/go.sum +++ b/drivers/go-redis-v8/go.sum @@ -1,4 +1,4 @@ -github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/DATA-DOG/go-sqlmock v1.5.1/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -41,6 +41,7 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= diff --git a/drivers/go-redis-v8/go.work b/drivers/go-redis-v8/go.work new file mode 100644 index 0000000..11d684b --- /dev/null +++ b/drivers/go-redis-v8/go.work @@ -0,0 +1,6 @@ +go 1.21 + +use . + +replace github.com/avito-tech/go-transaction-manager/v2 => ../../ + diff --git a/drivers/gorm/go.mod b/drivers/gorm/go.mod index 0c4ca9c..0d2b0d9 100644 --- a/drivers/gorm/go.mod +++ b/drivers/gorm/go.mod @@ -3,7 +3,7 @@ module github.com/avito-tech/go-transaction-manager/drivers/gorm/v2 go 1.18 require ( - github.com/DATA-DOG/go-sqlmock v1.5.0 + github.com/DATA-DOG/go-sqlmock v1.5.1 github.com/avito-tech/go-transaction-manager/v2 v2.0.0 github.com/mattn/go-sqlite3 v1.14.18 github.com/stretchr/testify v1.8.2 diff --git a/drivers/gorm/go.sum b/drivers/gorm/go.sum index 87f9a29..2d9394c 100644 --- a/drivers/gorm/go.sum +++ b/drivers/gorm/go.sum @@ -1,5 +1,5 @@ -github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= -github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/DATA-DOG/go-sqlmock v1.5.1 h1:FK6RCIUSfmbnI/imIICmboyQBkOckutaa6R5YYlLZyo= +github.com/DATA-DOG/go-sqlmock v1.5.1/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -15,6 +15,7 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= diff --git a/drivers/gorm/go.work b/drivers/gorm/go.work new file mode 100644 index 0000000..bb5c9df --- /dev/null +++ b/drivers/gorm/go.work @@ -0,0 +1,6 @@ +go 1.21 + +use . + +replace github.com/avito-tech/go-transaction-manager/v2 => ../../ +replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 => ../sql \ No newline at end of file diff --git a/drivers/mongo/go.mod b/drivers/mongo/go.mod index 7400992..0fcf73e 100644 --- a/drivers/mongo/go.mod +++ b/drivers/mongo/go.mod @@ -7,7 +7,7 @@ require ( github.com/avito-tech/go-transaction-manager/v2 v2.0.0 github.com/mattn/go-sqlite3 v1.14.18 github.com/stretchr/testify v1.8.2 - go.mongodb.org/mongo-driver v1.12.1 + go.mongodb.org/mongo-driver v1.13.1 ) replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 => ../sql diff --git a/drivers/mongo/go.sum b/drivers/mongo/go.sum index c464d64..caf0b0b 100644 --- a/drivers/mongo/go.sum +++ b/drivers/mongo/go.sum @@ -1,5 +1,6 @@ -github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/DATA-DOG/go-sqlmock v1.5.1 h1:FK6RCIUSfmbnI/imIICmboyQBkOckutaa6R5YYlLZyo= +github.com/DATA-DOG/go-sqlmock v1.5.1/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -13,6 +14,7 @@ github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -52,8 +54,8 @@ github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.mongodb.org/mongo-driver v1.12.1 h1:nLkghSU8fQNaK7oUmDhQFsnrtcoNy7Z6LVFKsEecqgE= -go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ= +go.mongodb.org/mongo-driver v1.13.1 h1:YIc7HTYsKndGK4RFzJ3covLz1byri52x0IoMB0Pt/vk= +go.mongodb.org/mongo-driver v1.13.1/go.mod h1:wcDf1JBCXy2mOW0bWHwO/IOYqdca1MPCwDtFu/Z9+eo= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= diff --git a/drivers/mongo/go.work b/drivers/mongo/go.work new file mode 100644 index 0000000..c27816b --- /dev/null +++ b/drivers/mongo/go.work @@ -0,0 +1,7 @@ +go 1.21 + +use . + +replace github.com/avito-tech/go-transaction-manager/v2 => ../../ +replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 => ../sql + diff --git a/drivers/mongo/transaction_test.go b/drivers/mongo/transaction_test.go index f1c5def..d384934 100644 --- a/drivers/mongo/transaction_test.go +++ b/drivers/mongo/transaction_test.go @@ -56,7 +56,6 @@ func TestTransaction(t *testing.T) { t, mtest.NewOptions().ClientType(mtest.Mock), ) - defer mt.Close() tests := map[string]struct { fields func(mt *mtest.T) fields @@ -202,7 +201,6 @@ func TestTransaction_awaitDone(t *testing.T) { ClientType(mtest.Mock). ShareClient(true), ) - defer mt.Close() wg := sync.WaitGroup{} wg.Add(1) diff --git a/drivers/pgxv4/go.sum b/drivers/pgxv4/go.sum index b2efab3..afb39d5 100644 --- a/drivers/pgxv4/go.sum +++ b/drivers/pgxv4/go.sum @@ -1,5 +1,5 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/DATA-DOG/go-sqlmock v1.5.1/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= @@ -81,6 +81,7 @@ github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dv github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= 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/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= diff --git a/drivers/pgxv4/go.work b/drivers/pgxv4/go.work new file mode 100644 index 0000000..11d684b --- /dev/null +++ b/drivers/pgxv4/go.work @@ -0,0 +1,6 @@ +go 1.21 + +use . + +replace github.com/avito-tech/go-transaction-manager/v2 => ../../ + diff --git a/drivers/pgxv5/go.mod b/drivers/pgxv5/go.mod index f2ec91d..983073c 100644 --- a/drivers/pgxv5/go.mod +++ b/drivers/pgxv5/go.mod @@ -4,7 +4,7 @@ go 1.13 require ( github.com/avito-tech/go-transaction-manager/v2 v2.0.0 - github.com/jackc/pgx/v5 v5.5.0 + github.com/jackc/pgx/v5 v5.5.1 github.com/pashagolub/pgxmock/v2 v2.12.0 github.com/stretchr/testify v1.8.2 ) diff --git a/drivers/pgxv5/go.sum b/drivers/pgxv5/go.sum index e1edf2f..8db70f4 100644 --- a/drivers/pgxv5/go.sum +++ b/drivers/pgxv5/go.sum @@ -1,4 +1,4 @@ -github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/DATA-DOG/go-sqlmock v1.5.1/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -11,12 +11,13 @@ github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5ey 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/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA= -github.com/jackc/pgx/v5 v5.5.0 h1:NxstgwndsTRy7eq9/kqYc/BZh5w2hHJV86wjvO+1xPw= -github.com/jackc/pgx/v5 v5.5.0/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA= +github.com/jackc/pgx/v5 v5.5.1 h1:5I9etrGkLrN+2XPCsi6XLlV5DITbSL/xBZdmAxFcXPI= +github.com/jackc/pgx/v5 v5.5.1/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA= github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk= github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= diff --git a/drivers/pgxv5/go.work b/drivers/pgxv5/go.work new file mode 100644 index 0000000..11d684b --- /dev/null +++ b/drivers/pgxv5/go.work @@ -0,0 +1,6 @@ +go 1.21 + +use . + +replace github.com/avito-tech/go-transaction-manager/v2 => ../../ + diff --git a/drivers/sql/go.mod b/drivers/sql/go.mod index 92569d0..7956866 100644 --- a/drivers/sql/go.mod +++ b/drivers/sql/go.mod @@ -3,7 +3,7 @@ module github.com/avito-tech/go-transaction-manager/drivers/sql/v2 go 1.13 require ( - github.com/DATA-DOG/go-sqlmock v1.5.0 + github.com/DATA-DOG/go-sqlmock v1.5.1 github.com/avito-tech/go-transaction-manager/v2 v2.0.0 github.com/golang/mock v1.6.0 github.com/mattn/go-sqlite3 v1.14.18 diff --git a/drivers/sql/go.sum b/drivers/sql/go.sum index d42c0bb..b125e85 100644 --- a/drivers/sql/go.sum +++ b/drivers/sql/go.sum @@ -1,5 +1,5 @@ -github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= -github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/DATA-DOG/go-sqlmock v1.5.1 h1:FK6RCIUSfmbnI/imIICmboyQBkOckutaa6R5YYlLZyo= +github.com/DATA-DOG/go-sqlmock v1.5.1/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -9,6 +9,7 @@ github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= diff --git a/drivers/sql/go.work b/drivers/sql/go.work new file mode 100644 index 0000000..180619c --- /dev/null +++ b/drivers/sql/go.work @@ -0,0 +1,5 @@ +go 1.21 + +use . + +replace github.com/avito-tech/go-transaction-manager/v2 => ../../ diff --git a/drivers/sqlx/go.mod b/drivers/sqlx/go.mod index ad13e74..459a48f 100644 --- a/drivers/sqlx/go.mod +++ b/drivers/sqlx/go.mod @@ -3,7 +3,7 @@ module github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2 go 1.13 require ( - github.com/DATA-DOG/go-sqlmock v1.5.0 + github.com/DATA-DOG/go-sqlmock v1.5.1 github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 github.com/avito-tech/go-transaction-manager/v2 v2.0.0 github.com/jmoiron/sqlx v1.3.5 diff --git a/drivers/sqlx/go.sum b/drivers/sqlx/go.sum index 32399e0..55f2b45 100644 --- a/drivers/sqlx/go.sum +++ b/drivers/sqlx/go.sum @@ -1,5 +1,5 @@ -github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= -github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/DATA-DOG/go-sqlmock v1.5.1 h1:FK6RCIUSfmbnI/imIICmboyQBkOckutaa6R5YYlLZyo= +github.com/DATA-DOG/go-sqlmock v1.5.1/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -11,6 +11,7 @@ github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+Licev github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= diff --git a/drivers/sqlx/go.work b/drivers/sqlx/go.work new file mode 100644 index 0000000..c27816b --- /dev/null +++ b/drivers/sqlx/go.work @@ -0,0 +1,7 @@ +go 1.21 + +use . + +replace github.com/avito-tech/go-transaction-manager/v2 => ../../ +replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 => ../sql + diff --git a/go.mod b/go.mod index e1dcbae..1592f45 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/avito-tech/go-transaction-manager/v2 go 1.13 require ( - github.com/DATA-DOG/go-sqlmock v1.5.0 + github.com/DATA-DOG/go-sqlmock v1.5.1 github.com/golang/mock v1.6.0 github.com/jinzhu/copier v0.4.0 github.com/jmoiron/sqlx v1.3.5 diff --git a/go.sum b/go.sum index ebcc7eb..e9412bc 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= -github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/DATA-DOG/go-sqlmock v1.5.1 h1:FK6RCIUSfmbnI/imIICmboyQBkOckutaa6R5YYlLZyo= +github.com/DATA-DOG/go-sqlmock v1.5.1/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -12,6 +12,7 @@ github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8= github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g= github.com/jmoiron/sqlx v1.3.5/go.mod h1:nRVWtLre0KfCLJvgxzCsLVMogSvQ1zNJtpYr2Ccp0mQ= +github.com/kisielk/sqlstruct v0.0.0-20201105191214-5f3e10d3ab46/go.mod h1:yyMNCyc/Ib3bDTKd379tNMpB/7/H5TjM2Y9QJ5THLbE= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= From 5e6beac27aeabac69ddaa4802abcdc592078ac06 Mon Sep 17 00:00:00 2001 From: iasergunin Date: Sat, 9 Dec 2023 06:34:47 +0300 Subject: [PATCH 05/13] 1. Fixed codecoverage --- .github/workflows/main.yaml | 2 +- .gitignore | 1 + Makefile | 16 ++++++++-------- internal/cover/nested/cover.build.sh | 21 +++++++++++++++++++++ sh/go.mod.tidy.sh | 2 ++ sh/go.mod.vendor.sh | 2 ++ sh/go.test.coverage.sh | 14 ++++++++++++++ sh/go.test.sh | 14 ++++++++++---- sh/utils/drivers.sh | 5 +++++ 9 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 internal/cover/nested/cover.build.sh mode change 100644 => 100755 sh/go.mod.tidy.sh mode change 100644 => 100755 sh/go.mod.vendor.sh create mode 100755 sh/go.test.coverage.sh mode change 100644 => 100755 sh/go.test.sh create mode 100755 sh/utils/drivers.sh diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6c327e0..a04f342 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -115,7 +115,7 @@ jobs: - name: Code coverage data run: | set -x - COVERAGE_TOTAL=`go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+'` + COVERAGE_TOTAL=`go tool covdata func -i=./coverage | grep total | grep -Eo '[0-9]+\.[0-9]+'` echo "COVERAGE_TOTAL=$COVERAGE_TOTAL" >> $GITHUB_ENV - uses: jandelgado/gcov2lcov-action@v1.0.9 with: diff --git a/.gitignore b/.gitignore index 3bb6dc3..6e206e7 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ vendor/ # Code coverage coverage.* +coverage/ diff --git a/Makefile b/Makefile index be253c4..eeacff7 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,21 @@ -GO_TEST=cd ./sh && sh ./go.test.sh -GO_TEST_WITH_REAL_DB=$(GO_TEST) --tags=with_real_db - DIR=$(PWD) -COVERAGE_FILE=`echo $(DIR)/coverage.out` + +GO_TEST=cd ./sh && bash ./go.test.sh +GO_TEST_COVERAGE=cd ./sh && bash ./go.test.coverage.sh + +GO_TEST_WITH_REAL_DB=--tags=with_real_db test: $(GO_TEST) test.with_real_db: - $(GO_TEST_WITH_REAL_DB) + $(GO_TEST) $(GO_TEST_WITH_REAL_DB) -# TODO see in https://gist.github.com/skarllot/13ebe8220822bc19494c8b076aabe9fc test.coverage: - $(GO_TEST) -covermode=atomic -coverprofile=$(COVERAGE_FILE) + $(GO_TEST_COVERAGE) test.coverage.with_real_db: - $(GO_TEST_WITH_REAL_DB) -covermode=atomic -coverprofile=$(COVERAGE_FILE) + $(GO_TEST_COVERAGE) $(GO_TEST_WITH_REAL_DB) fmt: go fmt ./... diff --git a/internal/cover/nested/cover.build.sh b/internal/cover/nested/cover.build.sh new file mode 100644 index 0000000..0d55b8b --- /dev/null +++ b/internal/cover/nested/cover.build.sh @@ -0,0 +1,21 @@ +cd ./module1/cmd + +mkdir -p codecov + +go build -cover -o run.exe . +GOCOVERDIR=./codecov ./run.exe + +# go test ./... -covermode=atomic -coverprofile=coverage.out + +cd ../../module2/cmd + +mkdir -p codecov + +go build -cover -o run.exe . +GOCOVERDIR=./codecov ./run.exe + +# go test ./... -covermode=atomic -coverprofile=coverage.out + +cd ../../ + +go tool covdata textfmt -i=module1/cmd/codecov,module2/cmd/codecov -o ./output.out \ No newline at end of file diff --git a/sh/go.mod.tidy.sh b/sh/go.mod.tidy.sh old mode 100644 new mode 100755 index 5a402ad..2bdf7e4 --- a/sh/go.mod.tidy.sh +++ b/sh/go.mod.tidy.sh @@ -1,3 +1,5 @@ +#!/bin/bash + cd ../ ROOT=$(pwd) diff --git a/sh/go.mod.vendor.sh b/sh/go.mod.vendor.sh old mode 100644 new mode 100755 index 9797e77..180b8fc --- a/sh/go.mod.vendor.sh +++ b/sh/go.mod.vendor.sh @@ -1,3 +1,5 @@ +#!/bin/bash + cd ../ ROOT=$(pwd) diff --git a/sh/go.test.coverage.sh b/sh/go.test.coverage.sh new file mode 100755 index 0000000..53b75cb --- /dev/null +++ b/sh/go.test.coverage.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +DIR=$(pwd) +ROOT="$(pwd)/.." + +COVERAGE_TEST="-cover -covermode=atomic -test.gocoverdir=$ROOT/coverage" + +drivers=("$($DIR/utils/drivers.sh)") + +mkdir -p $ROOT/coverage + +./go.test.sh $COVERAGE_TEST "$@" + +go tool covdata textfmt -i="$ROOT/coverage" -o "$ROOT/coverage.out" diff --git a/sh/go.test.sh b/sh/go.test.sh old mode 100644 new mode 100755 index d14c676..9d9723e --- a/sh/go.test.sh +++ b/sh/go.test.sh @@ -1,3 +1,9 @@ +#!/bin/bash + +DIR=$(pwd) + +drivers=("$($DIR/utils/drivers.sh)") + cd ../ ROOT=$(pwd) @@ -9,16 +15,16 @@ golist() { gotest() { cd $driver - go test $(golist) -race "$@" + go test $(golist) "$@" cd $ROOT } -go test $(golist) -race "$@" +go test $(golist) $@ & -for driver in ./drivers/*; do +for driver in $drivers; do if [ -d "$driver" ]; then - gotest "$@" & + gotest $@ & fi done diff --git a/sh/utils/drivers.sh b/sh/utils/drivers.sh new file mode 100755 index 0000000..2f63581 --- /dev/null +++ b/sh/utils/drivers.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cd ../ + +echo drivers/* From d4bf46e1a5295e17ee4b7ecb571716469a942320 Mon Sep 17 00:00:00 2001 From: iasergunin Date: Sat, 9 Dec 2023 07:28:11 +0300 Subject: [PATCH 06/13] 1. Fixed coverage db --- .github/workflows/main.yaml | 8 +++----- sh/go.test.coverage.sh | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index a04f342..51c5d9d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -117,14 +117,12 @@ jobs: set -x COVERAGE_TOTAL=`go tool covdata func -i=./coverage | grep total | grep -Eo '[0-9]+\.[0-9]+'` echo "COVERAGE_TOTAL=$COVERAGE_TOTAL" >> $GITHUB_ENV - - uses: jandelgado/gcov2lcov-action@v1.0.9 - with: - outfile: ./coverage.lcov - name: Coveralls - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@v2 with: - path-to-lcov: ./coverage.lcov + format: golang + file: ./coverage.out github-token: ${{ secrets.GITHUB_TOKEN }} golangci: diff --git a/sh/go.test.coverage.sh b/sh/go.test.coverage.sh index 53b75cb..d48284b 100755 --- a/sh/go.test.coverage.sh +++ b/sh/go.test.coverage.sh @@ -11,4 +11,4 @@ mkdir -p $ROOT/coverage ./go.test.sh $COVERAGE_TEST "$@" -go tool covdata textfmt -i="$ROOT/coverage" -o "$ROOT/coverage.out" +go tool covdata textfmt -i="$ROOT/coverage" -o "$ROOT/coverage.out" \ No newline at end of file From bcb8fed57f7980103c74bb1cabcbfc755561b66a Mon Sep 17 00:00:00 2001 From: iasergunin Date: Sat, 9 Dec 2023 23:01:09 +0300 Subject: [PATCH 07/13] 1. rename drivers to db 2. try to use workspace to simple local development --- .github/workflows/main.yaml | 2 +- .golangci.yml | 6 +- README.md | 66 ++++++++++++------- {drivers => dbs}/go-redis-v8/context.go | 0 {drivers => dbs}/go-redis-v8/example_test.go | 2 +- {drivers => dbs}/go-redis-v8/factory.go | 0 {drivers => dbs}/go-redis-v8/go.mod | 3 +- {drivers => dbs}/go-redis-v8/go.sum | 0 {drivers => dbs}/go-redis-v8/go.work | 0 {drivers => dbs}/go-redis-v8/option.go | 0 .../go-redis-v8/readonly_func_without_tx.go | 0 .../readonly_func_without_tx_test.go | 0 {drivers => dbs}/go-redis-v8/settings.go | 0 {drivers => dbs}/go-redis-v8/transaction.go | 0 .../go-redis-v8/transaction_test.go | 0 {drivers => dbs}/go-redis-v8/watcher.go | 0 {drivers => dbs}/go-redis-v8/watcher_test.go | 2 +- {drivers => dbs}/gorm/context.go | 0 {drivers => dbs}/gorm/example_test.go | 4 +- {drivers => dbs}/gorm/factory.go | 0 {drivers => dbs}/gorm/go.mod | 5 +- {drivers => dbs}/gorm/go.sum | 0 {drivers => dbs}/gorm/go.work | 0 {drivers => dbs}/gorm/settings.go | 0 {drivers => dbs}/gorm/settings_test.go | 0 {drivers => dbs}/gorm/transaction.go | 0 {drivers => dbs}/gorm/transaction_test.go | 0 {drivers => dbs}/mongo/contract.go | 0 {drivers => dbs}/mongo/example_test.go | 4 +- {drivers => dbs}/mongo/factory.go | 0 dbs/mongo/go.mod | 13 ++++ {drivers => dbs}/mongo/go.sum | 0 {drivers => dbs}/mongo/go.work | 0 {drivers => dbs}/mongo/settings.go | 0 {drivers => dbs}/mongo/settings_test.go | 0 {drivers => dbs}/mongo/transaction.go | 0 {drivers => dbs}/mongo/transaction_test.go | 0 {drivers => dbs}/pgxv4/context.go | 0 {drivers => dbs}/pgxv4/contract.go | 0 {drivers => dbs}/pgxv4/example_test.go | 4 +- {drivers => dbs}/pgxv4/factory.go | 0 {drivers => dbs}/pgxv4/go.mod | 2 +- {drivers => dbs}/pgxv4/go.sum | 0 {drivers => dbs}/pgxv4/go.work | 0 {drivers => dbs}/pgxv4/settings.go | 0 {drivers => dbs}/pgxv4/settings_test.go | 0 {drivers => dbs}/pgxv4/transaction.go | 0 {drivers => dbs}/pgxv4/transaction_test.go | 0 {drivers => dbs}/pgxv5/context.go | 0 {drivers => dbs}/pgxv5/contract.go | 0 {drivers => dbs}/pgxv5/example_test.go | 4 +- {drivers => dbs}/pgxv5/factory.go | 0 {drivers => dbs}/pgxv5/go.mod | 3 +- {drivers => dbs}/pgxv5/go.sum | 0 {drivers => dbs}/pgxv5/go.work | 0 {drivers => dbs}/pgxv5/settings.go | 0 {drivers => dbs}/pgxv5/settings_test.go | 0 {drivers => dbs}/pgxv5/transaction.go | 0 {drivers => dbs}/pgxv5/transaction_test.go | 0 {drivers => dbs}/sql/context.go | 0 {drivers => dbs}/sql/contract.go | 0 {drivers => dbs}/sql/example_test.go | 2 +- {drivers => dbs}/sql/factory.go | 0 dbs/sql/go.mod | 18 +++++ {drivers => dbs}/sql/go.sum | 0 {drivers => dbs}/sql/go.work | 0 {drivers => dbs}/sql/mock/savepoint.go | 0 {drivers => dbs}/sql/savepoint.go | 0 {drivers => dbs}/sql/settings.go | 0 {drivers => dbs}/sql/settings_test.go | 0 {drivers => dbs}/sql/transaction.go | 0 {drivers => dbs}/sql/transaction_test.go | 0 {drivers => dbs}/sqlx/chained_example_test.go | 2 +- {drivers => dbs}/sqlx/context.go | 0 {drivers => dbs}/sqlx/contract.go | 0 {drivers => dbs}/sqlx/example_test.go | 6 +- {drivers => dbs}/sqlx/factory.go | 3 +- {drivers/sql => dbs/sqlx}/go.mod | 6 +- {drivers => dbs}/sqlx/go.sum | 0 {drivers => dbs}/sqlx/go.work | 0 {drivers => dbs}/sqlx/transaction.go | 2 +- {drivers => dbs}/sqlx/transaction_test.go | 0 go.mod | 1 + .../with_or_without_trm/clean_test.go | 2 +- .../benchmark/with_or_without_trm/model.go | 4 +- .../with_or_without_trm/trm_test.go.skip | 2 +- .../with_or_without_trm/trmrepo.go.skip | 2 +- internal/cover/nested/cover.build.sh | 21 ------ sh/go.mod.tidy.sh | 2 +- sh/go.mod.vendor.local.sh | 20 ++++++ sh/go.mod.vendor.sh | 2 +- sh/go.test.coverage.sh | 6 +- sh/go.test.sh | 4 +- sh/utils/{drivers.sh => db.sh} | 2 +- sh/utils/go.mod.dropreplace.default.sh | 6 ++ sh/utils/go.mod.replace.default.sh | 3 + 96 files changed, 145 insertions(+), 91 deletions(-) rename {drivers => dbs}/go-redis-v8/context.go (100%) rename {drivers => dbs}/go-redis-v8/example_test.go (97%) rename {drivers => dbs}/go-redis-v8/factory.go (100%) rename {drivers => dbs}/go-redis-v8/go.mod (56%) rename {drivers => dbs}/go-redis-v8/go.sum (100%) rename {drivers => dbs}/go-redis-v8/go.work (100%) rename {drivers => dbs}/go-redis-v8/option.go (100%) rename {drivers => dbs}/go-redis-v8/readonly_func_without_tx.go (100%) rename {drivers => dbs}/go-redis-v8/readonly_func_without_tx_test.go (100%) rename {drivers => dbs}/go-redis-v8/settings.go (100%) rename {drivers => dbs}/go-redis-v8/transaction.go (100%) rename {drivers => dbs}/go-redis-v8/transaction_test.go (100%) rename {drivers => dbs}/go-redis-v8/watcher.go (100%) rename {drivers => dbs}/go-redis-v8/watcher_test.go (96%) rename {drivers => dbs}/gorm/context.go (100%) rename {drivers => dbs}/gorm/example_test.go (94%) rename {drivers => dbs}/gorm/factory.go (100%) rename {drivers => dbs}/gorm/go.mod (75%) rename {drivers => dbs}/gorm/go.sum (100%) rename {drivers => dbs}/gorm/go.work (100%) rename {drivers => dbs}/gorm/settings.go (100%) rename {drivers => dbs}/gorm/settings_test.go (100%) rename {drivers => dbs}/gorm/transaction.go (100%) rename {drivers => dbs}/gorm/transaction_test.go (100%) rename {drivers => dbs}/mongo/contract.go (100%) rename {drivers => dbs}/mongo/example_test.go (93%) rename {drivers => dbs}/mongo/factory.go (100%) create mode 100644 dbs/mongo/go.mod rename {drivers => dbs}/mongo/go.sum (100%) rename {drivers => dbs}/mongo/go.work (100%) rename {drivers => dbs}/mongo/settings.go (100%) rename {drivers => dbs}/mongo/settings_test.go (100%) rename {drivers => dbs}/mongo/transaction.go (100%) rename {drivers => dbs}/mongo/transaction_test.go (100%) rename {drivers => dbs}/pgxv4/context.go (100%) rename {drivers => dbs}/pgxv4/contract.go (100%) rename {drivers => dbs}/pgxv4/example_test.go (95%) rename {drivers => dbs}/pgxv4/factory.go (100%) rename {drivers => dbs}/pgxv4/go.mod (80%) rename {drivers => dbs}/pgxv4/go.sum (100%) rename {drivers => dbs}/pgxv4/go.work (100%) rename {drivers => dbs}/pgxv4/settings.go (100%) rename {drivers => dbs}/pgxv4/settings_test.go (100%) rename {drivers => dbs}/pgxv4/transaction.go (100%) rename {drivers => dbs}/pgxv4/transaction_test.go (100%) rename {drivers => dbs}/pgxv5/context.go (100%) rename {drivers => dbs}/pgxv5/contract.go (100%) rename {drivers => dbs}/pgxv5/example_test.go (95%) rename {drivers => dbs}/pgxv5/factory.go (100%) rename {drivers => dbs}/pgxv5/go.mod (57%) rename {drivers => dbs}/pgxv5/go.sum (100%) rename {drivers => dbs}/pgxv5/go.work (100%) rename {drivers => dbs}/pgxv5/settings.go (100%) rename {drivers => dbs}/pgxv5/settings_test.go (100%) rename {drivers => dbs}/pgxv5/transaction.go (100%) rename {drivers => dbs}/pgxv5/transaction_test.go (100%) rename {drivers => dbs}/sql/context.go (100%) rename {drivers => dbs}/sql/contract.go (100%) rename {drivers => dbs}/sql/example_test.go (97%) rename {drivers => dbs}/sql/factory.go (100%) create mode 100644 dbs/sql/go.mod rename {drivers => dbs}/sql/go.sum (100%) rename {drivers => dbs}/sql/go.work (100%) rename {drivers => dbs}/sql/mock/savepoint.go (100%) rename {drivers => dbs}/sql/savepoint.go (100%) rename {drivers => dbs}/sql/settings.go (100%) rename {drivers => dbs}/sql/settings_test.go (100%) rename {drivers => dbs}/sql/transaction.go (100%) rename {drivers => dbs}/sql/transaction_test.go (100%) rename {drivers => dbs}/sqlx/chained_example_test.go (96%) rename {drivers => dbs}/sqlx/context.go (100%) rename {drivers => dbs}/sqlx/contract.go (100%) rename {drivers => dbs}/sqlx/example_test.go (95%) rename {drivers => dbs}/sqlx/factory.go (89%) rename {drivers/sql => dbs/sqlx}/go.mod (56%) rename {drivers => dbs}/sqlx/go.sum (100%) rename {drivers => dbs}/sqlx/go.work (100%) rename {drivers => dbs}/sqlx/transaction.go (97%) rename {drivers => dbs}/sqlx/transaction_test.go (100%) delete mode 100644 internal/cover/nested/cover.build.sh create mode 100755 sh/go.mod.vendor.local.sh rename sh/utils/{drivers.sh => db.sh} (58%) create mode 100755 sh/utils/go.mod.dropreplace.default.sh create mode 100755 sh/utils/go.mod.replace.default.sh diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 51c5d9d..8df565d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -68,7 +68,7 @@ jobs: postgres: image: postgres env: - POSTGRES_DB: db + POSTGRES_DB: dbs POSTGRES_USER: user POSTGRES_PASSWORD: pass ports: diff --git a/.golangci.yml b/.golangci.yml index 177a71f..214caba 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -95,14 +95,14 @@ issues: linters: - staticcheck text: "SA1029: should not use built-in type string as key for value; define your own type to avoid collisions" - - path: .+/context\.go + - path: (.+/)?context\.go linters: - ireturn - - path: .+/transaction\.go + - path: (.+/)?transaction\.go linters: - ireturn source: \) Begin\(ctx - - path: .+/settings\.go + - path: (.+/)?settings\.go linters: - ireturn source: "(?:EnrichBy|SetPropagation|SetCtxKey|CtxKey|SetCancelable|SetTimeout)" diff --git a/README.md b/README.md index ef2f006..0e62c83 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ # Go transaction manager -[![Go Reference](https://pkg.go.dev/badge/github.com/avito-tech/go-transaction-manager.svg)](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager) +[![Go Reference](https://pkg.go.dev/badge/github.com/avito-tech/go-transaction-manager.svg)](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/v2) [![Test Status](https://github.com/avito-tech/go-transaction-manager/actions/workflows/main.yaml/badge.svg)](https://github.com/avito-tech/go-transaction-manager/actions?query=branch%3Amain) [![Coverage Status](https://coveralls.io/repos/github/avito-tech/go-transaction-manager/badge.svg?branch=main)](https://coveralls.io/github/avito-tech/go-transaction-manager?branch=main) -[![Go Report Card](https://goreportcard.com/badge/github.com/avito-tech/go-transaction-manager)](https://goreportcard.com/report/github.com/avito-tech/go-transaction-manager) +[![Go Report Card](https://goreportcard.com/badge/github.com/avito-tech/go-transaction-manager)](https://goreportcard.com/report/github.com/avito-tech/go-transaction-manager/v2) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) Transaction manager is an abstraction to coordinate database transaction boundaries. @@ -12,20 +12,31 @@ Easiest way to get the perfect repository. ## Supported implementations -* [database/sql](https://pkg.go.dev/database/sql), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/sql/v2) (Go 1.13) -* [jmoiron/sqlx](https://github.com/jmoiron/sqlx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2) (Go 1.13) -* [gorm](https://github.com/go-gorm/gorm), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/gorm/v2) (Go 1.18) -* [mongo-go-driver](https://github.com/mongodb/mongo-go-driver), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/mongo/v2) (Go 1.13) -* [go-redis/redis](https://github.com/go-redis/redis), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2) (Go 1.17) -* [pgx_v4](https://github.com/jackc/pgx/tree/v4), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2) (Go 1.16) -* [pgx_v5](https://github.com/jackc/pgx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/pgxv5/v2) (Go 1.19) +* [database/sql](https://pkg.go.dev/database/sql), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/db/sql/v2) ( + Go 1.13) +* [jmoiron/sqlx](https://github.com/jmoiron/sqlx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/db/sqlx/v2) ( + Go 1.13) +* [gorm](https://github.com/go-gorm/gorm), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/db/gorm/v2) ( + Go 1.18) +* [mongo-go-driver](https://github.com/mongodb/mongo-go-driver), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/db/mongo/v2) ( + Go 1.13) +* [go-redis/redis](https://github.com/go-redis/redis), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/db/go-redis-v8/v2) ( + Go 1.17) +* [pgx_v4](https://github.com/jackc/pgx/tree/v4), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/db/pgxv4/v2) ( + Go 1.16) +* [pgx_v5](https://github.com/jackc/pgx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/db/pgxv5/v2) ( + Go 1.19) ## Installation ```bash -go get github.com/avito-tech/go-transaction-manager +go get github.com/avito-tech/go-transaction-manager/v2 ``` +To install some support database use `go get github.com/avito-tech/go-transaction-manager/db/{name}/v2`. + +For example `go get github.com/avito-tech/go-transaction-manager/db/sqlx/v2`. + ### Backwards Compatibility The library is compatible with the most recent two versions of Go. @@ -33,9 +44,11 @@ Compatibility beyond that is not guaranteed. ## Usage -**To use multiple transactions from different databases**, you need to set CtxKey in [Settings](trm/settings.go) by [WithCtxKey](settings/option.go). +**To use multiple transactions from different databases**, you need to set CtxKey in [Settings](trm/settings.go) +by [WithCtxKey](settings/option.go). -**For nested transactions with different transaction managers**, you need to use [ChainedMW](manager/chain.go) ([docs](https://pkg.go.dev/github.com/github.com/avito-tech/go-transaction-manager)). +**For nested transactions with different transaction managers**, you need to +use [ChainedMW](manager/chain.go) ([docs](https://pkg.go.dev/github.com/github.com/avito-tech/go-transaction-manager)). **To skip a transaction rollback due to an error, use [ErrSkip](manager.go#L20) or [Skippable](manager.go#L24)** @@ -43,14 +56,13 @@ Compatibility beyond that is not guaranteed. ### Examples with an ideal *repository* and nested transactions. -* [database/sql](drivers/sql/example_test.go) -* [jmoiron/sqlx](drivers/sqlx/example_test.go) -* [gorm](drivers/gorm/example_test.go) -* [mongo-go-driver](drivers/mongo/example_test.go) -* [go-redis/redis](drivers/go-redis-v8/example_test.go) -* [pgx_v4](drivers/pgxv4/example_test.go) -* [pgx_v5](drivers/pgxv5/example_test.go) - +* [database/sql](dbs/sql/example_test.go) +* [jmoiron/sqlx](dbs/sqlx/example_test.go) +* [gorm](dbs/gorm/example_test.go) +* [mongo-go-driver](dbs/mongo/example_test.go) +* [go-redis/redis](dbs/go-redis-v8/example_test.go) +* [pgx_v4](dbs/pgxv4/example_test.go) +* [pgx_v5](dbs/pgxv5/example_test.go) Below is an example how to start usage. @@ -64,7 +76,7 @@ import ( "github.com/jmoiron/sqlx" _ "github.com/mattn/go-sqlite3" - trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" + trmsqlx "github.com/avito-tech/go-transaction-manager/dbs/sqlx/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" ) @@ -85,6 +97,7 @@ func main() { err = trManager.Do(ctx, func(ctx context.Context) error { checkErr(r.Save(ctx, u)) + // example of nested transactions return trManager.Do(ctx, func(ctx context.Context) error { u.Username = "new_username" return r.Save(ctx, u) @@ -114,8 +127,8 @@ func newRepo(db *sqlx.DB, c *trmsqlx.CtxGetter) *repo { } type user struct { - ID int64 `db:"user_id"` - Username string `db:"username"` + ID int64 `dbs:"user_id"` + Username string `dbs:"username"` } func (r *repo) GetByID(ctx context.Context, id int64) (*user, error) { @@ -146,4 +159,9 @@ func (r *repo) Save(ctx context.Context, u *user) error { ## Benchmark -[Comparing](internal/benchmark/with_or_without_trm/README.md) examples with and without trm. \ No newline at end of file +[Comparing](internal/benchmark/with_or_without_trm/README.md) examples with and without trm. + +## Contribution + +* To install all dependencies use `make go.mod.vendor`. +* To run all tests use `make go.test` or `make go.test.with_real_db` for integration tests. \ No newline at end of file diff --git a/drivers/go-redis-v8/context.go b/dbs/go-redis-v8/context.go similarity index 100% rename from drivers/go-redis-v8/context.go rename to dbs/go-redis-v8/context.go diff --git a/drivers/go-redis-v8/example_test.go b/dbs/go-redis-v8/example_test.go similarity index 97% rename from drivers/go-redis-v8/example_test.go rename to dbs/go-redis-v8/example_test.go index 38be219..2ff5b1d 100644 --- a/drivers/go-redis-v8/example_test.go +++ b/dbs/go-redis-v8/example_test.go @@ -14,7 +14,7 @@ import ( "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" - trmredis "github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2" + trmredis "github.com/avito-tech/go-transaction-manager/db/go-redis-v8/v2" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. diff --git a/drivers/go-redis-v8/factory.go b/dbs/go-redis-v8/factory.go similarity index 100% rename from drivers/go-redis-v8/factory.go rename to dbs/go-redis-v8/factory.go diff --git a/drivers/go-redis-v8/go.mod b/dbs/go-redis-v8/go.mod similarity index 56% rename from drivers/go-redis-v8/go.mod rename to dbs/go-redis-v8/go.mod index db2dadb..6127b82 100644 --- a/drivers/go-redis-v8/go.mod +++ b/dbs/go-redis-v8/go.mod @@ -1,4 +1,4 @@ -module github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2 +module github.com/avito-tech/go-transaction-manager/db/go-redis-v8/v2 go 1.13 @@ -9,4 +9,3 @@ require ( github.com/stretchr/testify v1.8.2 ) -replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ diff --git a/drivers/go-redis-v8/go.sum b/dbs/go-redis-v8/go.sum similarity index 100% rename from drivers/go-redis-v8/go.sum rename to dbs/go-redis-v8/go.sum diff --git a/drivers/go-redis-v8/go.work b/dbs/go-redis-v8/go.work similarity index 100% rename from drivers/go-redis-v8/go.work rename to dbs/go-redis-v8/go.work diff --git a/drivers/go-redis-v8/option.go b/dbs/go-redis-v8/option.go similarity index 100% rename from drivers/go-redis-v8/option.go rename to dbs/go-redis-v8/option.go diff --git a/drivers/go-redis-v8/readonly_func_without_tx.go b/dbs/go-redis-v8/readonly_func_without_tx.go similarity index 100% rename from drivers/go-redis-v8/readonly_func_without_tx.go rename to dbs/go-redis-v8/readonly_func_without_tx.go diff --git a/drivers/go-redis-v8/readonly_func_without_tx_test.go b/dbs/go-redis-v8/readonly_func_without_tx_test.go similarity index 100% rename from drivers/go-redis-v8/readonly_func_without_tx_test.go rename to dbs/go-redis-v8/readonly_func_without_tx_test.go diff --git a/drivers/go-redis-v8/settings.go b/dbs/go-redis-v8/settings.go similarity index 100% rename from drivers/go-redis-v8/settings.go rename to dbs/go-redis-v8/settings.go diff --git a/drivers/go-redis-v8/transaction.go b/dbs/go-redis-v8/transaction.go similarity index 100% rename from drivers/go-redis-v8/transaction.go rename to dbs/go-redis-v8/transaction.go diff --git a/drivers/go-redis-v8/transaction_test.go b/dbs/go-redis-v8/transaction_test.go similarity index 100% rename from drivers/go-redis-v8/transaction_test.go rename to dbs/go-redis-v8/transaction_test.go diff --git a/drivers/go-redis-v8/watcher.go b/dbs/go-redis-v8/watcher.go similarity index 100% rename from drivers/go-redis-v8/watcher.go rename to dbs/go-redis-v8/watcher.go diff --git a/drivers/go-redis-v8/watcher_test.go b/dbs/go-redis-v8/watcher_test.go similarity index 96% rename from drivers/go-redis-v8/watcher_test.go rename to dbs/go-redis-v8/watcher_test.go index b5ae0a7..09139d8 100644 --- a/drivers/go-redis-v8/watcher_test.go +++ b/dbs/go-redis-v8/watcher_test.go @@ -13,7 +13,7 @@ import ( "github.com/avito-tech/go-transaction-manager/v2/settings" "github.com/go-redis/redis/v8" - trmredis "github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2" + trmredis "github.com/avito-tech/go-transaction-manager/db/go-redis-v8/v2" ) // Example demonstrates the watching of updated keys. diff --git a/drivers/gorm/context.go b/dbs/gorm/context.go similarity index 100% rename from drivers/gorm/context.go rename to dbs/gorm/context.go diff --git a/drivers/gorm/example_test.go b/dbs/gorm/example_test.go similarity index 94% rename from drivers/gorm/example_test.go rename to dbs/gorm/example_test.go index 83a5b17..11e1189 100644 --- a/drivers/gorm/example_test.go +++ b/dbs/gorm/example_test.go @@ -11,7 +11,7 @@ import ( "gorm.io/driver/sqlite" "gorm.io/gorm" - trmgorm "github.com/avito-tech/go-transaction-manager/drivers/gorm/v2" + trmgorm "github.com/avito-tech/go-transaction-manager/db/gorm/v2" trm "github.com/avito-tech/go-transaction-manager/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" @@ -19,7 +19,7 @@ import ( // Example demonstrates the implementation of the Repository pattern by trm.Manager. func Example() { - db, err := gorm.Open(sqlite.Open("file:test.db?mode=memory")) + db, err := gorm.Open(sqlite.Open("file:test.dbs?mode=memory")) checkErr(err) // Migrate the schema diff --git a/drivers/gorm/factory.go b/dbs/gorm/factory.go similarity index 100% rename from drivers/gorm/factory.go rename to dbs/gorm/factory.go diff --git a/drivers/gorm/go.mod b/dbs/gorm/go.mod similarity index 75% rename from drivers/gorm/go.mod rename to dbs/gorm/go.mod index 0d2b0d9..9584aa0 100644 --- a/drivers/gorm/go.mod +++ b/dbs/gorm/go.mod @@ -1,4 +1,4 @@ -module github.com/avito-tech/go-transaction-manager/drivers/gorm/v2 +module github.com/avito-tech/go-transaction-manager/db/gorm/v2 go 1.18 @@ -24,6 +24,3 @@ require ( gopkg.in/yaml.v3 v3.0.1 // indirect ) -replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 => ../sql - -replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ diff --git a/drivers/gorm/go.sum b/dbs/gorm/go.sum similarity index 100% rename from drivers/gorm/go.sum rename to dbs/gorm/go.sum diff --git a/drivers/gorm/go.work b/dbs/gorm/go.work similarity index 100% rename from drivers/gorm/go.work rename to dbs/gorm/go.work diff --git a/drivers/gorm/settings.go b/dbs/gorm/settings.go similarity index 100% rename from drivers/gorm/settings.go rename to dbs/gorm/settings.go diff --git a/drivers/gorm/settings_test.go b/dbs/gorm/settings_test.go similarity index 100% rename from drivers/gorm/settings_test.go rename to dbs/gorm/settings_test.go diff --git a/drivers/gorm/transaction.go b/dbs/gorm/transaction.go similarity index 100% rename from drivers/gorm/transaction.go rename to dbs/gorm/transaction.go diff --git a/drivers/gorm/transaction_test.go b/dbs/gorm/transaction_test.go similarity index 100% rename from drivers/gorm/transaction_test.go rename to dbs/gorm/transaction_test.go diff --git a/drivers/mongo/contract.go b/dbs/mongo/contract.go similarity index 100% rename from drivers/mongo/contract.go rename to dbs/mongo/contract.go diff --git a/drivers/mongo/example_test.go b/dbs/mongo/example_test.go similarity index 93% rename from drivers/mongo/example_test.go rename to dbs/mongo/example_test.go index ec19556..cb25ede 100644 --- a/drivers/mongo/example_test.go +++ b/dbs/mongo/example_test.go @@ -12,12 +12,12 @@ import ( "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" + trmsql "github.com/avito-tech/go-transaction-manager/dbs/sql/v2" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" "github.com/avito-tech/go-transaction-manager/v2/manager" - trmmongo "github.com/avito-tech/go-transaction-manager/drivers/mongo/v2" + trmmongo "github.com/avito-tech/go-transaction-manager/db/mongo/v2" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. diff --git a/drivers/mongo/factory.go b/dbs/mongo/factory.go similarity index 100% rename from drivers/mongo/factory.go rename to dbs/mongo/factory.go diff --git a/dbs/mongo/go.mod b/dbs/mongo/go.mod new file mode 100644 index 0000000..9ed1203 --- /dev/null +++ b/dbs/mongo/go.mod @@ -0,0 +1,13 @@ +module github.com/avito-tech/go-transaction-manager/db/mongo/v2 + +go 1.13 + +require ( + github.com/avito-tech/go-transaction-manager/db/sql/v2 v2.0.0 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/mattn/go-sqlite3 v1.14.18 + github.com/stretchr/testify v1.8.2 + go.mongodb.org/mongo-driver v1.12.1 +) + + diff --git a/drivers/mongo/go.sum b/dbs/mongo/go.sum similarity index 100% rename from drivers/mongo/go.sum rename to dbs/mongo/go.sum diff --git a/drivers/mongo/go.work b/dbs/mongo/go.work similarity index 100% rename from drivers/mongo/go.work rename to dbs/mongo/go.work diff --git a/drivers/mongo/settings.go b/dbs/mongo/settings.go similarity index 100% rename from drivers/mongo/settings.go rename to dbs/mongo/settings.go diff --git a/drivers/mongo/settings_test.go b/dbs/mongo/settings_test.go similarity index 100% rename from drivers/mongo/settings_test.go rename to dbs/mongo/settings_test.go diff --git a/drivers/mongo/transaction.go b/dbs/mongo/transaction.go similarity index 100% rename from drivers/mongo/transaction.go rename to dbs/mongo/transaction.go diff --git a/drivers/mongo/transaction_test.go b/dbs/mongo/transaction_test.go similarity index 100% rename from drivers/mongo/transaction_test.go rename to dbs/mongo/transaction_test.go diff --git a/drivers/pgxv4/context.go b/dbs/pgxv4/context.go similarity index 100% rename from drivers/pgxv4/context.go rename to dbs/pgxv4/context.go diff --git a/drivers/pgxv4/contract.go b/dbs/pgxv4/contract.go similarity index 100% rename from drivers/pgxv4/contract.go rename to dbs/pgxv4/contract.go diff --git a/drivers/pgxv4/example_test.go b/dbs/pgxv4/example_test.go similarity index 95% rename from drivers/pgxv4/example_test.go rename to dbs/pgxv4/example_test.go index 8711af2..d8c5413 100644 --- a/drivers/pgxv4/example_test.go +++ b/dbs/pgxv4/example_test.go @@ -9,7 +9,7 @@ import ( "github.com/jackc/pgx/v4/pgxpool" - trmpgx "github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2" + trmpgx "github.com/avito-tech/go-transaction-manager/db/pgxv4/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" ) @@ -18,7 +18,7 @@ func Example() { ctx := context.Background() uri := fmt.Sprintf("postgres://%s:%s@%s:%d/%s", - "user", "pass", "localhost", 5432, "db", + "user", "pass", "localhost", 5432, "dbs", ) pool, err := pgxpool.Connect(ctx, uri) diff --git a/drivers/pgxv4/factory.go b/dbs/pgxv4/factory.go similarity index 100% rename from drivers/pgxv4/factory.go rename to dbs/pgxv4/factory.go diff --git a/drivers/pgxv4/go.mod b/dbs/pgxv4/go.mod similarity index 80% rename from drivers/pgxv4/go.mod rename to dbs/pgxv4/go.mod index dd30b5a..4d3d35b 100644 --- a/drivers/pgxv4/go.mod +++ b/dbs/pgxv4/go.mod @@ -1,4 +1,4 @@ -module github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2 +module github.com/avito-tech/go-transaction-manager/db/pgxv4/v2 go 1.13 diff --git a/drivers/pgxv4/go.sum b/dbs/pgxv4/go.sum similarity index 100% rename from drivers/pgxv4/go.sum rename to dbs/pgxv4/go.sum diff --git a/drivers/pgxv4/go.work b/dbs/pgxv4/go.work similarity index 100% rename from drivers/pgxv4/go.work rename to dbs/pgxv4/go.work diff --git a/drivers/pgxv4/settings.go b/dbs/pgxv4/settings.go similarity index 100% rename from drivers/pgxv4/settings.go rename to dbs/pgxv4/settings.go diff --git a/drivers/pgxv4/settings_test.go b/dbs/pgxv4/settings_test.go similarity index 100% rename from drivers/pgxv4/settings_test.go rename to dbs/pgxv4/settings_test.go diff --git a/drivers/pgxv4/transaction.go b/dbs/pgxv4/transaction.go similarity index 100% rename from drivers/pgxv4/transaction.go rename to dbs/pgxv4/transaction.go diff --git a/drivers/pgxv4/transaction_test.go b/dbs/pgxv4/transaction_test.go similarity index 100% rename from drivers/pgxv4/transaction_test.go rename to dbs/pgxv4/transaction_test.go diff --git a/drivers/pgxv5/context.go b/dbs/pgxv5/context.go similarity index 100% rename from drivers/pgxv5/context.go rename to dbs/pgxv5/context.go diff --git a/drivers/pgxv5/contract.go b/dbs/pgxv5/contract.go similarity index 100% rename from drivers/pgxv5/contract.go rename to dbs/pgxv5/contract.go diff --git a/drivers/pgxv5/example_test.go b/dbs/pgxv5/example_test.go similarity index 95% rename from drivers/pgxv5/example_test.go rename to dbs/pgxv5/example_test.go index e1cb83b..baf8dc8 100644 --- a/drivers/pgxv5/example_test.go +++ b/dbs/pgxv5/example_test.go @@ -9,7 +9,7 @@ import ( "github.com/jackc/pgx/v5/pgxpool" - trmpgx "github.com/avito-tech/go-transaction-manager/drivers/pgxv5/v2" + trmpgx "github.com/avito-tech/go-transaction-manager/db/pgxv5/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" ) @@ -18,7 +18,7 @@ func Example() { ctx := context.Background() uri := fmt.Sprintf("postgres://%s:%s@%s:%d/%s", - "user", "pass", "localhost", 5432, "db", + "user", "pass", "localhost", 5432, "dbs", ) pool, err := pgxpool.New(ctx, uri) diff --git a/drivers/pgxv5/factory.go b/dbs/pgxv5/factory.go similarity index 100% rename from drivers/pgxv5/factory.go rename to dbs/pgxv5/factory.go diff --git a/drivers/pgxv5/go.mod b/dbs/pgxv5/go.mod similarity index 57% rename from drivers/pgxv5/go.mod rename to dbs/pgxv5/go.mod index 983073c..a5445a2 100644 --- a/drivers/pgxv5/go.mod +++ b/dbs/pgxv5/go.mod @@ -1,4 +1,4 @@ -module github.com/avito-tech/go-transaction-manager/drivers/pgxv5/v2 +module github.com/avito-tech/go-transaction-manager/db/pgxv5/v2 go 1.13 @@ -9,4 +9,3 @@ require ( github.com/stretchr/testify v1.8.2 ) -replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ diff --git a/drivers/pgxv5/go.sum b/dbs/pgxv5/go.sum similarity index 100% rename from drivers/pgxv5/go.sum rename to dbs/pgxv5/go.sum diff --git a/drivers/pgxv5/go.work b/dbs/pgxv5/go.work similarity index 100% rename from drivers/pgxv5/go.work rename to dbs/pgxv5/go.work diff --git a/drivers/pgxv5/settings.go b/dbs/pgxv5/settings.go similarity index 100% rename from drivers/pgxv5/settings.go rename to dbs/pgxv5/settings.go diff --git a/drivers/pgxv5/settings_test.go b/dbs/pgxv5/settings_test.go similarity index 100% rename from drivers/pgxv5/settings_test.go rename to dbs/pgxv5/settings_test.go diff --git a/drivers/pgxv5/transaction.go b/dbs/pgxv5/transaction.go similarity index 100% rename from drivers/pgxv5/transaction.go rename to dbs/pgxv5/transaction.go diff --git a/drivers/pgxv5/transaction_test.go b/dbs/pgxv5/transaction_test.go similarity index 100% rename from drivers/pgxv5/transaction_test.go rename to dbs/pgxv5/transaction_test.go diff --git a/drivers/sql/context.go b/dbs/sql/context.go similarity index 100% rename from drivers/sql/context.go rename to dbs/sql/context.go diff --git a/drivers/sql/contract.go b/dbs/sql/contract.go similarity index 100% rename from drivers/sql/contract.go rename to dbs/sql/contract.go diff --git a/drivers/sql/example_test.go b/dbs/sql/example_test.go similarity index 97% rename from drivers/sql/example_test.go rename to dbs/sql/example_test.go index ab3bd87..b85a070 100644 --- a/drivers/sql/example_test.go +++ b/dbs/sql/example_test.go @@ -7,7 +7,7 @@ import ( _ "github.com/mattn/go-sqlite3" - trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" + trmsql "github.com/avito-tech/go-transaction-manager/db/sql/v2" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" "github.com/avito-tech/go-transaction-manager/v2/manager" diff --git a/drivers/sql/factory.go b/dbs/sql/factory.go similarity index 100% rename from drivers/sql/factory.go rename to dbs/sql/factory.go diff --git a/dbs/sql/go.mod b/dbs/sql/go.mod new file mode 100644 index 0000000..1f387e6 --- /dev/null +++ b/dbs/sql/go.mod @@ -0,0 +1,18 @@ +module github.com/avito-tech/go-transaction-manager/db/sql/v2 + +go 1.13 + +require ( + github.com/DATA-DOG/go-sqlmock v1.5.0 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/golang/mock v1.6.0 + github.com/mattn/go-sqlite3 v1.14.18 + github.com/stretchr/testify v1.8.2 + go.uber.org/multierr v1.9.0 +) + +// go mod edit -replace=github.com/avito-tech/go-transaction-manager/v2=../../ +// go get github.com/avito-tech/go-transaction-manager/v2 +// go mod edit -dropreplace=github.com/avito-tech/go-transaction-manager/v2 + +// replace github.com/avito-tech/go-transaction-manager/v2 => ../../ diff --git a/drivers/sql/go.sum b/dbs/sql/go.sum similarity index 100% rename from drivers/sql/go.sum rename to dbs/sql/go.sum diff --git a/drivers/sql/go.work b/dbs/sql/go.work similarity index 100% rename from drivers/sql/go.work rename to dbs/sql/go.work diff --git a/drivers/sql/mock/savepoint.go b/dbs/sql/mock/savepoint.go similarity index 100% rename from drivers/sql/mock/savepoint.go rename to dbs/sql/mock/savepoint.go diff --git a/drivers/sql/savepoint.go b/dbs/sql/savepoint.go similarity index 100% rename from drivers/sql/savepoint.go rename to dbs/sql/savepoint.go diff --git a/drivers/sql/settings.go b/dbs/sql/settings.go similarity index 100% rename from drivers/sql/settings.go rename to dbs/sql/settings.go diff --git a/drivers/sql/settings_test.go b/dbs/sql/settings_test.go similarity index 100% rename from drivers/sql/settings_test.go rename to dbs/sql/settings_test.go diff --git a/drivers/sql/transaction.go b/dbs/sql/transaction.go similarity index 100% rename from drivers/sql/transaction.go rename to dbs/sql/transaction.go diff --git a/drivers/sql/transaction_test.go b/dbs/sql/transaction_test.go similarity index 100% rename from drivers/sql/transaction_test.go rename to dbs/sql/transaction_test.go diff --git a/drivers/sqlx/chained_example_test.go b/dbs/sqlx/chained_example_test.go similarity index 96% rename from drivers/sqlx/chained_example_test.go rename to dbs/sqlx/chained_example_test.go index b863503..c522727 100644 --- a/drivers/sqlx/chained_example_test.go +++ b/dbs/sqlx/chained_example_test.go @@ -6,7 +6,7 @@ import ( _ "github.com/mattn/go-sqlite3" - trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" + trmsqlx "github.com/avito-tech/go-transaction-manager/db/sqlx/v2" trm "github.com/avito-tech/go-transaction-manager/v2" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" diff --git a/drivers/sqlx/context.go b/dbs/sqlx/context.go similarity index 100% rename from drivers/sqlx/context.go rename to dbs/sqlx/context.go diff --git a/drivers/sqlx/contract.go b/dbs/sqlx/contract.go similarity index 100% rename from drivers/sqlx/contract.go rename to dbs/sqlx/contract.go diff --git a/drivers/sqlx/example_test.go b/dbs/sqlx/example_test.go similarity index 95% rename from drivers/sqlx/example_test.go rename to dbs/sqlx/example_test.go index c9132dc..2852b7c 100644 --- a/drivers/sqlx/example_test.go +++ b/dbs/sqlx/example_test.go @@ -7,7 +7,7 @@ import ( "github.com/jmoiron/sqlx" _ "github.com/mattn/go-sqlite3" - trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" + trmsqlx "github.com/avito-tech/go-transaction-manager/db/sqlx/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" ) @@ -76,8 +76,8 @@ type user struct { } type userRow struct { - ID int64 `db:"user_id"` - Username string `db:"username"` + ID int64 `dbs:"user_id"` + Username string `dbs:"username"` } func (r *repo) GetByID(ctx context.Context, id int64) (*user, error) { diff --git a/drivers/sqlx/factory.go b/dbs/sqlx/factory.go similarity index 89% rename from drivers/sqlx/factory.go rename to dbs/sqlx/factory.go index 6a39487..ebac15a 100644 --- a/drivers/sqlx/factory.go +++ b/dbs/sqlx/factory.go @@ -5,7 +5,8 @@ import ( "github.com/jmoiron/sqlx" - trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" + trmsql "github.com/avito-tech/go-transaction-manager/dbs/sql/v2" + trm "github.com/avito-tech/go-transaction-manager/v2" ) diff --git a/drivers/sql/go.mod b/dbs/sqlx/go.mod similarity index 56% rename from drivers/sql/go.mod rename to dbs/sqlx/go.mod index 7956866..d98ee0c 100644 --- a/drivers/sql/go.mod +++ b/dbs/sqlx/go.mod @@ -1,14 +1,12 @@ -module github.com/avito-tech/go-transaction-manager/drivers/sql/v2 +module github.com/avito-tech/go-transaction-manager/db/sqlx/v2 go 1.13 require ( github.com/DATA-DOG/go-sqlmock v1.5.1 github.com/avito-tech/go-transaction-manager/v2 v2.0.0 - github.com/golang/mock v1.6.0 + github.com/jmoiron/sqlx v1.3.5 github.com/mattn/go-sqlite3 v1.14.18 github.com/stretchr/testify v1.8.2 go.uber.org/multierr v1.9.0 ) - -replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ diff --git a/drivers/sqlx/go.sum b/dbs/sqlx/go.sum similarity index 100% rename from drivers/sqlx/go.sum rename to dbs/sqlx/go.sum diff --git a/drivers/sqlx/go.work b/dbs/sqlx/go.work similarity index 100% rename from drivers/sqlx/go.work rename to dbs/sqlx/go.work diff --git a/drivers/sqlx/transaction.go b/dbs/sqlx/transaction.go similarity index 97% rename from drivers/sqlx/transaction.go rename to dbs/sqlx/transaction.go index 9f12b8c..c5f3b9f 100644 --- a/drivers/sqlx/transaction.go +++ b/dbs/sqlx/transaction.go @@ -9,7 +9,7 @@ import ( "github.com/jmoiron/sqlx" "go.uber.org/multierr" - trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" + trmsql "github.com/avito-tech/go-transaction-manager/dbs/sql/v2" trm "github.com/avito-tech/go-transaction-manager/v2" ) diff --git a/drivers/sqlx/transaction_test.go b/dbs/sqlx/transaction_test.go similarity index 100% rename from drivers/sqlx/transaction_test.go rename to dbs/sqlx/transaction_test.go diff --git a/go.mod b/go.mod index 1592f45..1b1b948 100644 --- a/go.mod +++ b/go.mod @@ -13,3 +13,4 @@ require ( go.uber.org/multierr v1.9.0 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) + diff --git a/internal/benchmark/with_or_without_trm/clean_test.go b/internal/benchmark/with_or_without_trm/clean_test.go index 1500a02..0949725 100644 --- a/internal/benchmark/with_or_without_trm/clean_test.go +++ b/internal/benchmark/with_or_without_trm/clean_test.go @@ -17,7 +17,7 @@ func BenchmarkClean_MockDB(b *testing.B) { } func BenchmarkClean_SQLite_File(b *testing.B) { - db := sqlite3(b, "file:test_clean.db") + db := sqlite3(b, "file:test_clean.dbs") defer db.Close() runClean(b, db) diff --git a/internal/benchmark/with_or_without_trm/model.go b/internal/benchmark/with_or_without_trm/model.go index 71879f2..58c0f23 100644 --- a/internal/benchmark/with_or_without_trm/model.go +++ b/internal/benchmark/with_or_without_trm/model.go @@ -1,6 +1,6 @@ package with_or_without_trm type user struct { - ID int64 `db:"user_id"` - Username string `db:"username"` + ID int64 `dbs:"user_id"` + Username string `dbs:"username"` } diff --git a/internal/benchmark/with_or_without_trm/trm_test.go.skip b/internal/benchmark/with_or_without_trm/trm_test.go.skip index 9c16573..c848d97 100644 --- a/internal/benchmark/with_or_without_trm/trm_test.go.skip +++ b/internal/benchmark/with_or_without_trm/trm_test.go.skip @@ -8,7 +8,7 @@ import ( _ "github.com/mattn/go-sqlite3" "github.com/stretchr/testify/require" - trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" + trmsqlx "github.com/avito-tech/go-transaction-manager/db/sqlx/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" ) diff --git a/internal/benchmark/with_or_without_trm/trmrepo.go.skip b/internal/benchmark/with_or_without_trm/trmrepo.go.skip index 7a21865..1d7e16a 100644 --- a/internal/benchmark/with_or_without_trm/trmrepo.go.skip +++ b/internal/benchmark/with_or_without_trm/trmrepo.go.skip @@ -5,7 +5,7 @@ import ( "github.com/jmoiron/sqlx" - trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" + trmsqlx "github.com/avito-tech/go-transaction-manager/db/sqlx/v2" ) type trmRepo struct { diff --git a/internal/cover/nested/cover.build.sh b/internal/cover/nested/cover.build.sh deleted file mode 100644 index 0d55b8b..0000000 --- a/internal/cover/nested/cover.build.sh +++ /dev/null @@ -1,21 +0,0 @@ -cd ./module1/cmd - -mkdir -p codecov - -go build -cover -o run.exe . -GOCOVERDIR=./codecov ./run.exe - -# go test ./... -covermode=atomic -coverprofile=coverage.out - -cd ../../module2/cmd - -mkdir -p codecov - -go build -cover -o run.exe . -GOCOVERDIR=./codecov ./run.exe - -# go test ./... -covermode=atomic -coverprofile=coverage.out - -cd ../../ - -go tool covdata textfmt -i=module1/cmd/codecov,module2/cmd/codecov -o ./output.out \ No newline at end of file diff --git a/sh/go.mod.tidy.sh b/sh/go.mod.tidy.sh index 2bdf7e4..0f6dbee 100755 --- a/sh/go.mod.tidy.sh +++ b/sh/go.mod.tidy.sh @@ -6,7 +6,7 @@ ROOT=$(pwd) go mod tidy -for driver in ./drivers/*/; do +for driver in ./db/*/; do if [ -d "$driver" ]; then echo "\n$driver" cd $driver && go mod tidy diff --git a/sh/go.mod.vendor.local.sh b/sh/go.mod.vendor.local.sh new file mode 100755 index 0000000..fd6e863 --- /dev/null +++ b/sh/go.mod.vendor.local.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +cd ../ + +ROOT=$(pwd) + +go mod vendor + +for driver in ./db/*; do + if [ -d "$driver" ]; then + echo "\n$driver" + + cd $driver && \ + $ROOT/sh/utils/go.mod.replace.default.sh + go mod vendor && \ + $ROOT/sh/utils/go.mod.dropreplace.default.sh + + cd $ROOT + fi +done diff --git a/sh/go.mod.vendor.sh b/sh/go.mod.vendor.sh index 180b8fc..dd2e592 100755 --- a/sh/go.mod.vendor.sh +++ b/sh/go.mod.vendor.sh @@ -6,7 +6,7 @@ ROOT=$(pwd) go mod vendor -for driver in ./drivers/*; do +for driver in ./db/*; do if [ -d "$driver" ]; then echo "\n$driver" cd $driver && go mod vendor diff --git a/sh/go.test.coverage.sh b/sh/go.test.coverage.sh index d48284b..829f217 100755 --- a/sh/go.test.coverage.sh +++ b/sh/go.test.coverage.sh @@ -5,10 +5,10 @@ ROOT="$(pwd)/.." COVERAGE_TEST="-cover -covermode=atomic -test.gocoverdir=$ROOT/coverage" -drivers=("$($DIR/utils/drivers.sh)") - mkdir -p $ROOT/coverage ./go.test.sh $COVERAGE_TEST "$@" -go tool covdata textfmt -i="$ROOT/coverage" -o "$ROOT/coverage.out" \ No newline at end of file +go tool covdata textfmt -i="$ROOT/coverage" -o "$ROOT/coverage.out" + +rm $ROOT/coverage/* \ No newline at end of file diff --git a/sh/go.test.sh b/sh/go.test.sh index 9d9723e..bf00c48 100755 --- a/sh/go.test.sh +++ b/sh/go.test.sh @@ -2,7 +2,9 @@ DIR=$(pwd) -drivers=("$($DIR/utils/drivers.sh)") +drivers=$($DIR/utils/drivers.sh) + +echo $drivers cd ../ diff --git a/sh/utils/drivers.sh b/sh/utils/db.sh similarity index 58% rename from sh/utils/drivers.sh rename to sh/utils/db.sh index 2f63581..a68b313 100755 --- a/sh/utils/drivers.sh +++ b/sh/utils/db.sh @@ -2,4 +2,4 @@ cd ../ -echo drivers/* +echo ./db/* diff --git a/sh/utils/go.mod.dropreplace.default.sh b/sh/utils/go.mod.dropreplace.default.sh new file mode 100755 index 0000000..1dca42e --- /dev/null +++ b/sh/utils/go.mod.dropreplace.default.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +go mod edit -dropreplace=github.com/avito-tech/go-transaction-manager/v2@v2=../../ + +# https://github.com/golang/go/issues/51932 +# https://go.dev/doc/tutorial/workspaces diff --git a/sh/utils/go.mod.replace.default.sh b/sh/utils/go.mod.replace.default.sh new file mode 100755 index 0000000..915a608 --- /dev/null +++ b/sh/utils/go.mod.replace.default.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +go mod edit -replace=github.com/avito-tech/go-transaction-manager/v2@v2=../../ From f14f261f290ab06f5dce5e9bd5de348a4275af67 Mon Sep 17 00:00:00 2001 From: iasergunin Date: Fri, 15 Dec 2023 22:41:28 +0400 Subject: [PATCH 08/13] 1. rename db to drivers --- .github/workflows/main.yaml | 2 +- README.md | 38 +++++++++---------- dbs/mongo/go.mod | 13 ------- dbs/sqlx/go.mod | 12 ------ {dbs => drivers}/go-redis-v8/context.go | 0 {dbs => drivers}/go-redis-v8/example_test.go | 4 +- {dbs => drivers}/go-redis-v8/factory.go | 0 {dbs => drivers}/go-redis-v8/go.mod | 2 +- {dbs => drivers}/go-redis-v8/go.sum | 0 {dbs => drivers}/go-redis-v8/go.work | 0 {dbs => drivers}/go-redis-v8/option.go | 0 .../go-redis-v8/readonly_func_without_tx.go | 0 .../readonly_func_without_tx_test.go | 0 {dbs => drivers}/go-redis-v8/settings.go | 0 {dbs => drivers}/go-redis-v8/transaction.go | 0 .../go-redis-v8/transaction_test.go | 0 {dbs => drivers}/go-redis-v8/watcher.go | 0 {dbs => drivers}/go-redis-v8/watcher_test.go | 5 ++- {dbs => drivers}/gorm/context.go | 0 {dbs => drivers}/gorm/example_test.go | 4 +- {dbs => drivers}/gorm/factory.go | 0 {dbs => drivers}/gorm/go.mod | 2 +- {dbs => drivers}/gorm/go.sum | 0 {dbs => drivers}/gorm/go.work | 0 {dbs => drivers}/gorm/settings.go | 0 {dbs => drivers}/gorm/settings_test.go | 0 {dbs => drivers}/gorm/transaction.go | 0 {dbs => drivers}/gorm/transaction_test.go | 0 {dbs => drivers}/mongo/contract.go | 0 {dbs => drivers}/mongo/example_test.go | 6 +-- {dbs => drivers}/mongo/factory.go | 0 {dbs => drivers}/mongo/go.sum | 0 {dbs => drivers}/mongo/go.work | 0 {dbs => drivers}/mongo/settings.go | 0 {dbs => drivers}/mongo/settings_test.go | 0 {dbs => drivers}/mongo/transaction.go | 0 {dbs => drivers}/mongo/transaction_test.go | 0 {dbs => drivers}/pgxv4/context.go | 0 {dbs => drivers}/pgxv4/contract.go | 0 {dbs => drivers}/pgxv4/example_test.go | 5 ++- {dbs => drivers}/pgxv4/factory.go | 0 {dbs => drivers}/pgxv4/go.mod | 2 +- {dbs => drivers}/pgxv4/go.sum | 0 {dbs => drivers}/pgxv4/go.work | 0 {dbs => drivers}/pgxv4/settings.go | 0 {dbs => drivers}/pgxv4/settings_test.go | 0 {dbs => drivers}/pgxv4/transaction.go | 0 {dbs => drivers}/pgxv4/transaction_test.go | 0 {dbs => drivers}/pgxv5/context.go | 0 {dbs => drivers}/pgxv5/contract.go | 0 {dbs => drivers}/pgxv5/example_test.go | 5 ++- {dbs => drivers}/pgxv5/factory.go | 0 {dbs => drivers}/pgxv5/go.mod | 2 +- {dbs => drivers}/pgxv5/go.sum | 0 {dbs => drivers}/pgxv5/go.work | 0 {dbs => drivers}/pgxv5/settings.go | 0 {dbs => drivers}/pgxv5/settings_test.go | 0 {dbs => drivers}/pgxv5/transaction.go | 0 {dbs => drivers}/pgxv5/transaction_test.go | 0 {dbs => drivers}/sql/context.go | 0 {dbs => drivers}/sql/contract.go | 0 {dbs => drivers}/sql/example_test.go | 3 +- {dbs => drivers}/sql/factory.go | 0 {dbs => drivers}/sql/go.mod | 2 +- {dbs => drivers}/sql/go.sum | 0 {dbs => drivers}/sql/go.work | 0 {dbs => drivers}/sql/mock/savepoint.go | 0 {dbs => drivers}/sql/savepoint.go | 0 {dbs => drivers}/sql/settings.go | 2 +- {dbs => drivers}/sql/settings_test.go | 0 {dbs => drivers}/sql/transaction.go | 0 {dbs => drivers}/sql/transaction_test.go | 0 {dbs => drivers}/sqlx/chained_example_test.go | 6 +-- {dbs => drivers}/sqlx/context.go | 0 {dbs => drivers}/sqlx/contract.go | 0 {dbs => drivers}/sqlx/example_test.go | 6 +-- {dbs => drivers}/sqlx/factory.go | 2 +- {dbs => drivers}/sqlx/go.sum | 0 {dbs => drivers}/sqlx/go.work | 0 {dbs => drivers}/sqlx/transaction.go | 2 +- {dbs => drivers}/sqlx/transaction_test.go | 0 .../with_or_without_trm/clean_test.go | 2 +- .../benchmark/with_or_without_trm/model.go | 4 +- .../with_or_without_trm/trm_test.go.skip | 2 +- .../with_or_without_trm/trmrepo.go.skip | 2 +- sh/go.mod.tidy.sh | 4 +- sh/go.mod.vendor.local.sh | 4 +- sh/go.mod.vendor.sh | 4 +- sh/go.test.coverage.sh | 1 - sh/go.test.sh | 2 - sh/utils/{db.sh => drivers.sh} | 2 +- 91 files changed, 65 insertions(+), 87 deletions(-) delete mode 100644 dbs/mongo/go.mod delete mode 100644 dbs/sqlx/go.mod rename {dbs => drivers}/go-redis-v8/context.go (100%) rename {dbs => drivers}/go-redis-v8/example_test.go (97%) rename {dbs => drivers}/go-redis-v8/factory.go (100%) rename {dbs => drivers}/go-redis-v8/go.mod (72%) rename {dbs => drivers}/go-redis-v8/go.sum (100%) rename {dbs => drivers}/go-redis-v8/go.work (100%) rename {dbs => drivers}/go-redis-v8/option.go (100%) rename {dbs => drivers}/go-redis-v8/readonly_func_without_tx.go (100%) rename {dbs => drivers}/go-redis-v8/readonly_func_without_tx_test.go (100%) rename {dbs => drivers}/go-redis-v8/settings.go (100%) rename {dbs => drivers}/go-redis-v8/transaction.go (100%) rename {dbs => drivers}/go-redis-v8/transaction_test.go (100%) rename {dbs => drivers}/go-redis-v8/watcher.go (100%) rename {dbs => drivers}/go-redis-v8/watcher_test.go (96%) rename {dbs => drivers}/gorm/context.go (100%) rename {dbs => drivers}/gorm/example_test.go (94%) rename {dbs => drivers}/gorm/factory.go (100%) rename {dbs => drivers}/gorm/go.mod (90%) rename {dbs => drivers}/gorm/go.sum (100%) rename {dbs => drivers}/gorm/go.work (100%) rename {dbs => drivers}/gorm/settings.go (100%) rename {dbs => drivers}/gorm/settings_test.go (100%) rename {dbs => drivers}/gorm/transaction.go (100%) rename {dbs => drivers}/gorm/transaction_test.go (100%) rename {dbs => drivers}/mongo/contract.go (100%) rename {dbs => drivers}/mongo/example_test.go (93%) rename {dbs => drivers}/mongo/factory.go (100%) rename {dbs => drivers}/mongo/go.sum (100%) rename {dbs => drivers}/mongo/go.work (100%) rename {dbs => drivers}/mongo/settings.go (100%) rename {dbs => drivers}/mongo/settings_test.go (100%) rename {dbs => drivers}/mongo/transaction.go (100%) rename {dbs => drivers}/mongo/transaction_test.go (100%) rename {dbs => drivers}/pgxv4/context.go (100%) rename {dbs => drivers}/pgxv4/contract.go (100%) rename {dbs => drivers}/pgxv4/example_test.go (95%) rename {dbs => drivers}/pgxv4/factory.go (100%) rename {dbs => drivers}/pgxv4/go.mod (80%) rename {dbs => drivers}/pgxv4/go.sum (100%) rename {dbs => drivers}/pgxv4/go.work (100%) rename {dbs => drivers}/pgxv4/settings.go (100%) rename {dbs => drivers}/pgxv4/settings_test.go (100%) rename {dbs => drivers}/pgxv4/transaction.go (100%) rename {dbs => drivers}/pgxv4/transaction_test.go (100%) rename {dbs => drivers}/pgxv5/context.go (100%) rename {dbs => drivers}/pgxv5/contract.go (100%) rename {dbs => drivers}/pgxv5/example_test.go (95%) rename {dbs => drivers}/pgxv5/factory.go (100%) rename {dbs => drivers}/pgxv5/go.mod (73%) rename {dbs => drivers}/pgxv5/go.sum (100%) rename {dbs => drivers}/pgxv5/go.work (100%) rename {dbs => drivers}/pgxv5/settings.go (100%) rename {dbs => drivers}/pgxv5/settings_test.go (100%) rename {dbs => drivers}/pgxv5/transaction.go (100%) rename {dbs => drivers}/pgxv5/transaction_test.go (100%) rename {dbs => drivers}/sql/context.go (100%) rename {dbs => drivers}/sql/contract.go (100%) rename {dbs => drivers}/sql/example_test.go (97%) rename {dbs => drivers}/sql/factory.go (100%) rename {dbs => drivers}/sql/go.mod (88%) rename {dbs => drivers}/sql/go.sum (100%) rename {dbs => drivers}/sql/go.work (100%) rename {dbs => drivers}/sql/mock/savepoint.go (100%) rename {dbs => drivers}/sql/savepoint.go (100%) rename {dbs => drivers}/sql/settings.go (96%) rename {dbs => drivers}/sql/settings_test.go (100%) rename {dbs => drivers}/sql/transaction.go (100%) rename {dbs => drivers}/sql/transaction_test.go (100%) rename {dbs => drivers}/sqlx/chained_example_test.go (96%) rename {dbs => drivers}/sqlx/context.go (100%) rename {dbs => drivers}/sqlx/contract.go (100%) rename {dbs => drivers}/sqlx/example_test.go (95%) rename {dbs => drivers}/sqlx/factory.go (89%) rename {dbs => drivers}/sqlx/go.sum (100%) rename {dbs => drivers}/sqlx/go.work (100%) rename {dbs => drivers}/sqlx/transaction.go (97%) rename {dbs => drivers}/sqlx/transaction_test.go (100%) rename sh/utils/{db.sh => drivers.sh} (55%) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 8df565d..51c5d9d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -68,7 +68,7 @@ jobs: postgres: image: postgres env: - POSTGRES_DB: dbs + POSTGRES_DB: db POSTGRES_USER: user POSTGRES_PASSWORD: pass ports: diff --git a/README.md b/README.md index 0e62c83..0c9d463 100644 --- a/README.md +++ b/README.md @@ -12,19 +12,19 @@ Easiest way to get the perfect repository. ## Supported implementations -* [database/sql](https://pkg.go.dev/database/sql), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/db/sql/v2) ( +* [database/sql](https://pkg.go.dev/database/sql), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/sql/v2) ( Go 1.13) -* [jmoiron/sqlx](https://github.com/jmoiron/sqlx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/db/sqlx/v2) ( +* [jmoiron/sqlx](https://github.com/jmoiron/sqlx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2) ( Go 1.13) -* [gorm](https://github.com/go-gorm/gorm), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/db/gorm/v2) ( +* [gorm](https://github.com/go-gorm/gorm), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/gorm/v2) ( Go 1.18) -* [mongo-go-driver](https://github.com/mongodb/mongo-go-driver), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/db/mongo/v2) ( +* [mongo-go-driver](https://github.com/mongodb/mongo-go-driver), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/mongo/v2) ( Go 1.13) -* [go-redis/redis](https://github.com/go-redis/redis), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/db/go-redis-v8/v2) ( +* [go-redis/redis](https://github.com/go-redis/redis), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2) ( Go 1.17) -* [pgx_v4](https://github.com/jackc/pgx/tree/v4), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/db/pgxv4/v2) ( +* [pgx_v4](https://github.com/jackc/pgx/tree/v4), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2) ( Go 1.16) -* [pgx_v5](https://github.com/jackc/pgx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/db/pgxv5/v2) ( +* [pgx_v5](https://github.com/jackc/pgx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/pgxv5/v2) ( Go 1.19) ## Installation @@ -33,9 +33,9 @@ Easiest way to get the perfect repository. go get github.com/avito-tech/go-transaction-manager/v2 ``` -To install some support database use `go get github.com/avito-tech/go-transaction-manager/db/{name}/v2`. +To install some support database use `go get github.com/avito-tech/go-transaction-manager/drivers/{name}/v2`. -For example `go get github.com/avito-tech/go-transaction-manager/db/sqlx/v2`. +For example `go get github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2`. ### Backwards Compatibility @@ -56,13 +56,13 @@ use [ChainedMW](manager/chain.go) ([docs](https://pkg.go.dev/github.com/github.c ### Examples with an ideal *repository* and nested transactions. -* [database/sql](dbs/sql/example_test.go) -* [jmoiron/sqlx](dbs/sqlx/example_test.go) -* [gorm](dbs/gorm/example_test.go) -* [mongo-go-driver](dbs/mongo/example_test.go) -* [go-redis/redis](dbs/go-redis-v8/example_test.go) -* [pgx_v4](dbs/pgxv4/example_test.go) -* [pgx_v5](dbs/pgxv5/example_test.go) +* [database/sql](drivers/sql/example_test.go) +* [jmoiron/sqlx](drivers/sqlx/example_test.go) +* [gorm](drivers/gorm/example_test.go) +* [mongo-go-driver](drivers/mongo/example_test.go) +* [go-redis/redis](drivers/go-redis-v8/example_test.go) +* [pgx_v4](drivers/pgxv4/example_test.go) +* [pgx_v5](drivers/pgxv5/example_test.go) Below is an example how to start usage. @@ -76,7 +76,7 @@ import ( "github.com/jmoiron/sqlx" _ "github.com/mattn/go-sqlite3" - trmsqlx "github.com/avito-tech/go-transaction-manager/dbs/sqlx/v2" + trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" ) @@ -127,8 +127,8 @@ func newRepo(db *sqlx.DB, c *trmsqlx.CtxGetter) *repo { } type user struct { - ID int64 `dbs:"user_id"` - Username string `dbs:"username"` + ID int64 `db:"user_id"` + Username string `db:"username"` } func (r *repo) GetByID(ctx context.Context, id int64) (*user, error) { diff --git a/dbs/mongo/go.mod b/dbs/mongo/go.mod deleted file mode 100644 index 9ed1203..0000000 --- a/dbs/mongo/go.mod +++ /dev/null @@ -1,13 +0,0 @@ -module github.com/avito-tech/go-transaction-manager/db/mongo/v2 - -go 1.13 - -require ( - github.com/avito-tech/go-transaction-manager/db/sql/v2 v2.0.0 - github.com/avito-tech/go-transaction-manager/v2 v2.0.0 - github.com/mattn/go-sqlite3 v1.14.18 - github.com/stretchr/testify v1.8.2 - go.mongodb.org/mongo-driver v1.12.1 -) - - diff --git a/dbs/sqlx/go.mod b/dbs/sqlx/go.mod deleted file mode 100644 index d98ee0c..0000000 --- a/dbs/sqlx/go.mod +++ /dev/null @@ -1,12 +0,0 @@ -module github.com/avito-tech/go-transaction-manager/db/sqlx/v2 - -go 1.13 - -require ( - github.com/DATA-DOG/go-sqlmock v1.5.1 - github.com/avito-tech/go-transaction-manager/v2 v2.0.0 - github.com/jmoiron/sqlx v1.3.5 - github.com/mattn/go-sqlite3 v1.14.18 - github.com/stretchr/testify v1.8.2 - go.uber.org/multierr v1.9.0 -) diff --git a/dbs/go-redis-v8/context.go b/drivers/go-redis-v8/context.go similarity index 100% rename from dbs/go-redis-v8/context.go rename to drivers/go-redis-v8/context.go diff --git a/dbs/go-redis-v8/example_test.go b/drivers/go-redis-v8/example_test.go similarity index 97% rename from dbs/go-redis-v8/example_test.go rename to drivers/go-redis-v8/example_test.go index 2ff5b1d..9f8468f 100644 --- a/dbs/go-redis-v8/example_test.go +++ b/drivers/go-redis-v8/example_test.go @@ -8,13 +8,13 @@ import ( "encoding/json" "fmt" - trm "github.com/avito-tech/go-transaction-manager/v2" "github.com/go-redis/redis/v8" + trm "github.com/avito-tech/go-transaction-manager/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" - trmredis "github.com/avito-tech/go-transaction-manager/db/go-redis-v8/v2" + trmredis "github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. diff --git a/dbs/go-redis-v8/factory.go b/drivers/go-redis-v8/factory.go similarity index 100% rename from dbs/go-redis-v8/factory.go rename to drivers/go-redis-v8/factory.go diff --git a/dbs/go-redis-v8/go.mod b/drivers/go-redis-v8/go.mod similarity index 72% rename from dbs/go-redis-v8/go.mod rename to drivers/go-redis-v8/go.mod index 6127b82..80ba957 100644 --- a/dbs/go-redis-v8/go.mod +++ b/drivers/go-redis-v8/go.mod @@ -1,4 +1,4 @@ -module github.com/avito-tech/go-transaction-manager/db/go-redis-v8/v2 +module github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2 go 1.13 diff --git a/dbs/go-redis-v8/go.sum b/drivers/go-redis-v8/go.sum similarity index 100% rename from dbs/go-redis-v8/go.sum rename to drivers/go-redis-v8/go.sum diff --git a/dbs/go-redis-v8/go.work b/drivers/go-redis-v8/go.work similarity index 100% rename from dbs/go-redis-v8/go.work rename to drivers/go-redis-v8/go.work diff --git a/dbs/go-redis-v8/option.go b/drivers/go-redis-v8/option.go similarity index 100% rename from dbs/go-redis-v8/option.go rename to drivers/go-redis-v8/option.go diff --git a/dbs/go-redis-v8/readonly_func_without_tx.go b/drivers/go-redis-v8/readonly_func_without_tx.go similarity index 100% rename from dbs/go-redis-v8/readonly_func_without_tx.go rename to drivers/go-redis-v8/readonly_func_without_tx.go diff --git a/dbs/go-redis-v8/readonly_func_without_tx_test.go b/drivers/go-redis-v8/readonly_func_without_tx_test.go similarity index 100% rename from dbs/go-redis-v8/readonly_func_without_tx_test.go rename to drivers/go-redis-v8/readonly_func_without_tx_test.go diff --git a/dbs/go-redis-v8/settings.go b/drivers/go-redis-v8/settings.go similarity index 100% rename from dbs/go-redis-v8/settings.go rename to drivers/go-redis-v8/settings.go diff --git a/dbs/go-redis-v8/transaction.go b/drivers/go-redis-v8/transaction.go similarity index 100% rename from dbs/go-redis-v8/transaction.go rename to drivers/go-redis-v8/transaction.go diff --git a/dbs/go-redis-v8/transaction_test.go b/drivers/go-redis-v8/transaction_test.go similarity index 100% rename from dbs/go-redis-v8/transaction_test.go rename to drivers/go-redis-v8/transaction_test.go diff --git a/dbs/go-redis-v8/watcher.go b/drivers/go-redis-v8/watcher.go similarity index 100% rename from dbs/go-redis-v8/watcher.go rename to drivers/go-redis-v8/watcher.go diff --git a/dbs/go-redis-v8/watcher_test.go b/drivers/go-redis-v8/watcher_test.go similarity index 96% rename from dbs/go-redis-v8/watcher_test.go rename to drivers/go-redis-v8/watcher_test.go index 09139d8..f6375e4 100644 --- a/dbs/go-redis-v8/watcher_test.go +++ b/drivers/go-redis-v8/watcher_test.go @@ -8,12 +8,13 @@ import ( "fmt" "time" + "github.com/go-redis/redis/v8" + trm "github.com/avito-tech/go-transaction-manager/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" - "github.com/go-redis/redis/v8" - trmredis "github.com/avito-tech/go-transaction-manager/db/go-redis-v8/v2" + trmredis "github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2" ) // Example demonstrates the watching of updated keys. diff --git a/dbs/gorm/context.go b/drivers/gorm/context.go similarity index 100% rename from dbs/gorm/context.go rename to drivers/gorm/context.go diff --git a/dbs/gorm/example_test.go b/drivers/gorm/example_test.go similarity index 94% rename from dbs/gorm/example_test.go rename to drivers/gorm/example_test.go index 11e1189..bd05850 100644 --- a/dbs/gorm/example_test.go +++ b/drivers/gorm/example_test.go @@ -11,7 +11,7 @@ import ( "gorm.io/driver/sqlite" "gorm.io/gorm" - trmgorm "github.com/avito-tech/go-transaction-manager/db/gorm/v2" + trmgorm "github.com/avito-tech/go-transaction-manager/drivers/gorm/v2" trm "github.com/avito-tech/go-transaction-manager/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" @@ -19,7 +19,7 @@ import ( // Example demonstrates the implementation of the Repository pattern by trm.Manager. func Example() { - db, err := gorm.Open(sqlite.Open("file:test.dbs?mode=memory")) + db, err := gorm.Open(sqlite.Open("file:test.drivers?mode=memory")) checkErr(err) // Migrate the schema diff --git a/dbs/gorm/factory.go b/drivers/gorm/factory.go similarity index 100% rename from dbs/gorm/factory.go rename to drivers/gorm/factory.go diff --git a/dbs/gorm/go.mod b/drivers/gorm/go.mod similarity index 90% rename from dbs/gorm/go.mod rename to drivers/gorm/go.mod index 9584aa0..35ee394 100644 --- a/dbs/gorm/go.mod +++ b/drivers/gorm/go.mod @@ -1,4 +1,4 @@ -module github.com/avito-tech/go-transaction-manager/db/gorm/v2 +module github.com/avito-tech/go-transaction-manager/drivers/gorm/v2 go 1.18 diff --git a/dbs/gorm/go.sum b/drivers/gorm/go.sum similarity index 100% rename from dbs/gorm/go.sum rename to drivers/gorm/go.sum diff --git a/dbs/gorm/go.work b/drivers/gorm/go.work similarity index 100% rename from dbs/gorm/go.work rename to drivers/gorm/go.work diff --git a/dbs/gorm/settings.go b/drivers/gorm/settings.go similarity index 100% rename from dbs/gorm/settings.go rename to drivers/gorm/settings.go diff --git a/dbs/gorm/settings_test.go b/drivers/gorm/settings_test.go similarity index 100% rename from dbs/gorm/settings_test.go rename to drivers/gorm/settings_test.go diff --git a/dbs/gorm/transaction.go b/drivers/gorm/transaction.go similarity index 100% rename from dbs/gorm/transaction.go rename to drivers/gorm/transaction.go diff --git a/dbs/gorm/transaction_test.go b/drivers/gorm/transaction_test.go similarity index 100% rename from dbs/gorm/transaction_test.go rename to drivers/gorm/transaction_test.go diff --git a/dbs/mongo/contract.go b/drivers/mongo/contract.go similarity index 100% rename from dbs/mongo/contract.go rename to drivers/mongo/contract.go diff --git a/dbs/mongo/example_test.go b/drivers/mongo/example_test.go similarity index 93% rename from dbs/mongo/example_test.go rename to drivers/mongo/example_test.go index cb25ede..239563c 100644 --- a/dbs/mongo/example_test.go +++ b/drivers/mongo/example_test.go @@ -12,12 +12,10 @@ import ( "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - trmsql "github.com/avito-tech/go-transaction-manager/dbs/sql/v2" - + trmmongo "github.com/avito-tech/go-transaction-manager/drivers/mongo/v2" + trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" "github.com/avito-tech/go-transaction-manager/v2/manager" - - trmmongo "github.com/avito-tech/go-transaction-manager/db/mongo/v2" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. diff --git a/dbs/mongo/factory.go b/drivers/mongo/factory.go similarity index 100% rename from dbs/mongo/factory.go rename to drivers/mongo/factory.go diff --git a/dbs/mongo/go.sum b/drivers/mongo/go.sum similarity index 100% rename from dbs/mongo/go.sum rename to drivers/mongo/go.sum diff --git a/dbs/mongo/go.work b/drivers/mongo/go.work similarity index 100% rename from dbs/mongo/go.work rename to drivers/mongo/go.work diff --git a/dbs/mongo/settings.go b/drivers/mongo/settings.go similarity index 100% rename from dbs/mongo/settings.go rename to drivers/mongo/settings.go diff --git a/dbs/mongo/settings_test.go b/drivers/mongo/settings_test.go similarity index 100% rename from dbs/mongo/settings_test.go rename to drivers/mongo/settings_test.go diff --git a/dbs/mongo/transaction.go b/drivers/mongo/transaction.go similarity index 100% rename from dbs/mongo/transaction.go rename to drivers/mongo/transaction.go diff --git a/dbs/mongo/transaction_test.go b/drivers/mongo/transaction_test.go similarity index 100% rename from dbs/mongo/transaction_test.go rename to drivers/mongo/transaction_test.go diff --git a/dbs/pgxv4/context.go b/drivers/pgxv4/context.go similarity index 100% rename from dbs/pgxv4/context.go rename to drivers/pgxv4/context.go diff --git a/dbs/pgxv4/contract.go b/drivers/pgxv4/contract.go similarity index 100% rename from dbs/pgxv4/contract.go rename to drivers/pgxv4/contract.go diff --git a/dbs/pgxv4/example_test.go b/drivers/pgxv4/example_test.go similarity index 95% rename from dbs/pgxv4/example_test.go rename to drivers/pgxv4/example_test.go index d8c5413..32e31d6 100644 --- a/dbs/pgxv4/example_test.go +++ b/drivers/pgxv4/example_test.go @@ -9,7 +9,8 @@ import ( "github.com/jackc/pgx/v4/pgxpool" - trmpgx "github.com/avito-tech/go-transaction-manager/db/pgxv4/v2" + trmpgx "github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2" + "github.com/avito-tech/go-transaction-manager/v2/manager" ) @@ -18,7 +19,7 @@ func Example() { ctx := context.Background() uri := fmt.Sprintf("postgres://%s:%s@%s:%d/%s", - "user", "pass", "localhost", 5432, "dbs", + "user", "pass", "localhost", 5432, "drivers", ) pool, err := pgxpool.Connect(ctx, uri) diff --git a/dbs/pgxv4/factory.go b/drivers/pgxv4/factory.go similarity index 100% rename from dbs/pgxv4/factory.go rename to drivers/pgxv4/factory.go diff --git a/dbs/pgxv4/go.mod b/drivers/pgxv4/go.mod similarity index 80% rename from dbs/pgxv4/go.mod rename to drivers/pgxv4/go.mod index 4d3d35b..dd30b5a 100644 --- a/dbs/pgxv4/go.mod +++ b/drivers/pgxv4/go.mod @@ -1,4 +1,4 @@ -module github.com/avito-tech/go-transaction-manager/db/pgxv4/v2 +module github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2 go 1.13 diff --git a/dbs/pgxv4/go.sum b/drivers/pgxv4/go.sum similarity index 100% rename from dbs/pgxv4/go.sum rename to drivers/pgxv4/go.sum diff --git a/dbs/pgxv4/go.work b/drivers/pgxv4/go.work similarity index 100% rename from dbs/pgxv4/go.work rename to drivers/pgxv4/go.work diff --git a/dbs/pgxv4/settings.go b/drivers/pgxv4/settings.go similarity index 100% rename from dbs/pgxv4/settings.go rename to drivers/pgxv4/settings.go diff --git a/dbs/pgxv4/settings_test.go b/drivers/pgxv4/settings_test.go similarity index 100% rename from dbs/pgxv4/settings_test.go rename to drivers/pgxv4/settings_test.go diff --git a/dbs/pgxv4/transaction.go b/drivers/pgxv4/transaction.go similarity index 100% rename from dbs/pgxv4/transaction.go rename to drivers/pgxv4/transaction.go diff --git a/dbs/pgxv4/transaction_test.go b/drivers/pgxv4/transaction_test.go similarity index 100% rename from dbs/pgxv4/transaction_test.go rename to drivers/pgxv4/transaction_test.go diff --git a/dbs/pgxv5/context.go b/drivers/pgxv5/context.go similarity index 100% rename from dbs/pgxv5/context.go rename to drivers/pgxv5/context.go diff --git a/dbs/pgxv5/contract.go b/drivers/pgxv5/contract.go similarity index 100% rename from dbs/pgxv5/contract.go rename to drivers/pgxv5/contract.go diff --git a/dbs/pgxv5/example_test.go b/drivers/pgxv5/example_test.go similarity index 95% rename from dbs/pgxv5/example_test.go rename to drivers/pgxv5/example_test.go index baf8dc8..fdc5cad 100644 --- a/dbs/pgxv5/example_test.go +++ b/drivers/pgxv5/example_test.go @@ -9,7 +9,8 @@ import ( "github.com/jackc/pgx/v5/pgxpool" - trmpgx "github.com/avito-tech/go-transaction-manager/db/pgxv5/v2" + trmpgx "github.com/avito-tech/go-transaction-manager/drivers/pgxv5/v2" + "github.com/avito-tech/go-transaction-manager/v2/manager" ) @@ -18,7 +19,7 @@ func Example() { ctx := context.Background() uri := fmt.Sprintf("postgres://%s:%s@%s:%d/%s", - "user", "pass", "localhost", 5432, "dbs", + "user", "pass", "localhost", 5432, "drivers", ) pool, err := pgxpool.New(ctx, uri) diff --git a/dbs/pgxv5/factory.go b/drivers/pgxv5/factory.go similarity index 100% rename from dbs/pgxv5/factory.go rename to drivers/pgxv5/factory.go diff --git a/dbs/pgxv5/go.mod b/drivers/pgxv5/go.mod similarity index 73% rename from dbs/pgxv5/go.mod rename to drivers/pgxv5/go.mod index a5445a2..43f85f3 100644 --- a/dbs/pgxv5/go.mod +++ b/drivers/pgxv5/go.mod @@ -1,4 +1,4 @@ -module github.com/avito-tech/go-transaction-manager/db/pgxv5/v2 +module github.com/avito-tech/go-transaction-manager/drivers/pgxv5/v2 go 1.13 diff --git a/dbs/pgxv5/go.sum b/drivers/pgxv5/go.sum similarity index 100% rename from dbs/pgxv5/go.sum rename to drivers/pgxv5/go.sum diff --git a/dbs/pgxv5/go.work b/drivers/pgxv5/go.work similarity index 100% rename from dbs/pgxv5/go.work rename to drivers/pgxv5/go.work diff --git a/dbs/pgxv5/settings.go b/drivers/pgxv5/settings.go similarity index 100% rename from dbs/pgxv5/settings.go rename to drivers/pgxv5/settings.go diff --git a/dbs/pgxv5/settings_test.go b/drivers/pgxv5/settings_test.go similarity index 100% rename from dbs/pgxv5/settings_test.go rename to drivers/pgxv5/settings_test.go diff --git a/dbs/pgxv5/transaction.go b/drivers/pgxv5/transaction.go similarity index 100% rename from dbs/pgxv5/transaction.go rename to drivers/pgxv5/transaction.go diff --git a/dbs/pgxv5/transaction_test.go b/drivers/pgxv5/transaction_test.go similarity index 100% rename from dbs/pgxv5/transaction_test.go rename to drivers/pgxv5/transaction_test.go diff --git a/dbs/sql/context.go b/drivers/sql/context.go similarity index 100% rename from dbs/sql/context.go rename to drivers/sql/context.go diff --git a/dbs/sql/contract.go b/drivers/sql/contract.go similarity index 100% rename from dbs/sql/contract.go rename to drivers/sql/contract.go diff --git a/dbs/sql/example_test.go b/drivers/sql/example_test.go similarity index 97% rename from dbs/sql/example_test.go rename to drivers/sql/example_test.go index b85a070..1a6c83e 100644 --- a/dbs/sql/example_test.go +++ b/drivers/sql/example_test.go @@ -7,7 +7,8 @@ import ( _ "github.com/mattn/go-sqlite3" - trmsql "github.com/avito-tech/go-transaction-manager/db/sql/v2" + trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" + trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" "github.com/avito-tech/go-transaction-manager/v2/manager" diff --git a/dbs/sql/factory.go b/drivers/sql/factory.go similarity index 100% rename from dbs/sql/factory.go rename to drivers/sql/factory.go diff --git a/dbs/sql/go.mod b/drivers/sql/go.mod similarity index 88% rename from dbs/sql/go.mod rename to drivers/sql/go.mod index 1f387e6..0e5263d 100644 --- a/dbs/sql/go.mod +++ b/drivers/sql/go.mod @@ -1,4 +1,4 @@ -module github.com/avito-tech/go-transaction-manager/db/sql/v2 +module github.com/avito-tech/go-transaction-manager/drivers/sql/v2 go 1.13 diff --git a/dbs/sql/go.sum b/drivers/sql/go.sum similarity index 100% rename from dbs/sql/go.sum rename to drivers/sql/go.sum diff --git a/dbs/sql/go.work b/drivers/sql/go.work similarity index 100% rename from dbs/sql/go.work rename to drivers/sql/go.work diff --git a/dbs/sql/mock/savepoint.go b/drivers/sql/mock/savepoint.go similarity index 100% rename from dbs/sql/mock/savepoint.go rename to drivers/sql/mock/savepoint.go diff --git a/dbs/sql/savepoint.go b/drivers/sql/savepoint.go similarity index 100% rename from dbs/sql/savepoint.go rename to drivers/sql/savepoint.go diff --git a/dbs/sql/settings.go b/drivers/sql/settings.go similarity index 96% rename from dbs/sql/settings.go rename to drivers/sql/settings.go index 7ec34b6..9e004ed 100644 --- a/dbs/sql/settings.go +++ b/drivers/sql/settings.go @@ -3,7 +3,7 @@ package sql import ( "database/sql" -trm "github.com/avito-tech/go-transaction-manager/v2" + trm "github.com/avito-tech/go-transaction-manager/v2" ) // Opt is a type to configure Settings. diff --git a/dbs/sql/settings_test.go b/drivers/sql/settings_test.go similarity index 100% rename from dbs/sql/settings_test.go rename to drivers/sql/settings_test.go diff --git a/dbs/sql/transaction.go b/drivers/sql/transaction.go similarity index 100% rename from dbs/sql/transaction.go rename to drivers/sql/transaction.go diff --git a/dbs/sql/transaction_test.go b/drivers/sql/transaction_test.go similarity index 100% rename from dbs/sql/transaction_test.go rename to drivers/sql/transaction_test.go diff --git a/dbs/sqlx/chained_example_test.go b/drivers/sqlx/chained_example_test.go similarity index 96% rename from dbs/sqlx/chained_example_test.go rename to drivers/sqlx/chained_example_test.go index c522727..c98d54f 100644 --- a/dbs/sqlx/chained_example_test.go +++ b/drivers/sqlx/chained_example_test.go @@ -6,13 +6,11 @@ import ( _ "github.com/mattn/go-sqlite3" - trmsqlx "github.com/avito-tech/go-transaction-manager/db/sqlx/v2" + trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" trm "github.com/avito-tech/go-transaction-manager/v2" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" - - "github.com/avito-tech/go-transaction-manager/v2/settings" - "github.com/avito-tech/go-transaction-manager/v2/manager" + "github.com/avito-tech/go-transaction-manager/v2/settings" ) // Example demonstrates a work of manager.ChainedMW. diff --git a/dbs/sqlx/context.go b/drivers/sqlx/context.go similarity index 100% rename from dbs/sqlx/context.go rename to drivers/sqlx/context.go diff --git a/dbs/sqlx/contract.go b/drivers/sqlx/contract.go similarity index 100% rename from dbs/sqlx/contract.go rename to drivers/sqlx/contract.go diff --git a/dbs/sqlx/example_test.go b/drivers/sqlx/example_test.go similarity index 95% rename from dbs/sqlx/example_test.go rename to drivers/sqlx/example_test.go index 2852b7c..c9132dc 100644 --- a/dbs/sqlx/example_test.go +++ b/drivers/sqlx/example_test.go @@ -7,7 +7,7 @@ import ( "github.com/jmoiron/sqlx" _ "github.com/mattn/go-sqlite3" - trmsqlx "github.com/avito-tech/go-transaction-manager/db/sqlx/v2" + trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" ) @@ -76,8 +76,8 @@ type user struct { } type userRow struct { - ID int64 `dbs:"user_id"` - Username string `dbs:"username"` + ID int64 `db:"user_id"` + Username string `db:"username"` } func (r *repo) GetByID(ctx context.Context, id int64) (*user, error) { diff --git a/dbs/sqlx/factory.go b/drivers/sqlx/factory.go similarity index 89% rename from dbs/sqlx/factory.go rename to drivers/sqlx/factory.go index ebac15a..d8fb698 100644 --- a/dbs/sqlx/factory.go +++ b/drivers/sqlx/factory.go @@ -5,7 +5,7 @@ import ( "github.com/jmoiron/sqlx" - trmsql "github.com/avito-tech/go-transaction-manager/dbs/sql/v2" + trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" trm "github.com/avito-tech/go-transaction-manager/v2" ) diff --git a/dbs/sqlx/go.sum b/drivers/sqlx/go.sum similarity index 100% rename from dbs/sqlx/go.sum rename to drivers/sqlx/go.sum diff --git a/dbs/sqlx/go.work b/drivers/sqlx/go.work similarity index 100% rename from dbs/sqlx/go.work rename to drivers/sqlx/go.work diff --git a/dbs/sqlx/transaction.go b/drivers/sqlx/transaction.go similarity index 97% rename from dbs/sqlx/transaction.go rename to drivers/sqlx/transaction.go index c5f3b9f..9f12b8c 100644 --- a/dbs/sqlx/transaction.go +++ b/drivers/sqlx/transaction.go @@ -9,7 +9,7 @@ import ( "github.com/jmoiron/sqlx" "go.uber.org/multierr" - trmsql "github.com/avito-tech/go-transaction-manager/dbs/sql/v2" + trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" trm "github.com/avito-tech/go-transaction-manager/v2" ) diff --git a/dbs/sqlx/transaction_test.go b/drivers/sqlx/transaction_test.go similarity index 100% rename from dbs/sqlx/transaction_test.go rename to drivers/sqlx/transaction_test.go diff --git a/internal/benchmark/with_or_without_trm/clean_test.go b/internal/benchmark/with_or_without_trm/clean_test.go index 0949725..ca240b8 100644 --- a/internal/benchmark/with_or_without_trm/clean_test.go +++ b/internal/benchmark/with_or_without_trm/clean_test.go @@ -17,7 +17,7 @@ func BenchmarkClean_MockDB(b *testing.B) { } func BenchmarkClean_SQLite_File(b *testing.B) { - db := sqlite3(b, "file:test_clean.dbs") + db := sqlite3(b, "file:test_clean.drivers") defer db.Close() runClean(b, db) diff --git a/internal/benchmark/with_or_without_trm/model.go b/internal/benchmark/with_or_without_trm/model.go index 58c0f23..71879f2 100644 --- a/internal/benchmark/with_or_without_trm/model.go +++ b/internal/benchmark/with_or_without_trm/model.go @@ -1,6 +1,6 @@ package with_or_without_trm type user struct { - ID int64 `dbs:"user_id"` - Username string `dbs:"username"` + ID int64 `db:"user_id"` + Username string `db:"username"` } diff --git a/internal/benchmark/with_or_without_trm/trm_test.go.skip b/internal/benchmark/with_or_without_trm/trm_test.go.skip index c848d97..9c16573 100644 --- a/internal/benchmark/with_or_without_trm/trm_test.go.skip +++ b/internal/benchmark/with_or_without_trm/trm_test.go.skip @@ -8,7 +8,7 @@ import ( _ "github.com/mattn/go-sqlite3" "github.com/stretchr/testify/require" - trmsqlx "github.com/avito-tech/go-transaction-manager/db/sqlx/v2" + trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" ) diff --git a/internal/benchmark/with_or_without_trm/trmrepo.go.skip b/internal/benchmark/with_or_without_trm/trmrepo.go.skip index 1d7e16a..7a21865 100644 --- a/internal/benchmark/with_or_without_trm/trmrepo.go.skip +++ b/internal/benchmark/with_or_without_trm/trmrepo.go.skip @@ -5,7 +5,7 @@ import ( "github.com/jmoiron/sqlx" - trmsqlx "github.com/avito-tech/go-transaction-manager/db/sqlx/v2" + trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" ) type trmRepo struct { diff --git a/sh/go.mod.tidy.sh b/sh/go.mod.tidy.sh index 0f6dbee..2169a3c 100755 --- a/sh/go.mod.tidy.sh +++ b/sh/go.mod.tidy.sh @@ -6,7 +6,9 @@ ROOT=$(pwd) go mod tidy -for driver in ./db/*/; do +drivers=$($DIR/utils/drivers.sh) + +for driver in $drivers; do if [ -d "$driver" ]; then echo "\n$driver" cd $driver && go mod tidy diff --git a/sh/go.mod.vendor.local.sh b/sh/go.mod.vendor.local.sh index fd6e863..52c06cc 100755 --- a/sh/go.mod.vendor.local.sh +++ b/sh/go.mod.vendor.local.sh @@ -6,7 +6,9 @@ ROOT=$(pwd) go mod vendor -for driver in ./db/*; do +drivers=$($DIR/utils/drivers.sh) + +for driver in $drivers; do if [ -d "$driver" ]; then echo "\n$driver" diff --git a/sh/go.mod.vendor.sh b/sh/go.mod.vendor.sh index dd2e592..4722a1b 100755 --- a/sh/go.mod.vendor.sh +++ b/sh/go.mod.vendor.sh @@ -6,7 +6,9 @@ ROOT=$(pwd) go mod vendor -for driver in ./db/*; do +drivers=$($DIR/utils/drivers.sh) + +for driver in $drivers; do if [ -d "$driver" ]; then echo "\n$driver" cd $driver && go mod vendor diff --git a/sh/go.test.coverage.sh b/sh/go.test.coverage.sh index 829f217..8918761 100755 --- a/sh/go.test.coverage.sh +++ b/sh/go.test.coverage.sh @@ -1,6 +1,5 @@ #!/bin/bash -DIR=$(pwd) ROOT="$(pwd)/.." COVERAGE_TEST="-cover -covermode=atomic -test.gocoverdir=$ROOT/coverage" diff --git a/sh/go.test.sh b/sh/go.test.sh index bf00c48..103c07e 100755 --- a/sh/go.test.sh +++ b/sh/go.test.sh @@ -4,8 +4,6 @@ DIR=$(pwd) drivers=$($DIR/utils/drivers.sh) -echo $drivers - cd ../ ROOT=$(pwd) diff --git a/sh/utils/db.sh b/sh/utils/drivers.sh similarity index 55% rename from sh/utils/db.sh rename to sh/utils/drivers.sh index a68b313..306c85e 100755 --- a/sh/utils/db.sh +++ b/sh/utils/drivers.sh @@ -2,4 +2,4 @@ cd ../ -echo ./db/* +echo ./drivers/* From 8b57256a685781283805688f7ed6ae6f66080aa3 Mon Sep 17 00:00:00 2001 From: iasergunin Date: Fri, 15 Dec 2023 23:20:52 +0400 Subject: [PATCH 09/13] 1. added workspace --- Makefile | 3 +++ drivers/go-redis-v8/go.work | 1 - drivers/gorm/go.work | 3 ++- drivers/mongo/go.mod | 3 --- drivers/mongo/go.work | 2 +- drivers/pgxv4/go.mod | 2 -- drivers/pgxv4/go.work | 1 - drivers/pgxv5/go.work | 1 - drivers/sql/go.work.sum | 1 + drivers/sqlx/go.mod | 4 ---- drivers/sqlx/go.work | 2 +- drivers/sqlx/go.work.sum | 1 + go.mod | 1 - sh/go.mod.tidy.sh | 11 +++++++---- sh/go.mod.vendor.local.sh | 14 +++++++------- sh/go.work.sync.sh | 19 +++++++++++++++++++ 16 files changed, 42 insertions(+), 27 deletions(-) create mode 100644 drivers/sql/go.work.sum create mode 100644 drivers/sqlx/go.work.sum create mode 100755 sh/go.work.sync.sh diff --git a/Makefile b/Makefile index eeacff7..e856068 100644 --- a/Makefile +++ b/Makefile @@ -32,3 +32,6 @@ go.mod.tidy: go.mod.vendor: cd sh && sh ./go.mod.vendor.sh + +go.work.sync: + cd sh && sh ./go.work.sync.sh diff --git a/drivers/go-redis-v8/go.work b/drivers/go-redis-v8/go.work index 11d684b..180619c 100644 --- a/drivers/go-redis-v8/go.work +++ b/drivers/go-redis-v8/go.work @@ -3,4 +3,3 @@ go 1.21 use . replace github.com/avito-tech/go-transaction-manager/v2 => ../../ - diff --git a/drivers/gorm/go.work b/drivers/gorm/go.work index bb5c9df..6e5594f 100644 --- a/drivers/gorm/go.work +++ b/drivers/gorm/go.work @@ -3,4 +3,5 @@ go 1.21 use . replace github.com/avito-tech/go-transaction-manager/v2 => ../../ -replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 => ../sql \ No newline at end of file + +replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 => ../sql diff --git a/drivers/mongo/go.mod b/drivers/mongo/go.mod index 0fcf73e..ab2b655 100644 --- a/drivers/mongo/go.mod +++ b/drivers/mongo/go.mod @@ -10,6 +10,3 @@ require ( go.mongodb.org/mongo-driver v1.13.1 ) -replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 => ../sql - -replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ diff --git a/drivers/mongo/go.work b/drivers/mongo/go.work index c27816b..6e5594f 100644 --- a/drivers/mongo/go.work +++ b/drivers/mongo/go.work @@ -3,5 +3,5 @@ go 1.21 use . replace github.com/avito-tech/go-transaction-manager/v2 => ../../ -replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 => ../sql +replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 => ../sql diff --git a/drivers/pgxv4/go.mod b/drivers/pgxv4/go.mod index dd30b5a..6b15a1c 100644 --- a/drivers/pgxv4/go.mod +++ b/drivers/pgxv4/go.mod @@ -9,5 +9,3 @@ require ( github.com/pashagolub/pgxmock v1.8.0 github.com/stretchr/testify v1.8.2 ) - -replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ diff --git a/drivers/pgxv4/go.work b/drivers/pgxv4/go.work index 11d684b..180619c 100644 --- a/drivers/pgxv4/go.work +++ b/drivers/pgxv4/go.work @@ -3,4 +3,3 @@ go 1.21 use . replace github.com/avito-tech/go-transaction-manager/v2 => ../../ - diff --git a/drivers/pgxv5/go.work b/drivers/pgxv5/go.work index 11d684b..180619c 100644 --- a/drivers/pgxv5/go.work +++ b/drivers/pgxv5/go.work @@ -3,4 +3,3 @@ go 1.21 use . replace github.com/avito-tech/go-transaction-manager/v2 => ../../ - diff --git a/drivers/sql/go.work.sum b/drivers/sql/go.work.sum new file mode 100644 index 0000000..1a8b847 --- /dev/null +++ b/drivers/sql/go.work.sum @@ -0,0 +1 @@ +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= diff --git a/drivers/sqlx/go.mod b/drivers/sqlx/go.mod index 459a48f..7a020e5 100644 --- a/drivers/sqlx/go.mod +++ b/drivers/sqlx/go.mod @@ -11,7 +11,3 @@ require ( github.com/stretchr/testify v1.8.2 go.uber.org/multierr v1.9.0 ) - -replace github.com/avito-tech/go-transaction-manager/v2 v2.0.0 => ../../ - -replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 => ../sql diff --git a/drivers/sqlx/go.work b/drivers/sqlx/go.work index c27816b..6e5594f 100644 --- a/drivers/sqlx/go.work +++ b/drivers/sqlx/go.work @@ -3,5 +3,5 @@ go 1.21 use . replace github.com/avito-tech/go-transaction-manager/v2 => ../../ -replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 => ../sql +replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 => ../sql diff --git a/drivers/sqlx/go.work.sum b/drivers/sqlx/go.work.sum new file mode 100644 index 0000000..1a8b847 --- /dev/null +++ b/drivers/sqlx/go.work.sum @@ -0,0 +1 @@ +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= diff --git a/go.mod b/go.mod index 1b1b948..1592f45 100644 --- a/go.mod +++ b/go.mod @@ -13,4 +13,3 @@ require ( go.uber.org/multierr v1.9.0 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) - diff --git a/sh/go.mod.tidy.sh b/sh/go.mod.tidy.sh index 2169a3c..35c7c4d 100755 --- a/sh/go.mod.tidy.sh +++ b/sh/go.mod.tidy.sh @@ -1,18 +1,21 @@ #!/bin/bash +DIR=$(pwd) +drivers=$($DIR/utils/drivers.sh) + cd ../ ROOT=$(pwd) -go mod tidy - -drivers=$($DIR/utils/drivers.sh) +go mod tidy & for driver in $drivers; do if [ -d "$driver" ]; then echo "\n$driver" - cd $driver && go mod tidy + cd $driver && go mod tidy & cd $ROOT fi done + +wait \ No newline at end of file diff --git a/sh/go.mod.vendor.local.sh b/sh/go.mod.vendor.local.sh index 52c06cc..b0e335b 100755 --- a/sh/go.mod.vendor.local.sh +++ b/sh/go.mod.vendor.local.sh @@ -1,22 +1,22 @@ #!/bin/bash +DIR=$(pwd) +drivers=$($DIR/utils/drivers.sh) + cd ../ ROOT=$(pwd) -go mod vendor - -drivers=$($DIR/utils/drivers.sh) +go mod vendor & for driver in $drivers; do if [ -d "$driver" ]; then echo "\n$driver" - cd $driver && \ - $ROOT/sh/utils/go.mod.replace.default.sh - go mod vendor && \ - $ROOT/sh/utils/go.mod.dropreplace.default.sh + cd $driver && go mod vendor & cd $ROOT fi done + +wait diff --git a/sh/go.work.sync.sh b/sh/go.work.sync.sh new file mode 100755 index 0000000..6473cc7 --- /dev/null +++ b/sh/go.work.sync.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +DIR=$(pwd) +drivers=$($DIR/utils/drivers.sh) + +cd ../ + +ROOT=$(pwd) + +for driver in $drivers; do + if [ -d "$driver" ]; then + echo "\n$driver" + cd $driver && go work sync & + + cd $ROOT + fi +done + +wait \ No newline at end of file From aad94a842f3d89d816a7d5d03e3581acd8607604 Mon Sep 17 00:00:00 2001 From: iasergunin Date: Fri, 15 Dec 2023 23:32:32 +0400 Subject: [PATCH 10/13] 1. fixed postgresql connection --- .github/workflows/main.yaml | 6 ------ drivers/pgxv4/example_test.go | 2 +- drivers/pgxv5/example_test.go | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 51c5d9d..07916f6 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -112,12 +112,6 @@ jobs: - name: Tests with real databases run: make test.coverage.with_real_db - - name: Code coverage data - run: | - set -x - COVERAGE_TOTAL=`go tool covdata func -i=./coverage | grep total | grep -Eo '[0-9]+\.[0-9]+'` - echo "COVERAGE_TOTAL=$COVERAGE_TOTAL" >> $GITHUB_ENV - - name: Coveralls uses: coverallsapp/github-action@v2 with: diff --git a/drivers/pgxv4/example_test.go b/drivers/pgxv4/example_test.go index 32e31d6..f0e11c1 100644 --- a/drivers/pgxv4/example_test.go +++ b/drivers/pgxv4/example_test.go @@ -19,7 +19,7 @@ func Example() { ctx := context.Background() uri := fmt.Sprintf("postgres://%s:%s@%s:%d/%s", - "user", "pass", "localhost", 5432, "drivers", + "user", "pass", "localhost", 5432, "db", ) pool, err := pgxpool.Connect(ctx, uri) diff --git a/drivers/pgxv5/example_test.go b/drivers/pgxv5/example_test.go index fdc5cad..d87d507 100644 --- a/drivers/pgxv5/example_test.go +++ b/drivers/pgxv5/example_test.go @@ -19,7 +19,7 @@ func Example() { ctx := context.Background() uri := fmt.Sprintf("postgres://%s:%s@%s:%d/%s", - "user", "pass", "localhost", 5432, "drivers", + "user", "pass", "localhost", 5432, "db", ) pool, err := pgxpool.New(ctx, uri) From 972b3347a303663ad80fdb98779afd7847e686e1 Mon Sep 17 00:00:00 2001 From: iasergunin Date: Sat, 16 Dec 2023 09:22:21 +0400 Subject: [PATCH 11/13] 1. renamed go-redis-v8 to goredis8 --- README.md | 4 ++-- drivers/{go-redis-v8 => goredis8}/context.go | 8 ++++---- drivers/{go-redis-v8 => goredis8}/example_test.go | 4 ++-- drivers/{go-redis-v8 => goredis8}/factory.go | 2 +- drivers/{go-redis-v8 => goredis8}/go.mod | 2 +- drivers/{go-redis-v8 => goredis8}/go.sum | 0 drivers/{go-redis-v8 => goredis8}/go.work | 0 drivers/{go-redis-v8 => goredis8}/option.go | 2 +- .../{go-redis-v8 => goredis8}/readonly_func_without_tx.go | 2 +- .../readonly_func_without_tx_test.go | 4 ++-- drivers/{go-redis-v8 => goredis8}/settings.go | 2 +- drivers/{go-redis-v8 => goredis8}/transaction.go | 2 +- drivers/{go-redis-v8 => goredis8}/transaction_test.go | 5 +++-- drivers/{go-redis-v8 => goredis8}/watcher.go | 2 +- drivers/{go-redis-v8 => goredis8}/watcher_test.go | 4 ++-- 15 files changed, 22 insertions(+), 21 deletions(-) rename drivers/{go-redis-v8 => goredis8}/context.go (80%) rename drivers/{go-redis-v8 => goredis8}/example_test.go (98%) rename drivers/{go-redis-v8 => goredis8}/factory.go (95%) rename drivers/{go-redis-v8 => goredis8}/go.mod (72%) rename drivers/{go-redis-v8 => goredis8}/go.sum (100%) rename drivers/{go-redis-v8 => goredis8}/go.work (100%) rename drivers/{go-redis-v8 => goredis8}/option.go (97%) rename drivers/{go-redis-v8 => goredis8}/readonly_func_without_tx.go (99%) rename drivers/{go-redis-v8 => goredis8}/readonly_func_without_tx_test.go (99%) rename drivers/{go-redis-v8 => goredis8}/settings.go (99%) rename drivers/{go-redis-v8 => goredis8}/transaction.go (99%) rename drivers/{go-redis-v8 => goredis8}/transaction_test.go (99%) rename drivers/{go-redis-v8 => goredis8}/watcher.go (97%) rename drivers/{go-redis-v8 => goredis8}/watcher_test.go (98%) diff --git a/README.md b/README.md index 0c9d463..6009894 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Easiest way to get the perfect repository. Go 1.18) * [mongo-go-driver](https://github.com/mongodb/mongo-go-driver), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/mongo/v2) ( Go 1.13) -* [go-redis/redis](https://github.com/go-redis/redis), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2) ( +* [go-redis/redis](https://github.com/go-redis/redis), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/goredis8/v2) ( Go 1.17) * [pgx_v4](https://github.com/jackc/pgx/tree/v4), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2) ( Go 1.16) @@ -60,7 +60,7 @@ use [ChainedMW](manager/chain.go) ([docs](https://pkg.go.dev/github.com/github.c * [jmoiron/sqlx](drivers/sqlx/example_test.go) * [gorm](drivers/gorm/example_test.go) * [mongo-go-driver](drivers/mongo/example_test.go) -* [go-redis/redis](drivers/go-redis-v8/example_test.go) +* [go-redis/redis](drivers/goredis8/example_test.go) * [pgx_v4](drivers/pgxv4/example_test.go) * [pgx_v5](drivers/pgxv5/example_test.go) diff --git a/drivers/go-redis-v8/context.go b/drivers/goredis8/context.go similarity index 80% rename from drivers/go-redis-v8/context.go rename to drivers/goredis8/context.go index dc7cc96..1c7edff 100644 --- a/drivers/go-redis-v8/context.go +++ b/drivers/goredis8/context.go @@ -1,4 +1,4 @@ -package go_redis_v8 +package goredis8 import ( "context" @@ -12,7 +12,7 @@ import ( // DefaultCtxGetter is the CtxGetter with settings.DefaultCtxKey. var DefaultCtxGetter = NewCtxGetter(trmcontext.DefaultManager) -// CtxGetter gets go-redis-v8.Pipeliner from trm.СtxManager by casting trm.Transaction to redis.UniversalClient. +// CtxGetter gets goredis8.Pipeliner from trm.СtxManager by casting trm.Transaction to redis.UniversalClient. type CtxGetter struct { ctxManager trm.СtxManager } @@ -22,7 +22,7 @@ func NewCtxGetter(c trm.СtxManager) *CtxGetter { return &CtxGetter{ctxManager: c} } -// DefaultTrOrDB returns Cmdable from context.Context or DB(go-redis-v8.Cmdable) otherwise. +// DefaultTrOrDB returns Cmdable from context.Context or DB(goredis8.Cmdable) otherwise. func (c *CtxGetter) DefaultTrOrDB(ctx context.Context, db redis.Cmdable) redis.Cmdable { if tr := c.ctxManager.Default(ctx); tr != nil { return c.convert(tr) @@ -31,7 +31,7 @@ func (c *CtxGetter) DefaultTrOrDB(ctx context.Context, db redis.Cmdable) redis.C return db } -// TrOrDB returns Cmdable from context.Context by trm.CtxKey or DB(go-redis-v8.Cmdable) otherwise. +// TrOrDB returns Cmdable from context.Context by trm.CtxKey or DB(goredis8.Cmdable) otherwise. func (c *CtxGetter) TrOrDB(ctx context.Context, key trm.CtxKey, db redis.Cmdable) redis.Cmdable { if tr := c.ctxManager.ByKey(ctx, key); tr != nil { return c.convert(tr) diff --git a/drivers/go-redis-v8/example_test.go b/drivers/goredis8/example_test.go similarity index 98% rename from drivers/go-redis-v8/example_test.go rename to drivers/goredis8/example_test.go index 9f8468f..e6b80c9 100644 --- a/drivers/go-redis-v8/example_test.go +++ b/drivers/goredis8/example_test.go @@ -1,7 +1,7 @@ //go:build with_real_db // +build with_real_db -package go_redis_v8_test +package goredis8_test import ( "context" @@ -14,7 +14,7 @@ import ( "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" - trmredis "github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2" + trmredis "github.com/avito-tech/go-transaction-manager/drivers/goredis8/v2" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. diff --git a/drivers/go-redis-v8/factory.go b/drivers/goredis8/factory.go similarity index 95% rename from drivers/go-redis-v8/factory.go rename to drivers/goredis8/factory.go index 426a43f..840f640 100644 --- a/drivers/go-redis-v8/factory.go +++ b/drivers/goredis8/factory.go @@ -1,4 +1,4 @@ -package go_redis_v8 +package goredis8 import ( "context" diff --git a/drivers/go-redis-v8/go.mod b/drivers/goredis8/go.mod similarity index 72% rename from drivers/go-redis-v8/go.mod rename to drivers/goredis8/go.mod index 80ba957..4238800 100644 --- a/drivers/go-redis-v8/go.mod +++ b/drivers/goredis8/go.mod @@ -1,4 +1,4 @@ -module github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2 +module github.com/avito-tech/go-transaction-manager/drivers/goredis8/v2 go 1.13 diff --git a/drivers/go-redis-v8/go.sum b/drivers/goredis8/go.sum similarity index 100% rename from drivers/go-redis-v8/go.sum rename to drivers/goredis8/go.sum diff --git a/drivers/go-redis-v8/go.work b/drivers/goredis8/go.work similarity index 100% rename from drivers/go-redis-v8/go.work rename to drivers/goredis8/go.work diff --git a/drivers/go-redis-v8/option.go b/drivers/goredis8/option.go similarity index 97% rename from drivers/go-redis-v8/option.go rename to drivers/goredis8/option.go index 9ab72c6..b302117 100644 --- a/drivers/go-redis-v8/option.go +++ b/drivers/goredis8/option.go @@ -1,4 +1,4 @@ -package go_redis_v8 +package goredis8 import "github.com/go-redis/redis/v8" diff --git a/drivers/go-redis-v8/readonly_func_without_tx.go b/drivers/goredis8/readonly_func_without_tx.go similarity index 99% rename from drivers/go-redis-v8/readonly_func_without_tx.go rename to drivers/goredis8/readonly_func_without_tx.go index 8dd936a..f6c71ae 100644 --- a/drivers/go-redis-v8/readonly_func_without_tx.go +++ b/drivers/goredis8/readonly_func_without_tx.go @@ -1,4 +1,4 @@ -package go_redis_v8 +package goredis8 import ( "context" diff --git a/drivers/go-redis-v8/readonly_func_without_tx_test.go b/drivers/goredis8/readonly_func_without_tx_test.go similarity index 99% rename from drivers/go-redis-v8/readonly_func_without_tx_test.go rename to drivers/goredis8/readonly_func_without_tx_test.go index 283c829..1d1952b 100644 --- a/drivers/go-redis-v8/readonly_func_without_tx_test.go +++ b/drivers/goredis8/readonly_func_without_tx_test.go @@ -1,14 +1,14 @@ //go:build go1.14 // +build go1.14 -package go_redis_v8 +package goredis8 import ( "context" "testing" "github.com/go-redis/redis/v8" - redismock "github.com/go-redis/redismock/v8" + "github.com/go-redis/redismock/v8" "github.com/stretchr/testify/require" ) diff --git a/drivers/go-redis-v8/settings.go b/drivers/goredis8/settings.go similarity index 99% rename from drivers/go-redis-v8/settings.go rename to drivers/goredis8/settings.go index 23f1017..5f2f5fd 100644 --- a/drivers/go-redis-v8/settings.go +++ b/drivers/goredis8/settings.go @@ -1,4 +1,4 @@ -package go_redis_v8 +package goredis8 import ( "github.com/go-redis/redis/v8" diff --git a/drivers/go-redis-v8/transaction.go b/drivers/goredis8/transaction.go similarity index 99% rename from drivers/go-redis-v8/transaction.go rename to drivers/goredis8/transaction.go index 53a8cdd..b8c2111 100644 --- a/drivers/go-redis-v8/transaction.go +++ b/drivers/goredis8/transaction.go @@ -1,5 +1,5 @@ // Package go_redis_v8 is an implementation of trm.Transaction interface by Transaction for redis.UniversalClient. -package go_redis_v8 +package goredis8 import ( "context" diff --git a/drivers/go-redis-v8/transaction_test.go b/drivers/goredis8/transaction_test.go similarity index 99% rename from drivers/go-redis-v8/transaction_test.go rename to drivers/goredis8/transaction_test.go index 512592f..dd5409b 100644 --- a/drivers/go-redis-v8/transaction_test.go +++ b/drivers/goredis8/transaction_test.go @@ -1,7 +1,7 @@ //go:build go1.14 // +build go1.14 -package go_redis_v8 +package goredis8 import ( "context" @@ -13,9 +13,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/go-redis/redismock/v8" + trm "github.com/avito-tech/go-transaction-manager/v2" "github.com/avito-tech/go-transaction-manager/v2/mock" - "github.com/go-redis/redismock/v8" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" diff --git a/drivers/go-redis-v8/watcher.go b/drivers/goredis8/watcher.go similarity index 97% rename from drivers/go-redis-v8/watcher.go rename to drivers/goredis8/watcher.go index bc3b815..8d6ffee 100644 --- a/drivers/go-redis-v8/watcher.go +++ b/drivers/goredis8/watcher.go @@ -1,4 +1,4 @@ -package go_redis_v8 +package goredis8 import ( "context" diff --git a/drivers/go-redis-v8/watcher_test.go b/drivers/goredis8/watcher_test.go similarity index 98% rename from drivers/go-redis-v8/watcher_test.go rename to drivers/goredis8/watcher_test.go index f6375e4..eaa0c74 100644 --- a/drivers/go-redis-v8/watcher_test.go +++ b/drivers/goredis8/watcher_test.go @@ -1,7 +1,7 @@ //go:build with_real_db // +build with_real_db -package go_redis_v8_test +package goredis8_test import ( "context" @@ -14,7 +14,7 @@ import ( "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" - trmredis "github.com/avito-tech/go-transaction-manager/drivers/go-redis-v8/v2" + trmredis "github.com/avito-tech/go-transaction-manager/drivers/goredis8/v2" ) // Example demonstrates the watching of updated keys. From a533663a2a64a7cc21f66d22e5557db8fe4540d6 Mon Sep 17 00:00:00 2001 From: iasergunin Date: Sat, 16 Dec 2023 18:48:09 +0400 Subject: [PATCH 12/13] 1. renamed tag version --- README.md | 7 +++++-- drivers/goredis8/example_test.go | 3 +-- drivers/goredis8/go.mod | 3 +-- drivers/goredis8/go.sum | 2 ++ drivers/goredis8/watcher_test.go | 3 +-- drivers/gorm/example_test.go | 1 + drivers/gorm/go.mod | 3 +-- drivers/gorm/go.sum | 2 ++ drivers/mongo/go.mod | 2 +- drivers/pgxv4/go.mod | 2 +- drivers/pgxv4/go.sum | 2 ++ drivers/pgxv5/go.mod | 3 +-- drivers/pgxv5/go.sum | 2 ++ drivers/sql/go.mod | 4 ++-- drivers/sql/go.sum | 2 ++ drivers/sqlx/go.mod | 4 ++-- drivers/sqlx/go.work.sum | 1 - sh/go.mod.vendor.local.sh | 22 ---------------------- sh/go.mod.vendor.sh | 9 +++++---- 19 files changed, 32 insertions(+), 45 deletions(-) delete mode 100644 drivers/sqlx/go.work.sum delete mode 100755 sh/go.mod.vendor.local.sh diff --git a/README.md b/README.md index 6009894..d31be6a 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Easiest way to get the perfect repository. go get github.com/avito-tech/go-transaction-manager/v2 ``` -To install some support database use `go get github.com/avito-tech/go-transaction-manager/drivers/{name}/v2`. +To install some support database use `go get github.com/avito-tech/go-transaction-manager/v2/drivers/{name}`. For example `go get github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2`. @@ -163,5 +163,8 @@ func (r *repo) Save(ctx context.Context, u *user) error { ## Contribution -* To install all dependencies use `make go.mod.vendor`. +1. To local development sync dependencies by `make go.work.sync`. +2. After finalizing of changes bump up version in all drivers. + +* To install all dependencies use `make go.mod.tidy` or `make go.mod.vendor`. * To run all tests use `make go.test` or `make go.test.with_real_db` for integration tests. \ No newline at end of file diff --git a/drivers/goredis8/example_test.go b/drivers/goredis8/example_test.go index e6b80c9..185135a 100644 --- a/drivers/goredis8/example_test.go +++ b/drivers/goredis8/example_test.go @@ -10,11 +10,10 @@ import ( "github.com/go-redis/redis/v8" + trmredis "github.com/avito-tech/go-transaction-manager/drivers/goredis8/v2" trm "github.com/avito-tech/go-transaction-manager/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" - - trmredis "github.com/avito-tech/go-transaction-manager/drivers/goredis8/v2" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. diff --git a/drivers/goredis8/go.mod b/drivers/goredis8/go.mod index 4238800..8d8f2d3 100644 --- a/drivers/goredis8/go.mod +++ b/drivers/goredis8/go.mod @@ -3,9 +3,8 @@ module github.com/avito-tech/go-transaction-manager/drivers/goredis8/v2 go 1.13 require ( - github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 github.com/go-redis/redis/v8 v8.11.5 github.com/go-redis/redismock/v8 v8.11.5 github.com/stretchr/testify v1.8.2 ) - diff --git a/drivers/goredis8/go.sum b/drivers/goredis8/go.sum index 5594999..b3c3a7c 100644 --- a/drivers/goredis8/go.sum +++ b/drivers/goredis8/go.sum @@ -1,4 +1,6 @@ github.com/DATA-DOG/go-sqlmock v1.5.1/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= +github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 h1:T40OayD/EdYn1uSUg0+8whVYhzgkTDN9dVPuwGQd4jM= +github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1/go.mod h1:zl4uvbnlVO7ZCaD2Nz3tn776TmkwUykDYGVqpkmO4zo= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= diff --git a/drivers/goredis8/watcher_test.go b/drivers/goredis8/watcher_test.go index eaa0c74..47081b6 100644 --- a/drivers/goredis8/watcher_test.go +++ b/drivers/goredis8/watcher_test.go @@ -10,11 +10,10 @@ import ( "github.com/go-redis/redis/v8" + trmredis "github.com/avito-tech/go-transaction-manager/drivers/goredis8/v2" trm "github.com/avito-tech/go-transaction-manager/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" - - trmredis "github.com/avito-tech/go-transaction-manager/drivers/goredis8/v2" ) // Example demonstrates the watching of updated keys. diff --git a/drivers/gorm/example_test.go b/drivers/gorm/example_test.go index bd05850..b1939a6 100644 --- a/drivers/gorm/example_test.go +++ b/drivers/gorm/example_test.go @@ -12,6 +12,7 @@ import ( "gorm.io/gorm" trmgorm "github.com/avito-tech/go-transaction-manager/drivers/gorm/v2" + trm "github.com/avito-tech/go-transaction-manager/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" diff --git a/drivers/gorm/go.mod b/drivers/gorm/go.mod index 35ee394..418a3d1 100644 --- a/drivers/gorm/go.mod +++ b/drivers/gorm/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/DATA-DOG/go-sqlmock v1.5.1 - github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 github.com/mattn/go-sqlite3 v1.14.18 github.com/stretchr/testify v1.8.2 gorm.io/driver/mysql v1.5.2 @@ -23,4 +23,3 @@ require ( go.uber.org/multierr v1.9.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) - diff --git a/drivers/gorm/go.sum b/drivers/gorm/go.sum index 2d9394c..f1694ab 100644 --- a/drivers/gorm/go.sum +++ b/drivers/gorm/go.sum @@ -1,5 +1,7 @@ github.com/DATA-DOG/go-sqlmock v1.5.1 h1:FK6RCIUSfmbnI/imIICmboyQBkOckutaa6R5YYlLZyo= github.com/DATA-DOG/go-sqlmock v1.5.1/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= +github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 h1:T40OayD/EdYn1uSUg0+8whVYhzgkTDN9dVPuwGQd4jM= +github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1/go.mod h1:zl4uvbnlVO7ZCaD2Nz3tn776TmkwUykDYGVqpkmO4zo= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/drivers/mongo/go.mod b/drivers/mongo/go.mod index ab2b655..9e7bd58 100644 --- a/drivers/mongo/go.mod +++ b/drivers/mongo/go.mod @@ -4,7 +4,7 @@ go 1.13 require ( github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 - github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 github.com/mattn/go-sqlite3 v1.14.18 github.com/stretchr/testify v1.8.2 go.mongodb.org/mongo-driver v1.13.1 diff --git a/drivers/pgxv4/go.mod b/drivers/pgxv4/go.mod index 6b15a1c..1d727f6 100644 --- a/drivers/pgxv4/go.mod +++ b/drivers/pgxv4/go.mod @@ -3,7 +3,7 @@ module github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2 go 1.13 require ( - github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 github.com/jackc/pgconn v1.14.1 github.com/jackc/pgx/v4 v4.18.1 github.com/pashagolub/pgxmock v1.8.0 diff --git a/drivers/pgxv4/go.sum b/drivers/pgxv4/go.sum index afb39d5..1fb4524 100644 --- a/drivers/pgxv4/go.sum +++ b/drivers/pgxv4/go.sum @@ -2,6 +2,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/DATA-DOG/go-sqlmock v1.5.1/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 h1:T40OayD/EdYn1uSUg0+8whVYhzgkTDN9dVPuwGQd4jM= +github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1/go.mod h1:zl4uvbnlVO7ZCaD2Nz3tn776TmkwUykDYGVqpkmO4zo= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= diff --git a/drivers/pgxv5/go.mod b/drivers/pgxv5/go.mod index 43f85f3..7e61756 100644 --- a/drivers/pgxv5/go.mod +++ b/drivers/pgxv5/go.mod @@ -3,9 +3,8 @@ module github.com/avito-tech/go-transaction-manager/drivers/pgxv5/v2 go 1.13 require ( - github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 github.com/jackc/pgx/v5 v5.5.1 github.com/pashagolub/pgxmock/v2 v2.12.0 github.com/stretchr/testify v1.8.2 ) - diff --git a/drivers/pgxv5/go.sum b/drivers/pgxv5/go.sum index 8db70f4..091a707 100644 --- a/drivers/pgxv5/go.sum +++ b/drivers/pgxv5/go.sum @@ -1,4 +1,6 @@ github.com/DATA-DOG/go-sqlmock v1.5.1/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= +github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 h1:T40OayD/EdYn1uSUg0+8whVYhzgkTDN9dVPuwGQd4jM= +github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1/go.mod h1:zl4uvbnlVO7ZCaD2Nz3tn776TmkwUykDYGVqpkmO4zo= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/drivers/sql/go.mod b/drivers/sql/go.mod index 0e5263d..623c842 100644 --- a/drivers/sql/go.mod +++ b/drivers/sql/go.mod @@ -3,8 +3,8 @@ module github.com/avito-tech/go-transaction-manager/drivers/sql/v2 go 1.13 require ( - github.com/DATA-DOG/go-sqlmock v1.5.0 - github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/DATA-DOG/go-sqlmock v1.5.1 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 github.com/golang/mock v1.6.0 github.com/mattn/go-sqlite3 v1.14.18 github.com/stretchr/testify v1.8.2 diff --git a/drivers/sql/go.sum b/drivers/sql/go.sum index b125e85..05e39b7 100644 --- a/drivers/sql/go.sum +++ b/drivers/sql/go.sum @@ -1,5 +1,7 @@ github.com/DATA-DOG/go-sqlmock v1.5.1 h1:FK6RCIUSfmbnI/imIICmboyQBkOckutaa6R5YYlLZyo= github.com/DATA-DOG/go-sqlmock v1.5.1/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU= +github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 h1:T40OayD/EdYn1uSUg0+8whVYhzgkTDN9dVPuwGQd4jM= +github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1/go.mod h1:zl4uvbnlVO7ZCaD2Nz3tn776TmkwUykDYGVqpkmO4zo= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/drivers/sqlx/go.mod b/drivers/sqlx/go.mod index 7a020e5..bcfd641 100644 --- a/drivers/sqlx/go.mod +++ b/drivers/sqlx/go.mod @@ -4,8 +4,8 @@ go 1.13 require ( github.com/DATA-DOG/go-sqlmock v1.5.1 - github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 - github.com/avito-tech/go-transaction-manager/v2 v2.0.0 + github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0-rc1 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 github.com/jmoiron/sqlx v1.3.5 github.com/mattn/go-sqlite3 v1.14.18 github.com/stretchr/testify v1.8.2 diff --git a/drivers/sqlx/go.work.sum b/drivers/sqlx/go.work.sum deleted file mode 100644 index 1a8b847..0000000 --- a/drivers/sqlx/go.work.sum +++ /dev/null @@ -1 +0,0 @@ -github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= diff --git a/sh/go.mod.vendor.local.sh b/sh/go.mod.vendor.local.sh deleted file mode 100755 index b0e335b..0000000 --- a/sh/go.mod.vendor.local.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -DIR=$(pwd) -drivers=$($DIR/utils/drivers.sh) - -cd ../ - -ROOT=$(pwd) - -go mod vendor & - -for driver in $drivers; do - if [ -d "$driver" ]; then - echo "\n$driver" - - cd $driver && go mod vendor & - - cd $ROOT - fi -done - -wait diff --git a/sh/go.mod.vendor.sh b/sh/go.mod.vendor.sh index 4722a1b..271f0d3 100755 --- a/sh/go.mod.vendor.sh +++ b/sh/go.mod.vendor.sh @@ -1,17 +1,18 @@ #!/bin/bash +DIR=$(pwd) +drivers=$($DIR/utils/drivers.sh) + cd ../ ROOT=$(pwd) -go mod vendor - -drivers=$($DIR/utils/drivers.sh) +go mod vendor & for driver in $drivers; do if [ -d "$driver" ]; then echo "\n$driver" - cd $driver && go mod vendor + cd $driver && go mod vendor & cd $ROOT fi From 40f6cee0383c856674132cf8e875e862f2c5471a Mon Sep 17 00:00:00 2001 From: iasergunin Date: Sat, 16 Dec 2023 19:10:21 +0400 Subject: [PATCH 13/13] 1. try rename --- README.md | 18 +++++++++--------- drivers/goredis8/example_test.go | 3 ++- drivers/goredis8/go.mod | 4 ++-- drivers/goredis8/watcher_test.go | 3 ++- drivers/gorm/example_test.go | 2 +- drivers/gorm/go.mod | 4 ++-- drivers/gorm/go.work | 2 +- drivers/mongo/example_test.go | 12 +++++------- drivers/mongo/go.mod | 6 +++--- drivers/mongo/go.work | 2 +- drivers/pgxv4/example_test.go | 2 +- drivers/pgxv4/go.mod | 4 ++-- drivers/pgxv5/example_test.go | 2 +- drivers/pgxv5/go.mod | 4 ++-- drivers/sql/example_test.go | 2 +- drivers/sql/go.mod | 4 ++-- drivers/sqlx/chained_example_test.go | 2 +- drivers/sqlx/example_test.go | 2 +- drivers/sqlx/factory.go | 2 +- drivers/sqlx/go.mod | 6 +++--- drivers/sqlx/go.work | 2 +- drivers/sqlx/transaction.go | 2 +- .../with_or_without_trm/trm_test.go.skip | 2 +- .../with_or_without_trm/trmrepo.go.skip | 2 +- 24 files changed, 47 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index d31be6a..dfe8aeb 100644 --- a/README.md +++ b/README.md @@ -12,19 +12,19 @@ Easiest way to get the perfect repository. ## Supported implementations -* [database/sql](https://pkg.go.dev/database/sql), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/sql/v2) ( +* [database/sql](https://pkg.go.dev/database/sql), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/v2/drivers/sql/v2) ( Go 1.13) -* [jmoiron/sqlx](https://github.com/jmoiron/sqlx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2) ( +* [jmoiron/sqlx](https://github.com/jmoiron/sqlx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/v2/drivers/sqlx/v2) ( Go 1.13) -* [gorm](https://github.com/go-gorm/gorm), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/gorm/v2) ( +* [gorm](https://github.com/go-gorm/gorm), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/v2/drivers/gorm/v2) ( Go 1.18) -* [mongo-go-driver](https://github.com/mongodb/mongo-go-driver), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/mongo/v2) ( +* [mongo-go-driver](https://github.com/mongodb/mongo-go-driver), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/v2/drivers/mongo/v2) ( Go 1.13) -* [go-redis/redis](https://github.com/go-redis/redis), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/goredis8/v2) ( +* [go-redis/redis](https://github.com/go-redis/redis), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/v2/drivers/goredis8/v2) ( Go 1.17) -* [pgx_v4](https://github.com/jackc/pgx/tree/v4), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2) ( +* [pgx_v4](https://github.com/jackc/pgx/tree/v4), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/v2/drivers/pgxv4/v2) ( Go 1.16) -* [pgx_v5](https://github.com/jackc/pgx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/drivers/pgxv5/v2) ( +* [pgx_v5](https://github.com/jackc/pgx), [docs](https://pkg.go.dev/github.com/avito-tech/go-transaction-manager/v2/drivers/pgxv5/v2) ( Go 1.19) ## Installation @@ -35,7 +35,7 @@ go get github.com/avito-tech/go-transaction-manager/v2 To install some support database use `go get github.com/avito-tech/go-transaction-manager/v2/drivers/{name}`. -For example `go get github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2`. +For example `go get github.com/avito-tech/go-transaction-manager/v2/drivers/sqlx/v2`. ### Backwards Compatibility @@ -76,7 +76,7 @@ import ( "github.com/jmoiron/sqlx" _ "github.com/mattn/go-sqlite3" - trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" + trmsqlx "github.com/avito-tech/go-transaction-manager/v2/drivers/sqlx/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" ) diff --git a/drivers/goredis8/example_test.go b/drivers/goredis8/example_test.go index 185135a..f0196fd 100644 --- a/drivers/goredis8/example_test.go +++ b/drivers/goredis8/example_test.go @@ -10,7 +10,8 @@ import ( "github.com/go-redis/redis/v8" - trmredis "github.com/avito-tech/go-transaction-manager/drivers/goredis8/v2" + trmredis "github.com/avito-tech/go-transaction-manager/v2/drivers/goredis8/v2" + trm "github.com/avito-tech/go-transaction-manager/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" diff --git a/drivers/goredis8/go.mod b/drivers/goredis8/go.mod index 8d8f2d3..cd631dd 100644 --- a/drivers/goredis8/go.mod +++ b/drivers/goredis8/go.mod @@ -1,9 +1,9 @@ -module github.com/avito-tech/go-transaction-manager/drivers/goredis8/v2 +module github.com/avito-tech/go-transaction-manager/v2/drivers/goredis8/v2 go 1.13 require ( - github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc4 github.com/go-redis/redis/v8 v8.11.5 github.com/go-redis/redismock/v8 v8.11.5 github.com/stretchr/testify v1.8.2 diff --git a/drivers/goredis8/watcher_test.go b/drivers/goredis8/watcher_test.go index 47081b6..53bbff5 100644 --- a/drivers/goredis8/watcher_test.go +++ b/drivers/goredis8/watcher_test.go @@ -10,7 +10,8 @@ import ( "github.com/go-redis/redis/v8" - trmredis "github.com/avito-tech/go-transaction-manager/drivers/goredis8/v2" + trmredis "github.com/avito-tech/go-transaction-manager/v2/drivers/goredis8/v2" + trm "github.com/avito-tech/go-transaction-manager/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" diff --git a/drivers/gorm/example_test.go b/drivers/gorm/example_test.go index b1939a6..351cd20 100644 --- a/drivers/gorm/example_test.go +++ b/drivers/gorm/example_test.go @@ -11,7 +11,7 @@ import ( "gorm.io/driver/sqlite" "gorm.io/gorm" - trmgorm "github.com/avito-tech/go-transaction-manager/drivers/gorm/v2" + trmgorm "github.com/avito-tech/go-transaction-manager/v2/drivers/gorm/v2" trm "github.com/avito-tech/go-transaction-manager/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" diff --git a/drivers/gorm/go.mod b/drivers/gorm/go.mod index 418a3d1..114aaee 100644 --- a/drivers/gorm/go.mod +++ b/drivers/gorm/go.mod @@ -1,10 +1,10 @@ -module github.com/avito-tech/go-transaction-manager/drivers/gorm/v2 +module github.com/avito-tech/go-transaction-manager/v2/drivers/gorm/v2 go 1.18 require ( github.com/DATA-DOG/go-sqlmock v1.5.1 - github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc4 github.com/mattn/go-sqlite3 v1.14.18 github.com/stretchr/testify v1.8.2 gorm.io/driver/mysql v1.5.2 diff --git a/drivers/gorm/go.work b/drivers/gorm/go.work index 6e5594f..1f1884b 100644 --- a/drivers/gorm/go.work +++ b/drivers/gorm/go.work @@ -4,4 +4,4 @@ use . replace github.com/avito-tech/go-transaction-manager/v2 => ../../ -replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 => ../sql +replace github.com/avito-tech/go-transaction-manager/v2/drivers/sql/v2 => ../sql diff --git a/drivers/mongo/example_test.go b/drivers/mongo/example_test.go index 239563c..acc3d70 100644 --- a/drivers/mongo/example_test.go +++ b/drivers/mongo/example_test.go @@ -12,21 +12,19 @@ import ( "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo/options" - trmmongo "github.com/avito-tech/go-transaction-manager/drivers/mongo/v2" - trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" + trmmongo "github.com/avito-tech/go-transaction-manager/v2/drivers/mongo/v2" + trmsql "github.com/avito-tech/go-transaction-manager/v2/drivers/sql/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" ) // Example demonstrates the implementation of the Repository pattern by trm.Manager. func Example() { - client, err := mongo.NewClient(options.Client(). - ApplyURI("mongodb://127.0.0.1:27017")) - checkErr(err) - ctx := context.Background() - checkErr(client.Connect(ctx)) + client, err := mongo.Connect(ctx, options.Client(). + ApplyURI("mongodb://127.0.0.1:27017")) + checkErr(err) collection := client.Database("test").Collection("users") diff --git a/drivers/mongo/go.mod b/drivers/mongo/go.mod index 9e7bd58..a946a3a 100644 --- a/drivers/mongo/go.mod +++ b/drivers/mongo/go.mod @@ -1,10 +1,10 @@ -module github.com/avito-tech/go-transaction-manager/drivers/mongo/v2 +module github.com/avito-tech/go-transaction-manager/v2/drivers/mongo/v2 go 1.13 require ( - github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0 - github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 + github.com/avito-tech/go-transaction-manager/v2/drivers/sql/v2 v2.0.0-rc4 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc4 github.com/mattn/go-sqlite3 v1.14.18 github.com/stretchr/testify v1.8.2 go.mongodb.org/mongo-driver v1.13.1 diff --git a/drivers/mongo/go.work b/drivers/mongo/go.work index 6e5594f..1f1884b 100644 --- a/drivers/mongo/go.work +++ b/drivers/mongo/go.work @@ -4,4 +4,4 @@ use . replace github.com/avito-tech/go-transaction-manager/v2 => ../../ -replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 => ../sql +replace github.com/avito-tech/go-transaction-manager/v2/drivers/sql/v2 => ../sql diff --git a/drivers/pgxv4/example_test.go b/drivers/pgxv4/example_test.go index f0e11c1..f3fe1cf 100644 --- a/drivers/pgxv4/example_test.go +++ b/drivers/pgxv4/example_test.go @@ -9,7 +9,7 @@ import ( "github.com/jackc/pgx/v4/pgxpool" - trmpgx "github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2" + trmpgx "github.com/avito-tech/go-transaction-manager/v2/drivers/pgxv4/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" ) diff --git a/drivers/pgxv4/go.mod b/drivers/pgxv4/go.mod index 1d727f6..ba6d0af 100644 --- a/drivers/pgxv4/go.mod +++ b/drivers/pgxv4/go.mod @@ -1,9 +1,9 @@ -module github.com/avito-tech/go-transaction-manager/drivers/pgxv4/v2 +module github.com/avito-tech/go-transaction-manager/v2/drivers/pgxv4/v2 go 1.13 require ( - github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc4 github.com/jackc/pgconn v1.14.1 github.com/jackc/pgx/v4 v4.18.1 github.com/pashagolub/pgxmock v1.8.0 diff --git a/drivers/pgxv5/example_test.go b/drivers/pgxv5/example_test.go index d87d507..b43a316 100644 --- a/drivers/pgxv5/example_test.go +++ b/drivers/pgxv5/example_test.go @@ -9,7 +9,7 @@ import ( "github.com/jackc/pgx/v5/pgxpool" - trmpgx "github.com/avito-tech/go-transaction-manager/drivers/pgxv5/v2" + trmpgx "github.com/avito-tech/go-transaction-manager/v2/drivers/pgxv5/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" ) diff --git a/drivers/pgxv5/go.mod b/drivers/pgxv5/go.mod index 7e61756..18a8473 100644 --- a/drivers/pgxv5/go.mod +++ b/drivers/pgxv5/go.mod @@ -1,9 +1,9 @@ -module github.com/avito-tech/go-transaction-manager/drivers/pgxv5/v2 +module github.com/avito-tech/go-transaction-manager/v2/drivers/pgxv5/v2 go 1.13 require ( - github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc4 github.com/jackc/pgx/v5 v5.5.1 github.com/pashagolub/pgxmock/v2 v2.12.0 github.com/stretchr/testify v1.8.2 diff --git a/drivers/sql/example_test.go b/drivers/sql/example_test.go index 1a6c83e..92a6aad 100644 --- a/drivers/sql/example_test.go +++ b/drivers/sql/example_test.go @@ -7,7 +7,7 @@ import ( _ "github.com/mattn/go-sqlite3" - trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" + trmsql "github.com/avito-tech/go-transaction-manager/v2/drivers/sql/v2" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" diff --git a/drivers/sql/go.mod b/drivers/sql/go.mod index 623c842..ac5ba18 100644 --- a/drivers/sql/go.mod +++ b/drivers/sql/go.mod @@ -1,10 +1,10 @@ -module github.com/avito-tech/go-transaction-manager/drivers/sql/v2 +module github.com/avito-tech/go-transaction-manager/v2/drivers/sql/v2 go 1.13 require ( github.com/DATA-DOG/go-sqlmock v1.5.1 - github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc4 github.com/golang/mock v1.6.0 github.com/mattn/go-sqlite3 v1.14.18 github.com/stretchr/testify v1.8.2 diff --git a/drivers/sqlx/chained_example_test.go b/drivers/sqlx/chained_example_test.go index c98d54f..6528384 100644 --- a/drivers/sqlx/chained_example_test.go +++ b/drivers/sqlx/chained_example_test.go @@ -6,9 +6,9 @@ import ( _ "github.com/mattn/go-sqlite3" - trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" trm "github.com/avito-tech/go-transaction-manager/v2" trmcontext "github.com/avito-tech/go-transaction-manager/v2/context" + trmsqlx "github.com/avito-tech/go-transaction-manager/v2/drivers/sqlx/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" "github.com/avito-tech/go-transaction-manager/v2/settings" ) diff --git a/drivers/sqlx/example_test.go b/drivers/sqlx/example_test.go index c9132dc..350a1ad 100644 --- a/drivers/sqlx/example_test.go +++ b/drivers/sqlx/example_test.go @@ -7,7 +7,7 @@ import ( "github.com/jmoiron/sqlx" _ "github.com/mattn/go-sqlite3" - trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" + trmsqlx "github.com/avito-tech/go-transaction-manager/v2/drivers/sqlx/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" ) diff --git a/drivers/sqlx/factory.go b/drivers/sqlx/factory.go index d8fb698..bec1357 100644 --- a/drivers/sqlx/factory.go +++ b/drivers/sqlx/factory.go @@ -5,7 +5,7 @@ import ( "github.com/jmoiron/sqlx" - trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" + trmsql "github.com/avito-tech/go-transaction-manager/v2/drivers/sql/v2" trm "github.com/avito-tech/go-transaction-manager/v2" ) diff --git a/drivers/sqlx/go.mod b/drivers/sqlx/go.mod index bcfd641..4f5d5fc 100644 --- a/drivers/sqlx/go.mod +++ b/drivers/sqlx/go.mod @@ -1,11 +1,11 @@ -module github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2 +module github.com/avito-tech/go-transaction-manager/v2/drivers/sqlx/v2 go 1.13 require ( github.com/DATA-DOG/go-sqlmock v1.5.1 - github.com/avito-tech/go-transaction-manager/drivers/sql/v2 v2.0.0-rc1 - github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc1 + github.com/avito-tech/go-transaction-manager/v2/drivers/sql/v2 v2.0.0-rc4 + github.com/avito-tech/go-transaction-manager/v2 v2.0.0-rc4 github.com/jmoiron/sqlx v1.3.5 github.com/mattn/go-sqlite3 v1.14.18 github.com/stretchr/testify v1.8.2 diff --git a/drivers/sqlx/go.work b/drivers/sqlx/go.work index 6e5594f..1f1884b 100644 --- a/drivers/sqlx/go.work +++ b/drivers/sqlx/go.work @@ -4,4 +4,4 @@ use . replace github.com/avito-tech/go-transaction-manager/v2 => ../../ -replace github.com/avito-tech/go-transaction-manager/drivers/sql/v2 => ../sql +replace github.com/avito-tech/go-transaction-manager/v2/drivers/sql/v2 => ../sql diff --git a/drivers/sqlx/transaction.go b/drivers/sqlx/transaction.go index 9f12b8c..dd354c5 100644 --- a/drivers/sqlx/transaction.go +++ b/drivers/sqlx/transaction.go @@ -9,7 +9,7 @@ import ( "github.com/jmoiron/sqlx" "go.uber.org/multierr" - trmsql "github.com/avito-tech/go-transaction-manager/drivers/sql/v2" + trmsql "github.com/avito-tech/go-transaction-manager/v2/drivers/sql/v2" trm "github.com/avito-tech/go-transaction-manager/v2" ) diff --git a/internal/benchmark/with_or_without_trm/trm_test.go.skip b/internal/benchmark/with_or_without_trm/trm_test.go.skip index 9c16573..5a33df3 100644 --- a/internal/benchmark/with_or_without_trm/trm_test.go.skip +++ b/internal/benchmark/with_or_without_trm/trm_test.go.skip @@ -8,7 +8,7 @@ import ( _ "github.com/mattn/go-sqlite3" "github.com/stretchr/testify/require" - trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" + trmsqlx "github.com/avito-tech/go-transaction-manager/v2/drivers/sqlx/v2" "github.com/avito-tech/go-transaction-manager/v2/manager" ) diff --git a/internal/benchmark/with_or_without_trm/trmrepo.go.skip b/internal/benchmark/with_or_without_trm/trmrepo.go.skip index 7a21865..4860f6e 100644 --- a/internal/benchmark/with_or_without_trm/trmrepo.go.skip +++ b/internal/benchmark/with_or_without_trm/trmrepo.go.skip @@ -5,7 +5,7 @@ import ( "github.com/jmoiron/sqlx" - trmsqlx "github.com/avito-tech/go-transaction-manager/drivers/sqlx/v2" + trmsqlx "github.com/avito-tech/go-transaction-manager/v2/drivers/sqlx/v2" ) type trmRepo struct {