refactor: Update internal/db and oplog to use go-dbw package for database operations. (#1785)

* chore: Add new dbw dependency

* refactor: Convert to use dbw.DB

* refactor (db): Change GetTicket(...) signature

* feature (db tests): Added TestDeleteWhere(...)
Adding this allows us to eliminate a leak of the gorm library

* refactor: Add ctx to ScanRows(...) signature
This is required to refactor all the deprecated errors pkg calls.
This refactor required adding a context to quite a few call chains
and in particular the job scheduler bits

* feature (db/tests): Add support for test opt: WithTestLogLevel(...)
This test only option allows callers to specify a log level for the
underlying db package (where supported/applicable) when calling
TestSetup(...)

* refactor (db): Simplify Db type
Only store the underlying *DB and create the *RW on demand when
needed.

* refactor (oplog): Port to using dbw pkg for db operations

* refactor (db): Remove gormDB(...) func

* tests (db): Add unit tests for TestDeleteWhere(...)

* chore: make fmt changes to formatting
This commit is contained in:
Jim authored and GitHub committed 2022-01-05 14:38:38 -05:00
1 parent 002d004114
commit 591ec476e7
160 files changed
+4369 -3164

No files matched your search

+8 -8
View File
@@ -150,8 +150,8 @@ func errorInterceptor(
return func(interceptorCtx context.Context,
req interface{},
_ *grpc.UnaryServerInfo,
handler grpc.UnaryHandler) (interface{}, error) {
handler grpc.UnaryHandler) (interface{}, error,
) {
// call the handler...
h, handlerErr := handler(interceptorCtx, req)
@@ -201,8 +201,8 @@ func statusCodeInterceptor(
return func(interceptorCtx context.Context,
req interface{},
_ *grpc.UnaryServerInfo,
handler grpc.UnaryHandler) (interface{}, error) {
handler grpc.UnaryHandler) (interface{}, error,
) {
// call the handler...
h, handlerErr := handler(interceptorCtx, req)
@@ -237,8 +237,8 @@ func auditRequestInterceptor(
return func(interceptorCtx context.Context,
req interface{},
_ *grpc.UnaryServerInfo,
handler grpc.UnaryHandler) (interface{}, error) {
handler grpc.UnaryHandler) (interface{}, error,
) {
if msg, ok := req.(proto.Message); ok {
if err := event.WriteAudit(interceptorCtx, op, event.WithRequest(&event.Request{Details: msg})); err != nil {
return req, status.Errorf(codes.Internal, "unable to write request msg audit: %s", err)
@@ -256,8 +256,8 @@ func auditResponseInterceptor(
return func(interceptorCtx context.Context,
req interface{},
_ *grpc.UnaryServerInfo,
handler grpc.UnaryHandler) (interface{}, error) {
handler grpc.UnaryHandler) (interface{}, error,
) {
// call the handler...
resp, err := handler(interceptorCtx, req)