(ctx context.Context, period time.Duration, dbID proto.DatabaseID, checkFunc func(profile *types.SQLChainProfile) bool)
| 755 | } |
| 756 | |
| 757 | func 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 | } |
no test coverage detected