Skip to content

Commit

Permalink
Revert unneeded change
Browse files Browse the repository at this point in the history
  • Loading branch information
mgdigital committed Jan 6, 2024
1 parent d949b5b commit b4b5f20
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions internal/database/query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ type OptionBuilder interface {
WithHasNextPage(bool) OptionBuilder
withTotalCount() bool
applyCallbacks(context.Context, any) error
applyCallbacksCtx(context.Context, callbackContext, any) error
hasZeroLimit() bool
needsNextPage() bool
hasNextPage(nItems int) bool
Expand Down Expand Up @@ -508,26 +507,14 @@ func (b optionBuilder) applyPost(sq SubQuery) error {
}

func (b optionBuilder) applyCallbacks(ctx context.Context, results any) error {
return doApplyCallbacks(ctx, callbackContext{
cbCtx := callbackContext{
dbContext: b.dbContext,
Mutex: &sync.Mutex{},
}, results, b.callbacks...)
}

func (b optionBuilder) applyCallbacksCtx(ctx context.Context, cbCtx callbackContext, results any) error {
for _, cb := range b.callbacks {
if err := cb(ctx, cbCtx, results); err != nil {
return err
}
}
return nil
}

func doApplyCallbacks(ctx context.Context, cbCtx callbackContext, results any, callbacks ...Callback) error {
var errs []error
wg := sync.WaitGroup{}
wg.Add(len(callbacks))
for _, cb := range callbacks {
wg.Add(len(b.callbacks))
for _, cb := range b.callbacks {
go (func(cb Callback) {
defer wg.Done()
if err := cb(ctx, cbCtx, results); err != nil {
Expand Down

0 comments on commit b4b5f20

Please sign in to comment.