MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / waitProfileChecking

Function waitProfileChecking

sqlchain/observer/observation_test.go:757–785  ·  view source on GitHub ↗
(ctx context.Context, period time.Duration, dbID proto.DatabaseID,
	checkFunc func(profile *types.SQLChainProfile) bool)

Source from the content-addressed store, hash-verified

755}
756
757func waitProfileChecking(ctx context.Context, period time.Duration, dbID proto.DatabaseID,
758 checkFunc func(profile *types.SQLChainProfile) bool) (err error) {
759 var (
760 ticker = time.NewTicker(period)
761 req = &types.QuerySQLChainProfileReq{}
762 resp = &types.QuerySQLChainProfileResp{}
763 )
764 defer ticker.Stop()
765 req.DBID = dbID
766
767 for {
768 select {
769 case <-ticker.C:
770 err = rpc.RequestBP(route.MCCQuerySQLChainProfile.String(), req, resp)
771 if err == nil {
772 if checkFunc(&resp.Profile) {
773 return
774 }
775 log.WithFields(log.Fields{
776 "dbID": resp.Profile.Address,
777 "num_of_user": len(resp.Profile.Users),
778 }).Debugf("get profile but failed to check in waitProfileChecking")
779 }
780 case <-ctx.Done():
781 err = ctx.Err()
782 return
783 }
784 }
785}

Callers 1

TestFullProcessFunction · 0.70

Calls 4

WithFieldsFunction · 0.92
DebugfMethod · 0.80
StopMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected