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 3ea7750
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 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))
ds.logger.Info("oracle store failed mutation, transition to next state impossible so continuing with next mutation", zap.Error(oracleErr))
return nil
}
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 3ea7750

Please sign in to comment.