chore: refactor (#1814)
This commit is contained in:
@@ -21,7 +21,7 @@ type (
|
||||
opts []Option
|
||||
}
|
||||
|
||||
wrapSession struct {
|
||||
wrappedSession struct {
|
||||
mongo.Session
|
||||
brk breaker.Breaker
|
||||
}
|
||||
@@ -74,7 +74,10 @@ func (m *Model) StartSession(opts ...*mopt.SessionOptions) (sess mongo.Session,
|
||||
return sessionErr
|
||||
}
|
||||
|
||||
sess = &wrapSession{Session: session, brk: m.brk}
|
||||
sess = &wrappedSession{
|
||||
Session: session,
|
||||
brk: m.brk,
|
||||
}
|
||||
|
||||
return nil
|
||||
}, acceptable)
|
||||
@@ -166,7 +169,7 @@ func (m *Model) FindOneAndUpdate(ctx context.Context, v, filter interface{}, upd
|
||||
return res.Decode(v)
|
||||
}
|
||||
|
||||
func (w *wrapSession) AbortTransaction(ctx context.Context) error {
|
||||
func (w *wrappedSession) AbortTransaction(ctx context.Context) error {
|
||||
ctx, span := startSpan(ctx)
|
||||
defer span.End()
|
||||
|
||||
@@ -175,7 +178,7 @@ func (w *wrapSession) AbortTransaction(ctx context.Context) error {
|
||||
}, acceptable)
|
||||
}
|
||||
|
||||
func (w *wrapSession) CommitTransaction(ctx context.Context) error {
|
||||
func (w *wrappedSession) CommitTransaction(ctx context.Context) error {
|
||||
ctx, span := startSpan(ctx)
|
||||
defer span.End()
|
||||
|
||||
@@ -184,7 +187,11 @@ func (w *wrapSession) CommitTransaction(ctx context.Context) error {
|
||||
}, acceptable)
|
||||
}
|
||||
|
||||
func (w *wrapSession) WithTransaction(ctx context.Context, fn func(sessCtx mongo.SessionContext) (interface{}, error), opts ...*mopt.TransactionOptions) (res interface{}, err error) {
|
||||
func (w *wrappedSession) WithTransaction(
|
||||
ctx context.Context,
|
||||
fn func(sessCtx mongo.SessionContext) (interface{}, error),
|
||||
opts ...*mopt.TransactionOptions,
|
||||
) (res interface{}, err error) {
|
||||
ctx, span := startSpan(ctx)
|
||||
defer span.End()
|
||||
|
||||
@@ -196,7 +203,7 @@ func (w *wrapSession) WithTransaction(ctx context.Context, fn func(sessCtx mongo
|
||||
return
|
||||
}
|
||||
|
||||
func (w *wrapSession) EndSession(ctx context.Context) {
|
||||
func (w *wrappedSession) EndSession(ctx context.Context) {
|
||||
ctx, span := startSpan(ctx)
|
||||
defer span.End()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user