Skip to content

Commit

Permalink
add(store): makes Mutate func do queries on test and oracle stores pa…
Browse files Browse the repository at this point in the history
…rallel
  • Loading branch information
illia-li committed Jul 10, 2023
1 parent 94f8ad5 commit 7c33379
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions pkg/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,25 @@ func (ds delegatingStore) Create(ctx context.Context, testBuilder, oracleBuilder
}

func (ds delegatingStore) Mutate(ctx context.Context, builder qb.Builder, values ...interface{}) error {
if err := mutate(ctx, ds.oracleStore, builder, values...); err != nil {
var testErr error
var wg sync.WaitGroup
wg.Add(1)
go func() {
testErr = mutate(ctx, ds.testStore, builder, values...)
wg.Done()
}()
if oracleErr := mutate(ctx, ds.oracleStore, builder, values...); oracleErr != nil {
// Oracle failed, transition cannot take place
ds.logger.Info("oracle failed mutation, transition to next state impossible so continuing with next mutation", zap.Error(err))
return nil
ds.logger.Info("oracle store failed mutation, transition to next state impossible so continuing with next mutation", zap.Error(oracleErr))
return oracleErr
}
return mutate(ctx, ds.testStore, builder, values...)
wg.Wait()
if testErr != nil {
// Test store failed, transition cannot take place
ds.logger.Info("test store failed mutation, transition to next state impossible so continuing with next mutation", zap.Error(testErr))
return testErr
}
return nil
}

func mutate(ctx context.Context, s storeLoader, builder qb.Builder, values ...interface{}) error {
Expand Down

0 comments on commit 7c33379

Please sign in to comment.