Skip to content

Commit

Permalink
*: enable revive.exported linter (tikv#8563)
Browse files Browse the repository at this point in the history
close tikv#8458

Signed-off-by: okJiang <[email protected]>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
  • Loading branch information
okJiang and ti-chi-bot[bot] committed Aug 22, 2024
1 parent 9e7a1b9 commit 61a85e5
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 124 deletions.
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,5 +226,4 @@ issues:
linters:
- errcheck
include:
# remove the comment after the path is ready
# - EXC0012
- EXC0012
68 changes: 34 additions & 34 deletions tools/pd-api-bench/cases/cases.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,48 +80,48 @@ func (c *Config) Clone() *Config {

// Case is the interface for all cases.
type Case interface {
Name() string
SetQPS(int64)
GetQPS() int64
SetBurst(int64)
GetBurst() int64
GetConfig() *Config
getName() string
setQPS(int64)
getQPS() int64
setBurst(int64)
getBurst() int64
getConfig() *Config
}

type baseCase struct {
name string
cfg *Config
}

func (c *baseCase) Name() string {
func (c *baseCase) getName() string {
return c.name
}

func (c *baseCase) SetQPS(qps int64) {
func (c *baseCase) setQPS(qps int64) {
c.cfg.QPS = qps
}

func (c *baseCase) GetQPS() int64 {
func (c *baseCase) getQPS() int64 {
return c.cfg.QPS
}

func (c *baseCase) SetBurst(burst int64) {
func (c *baseCase) setBurst(burst int64) {
c.cfg.Burst = burst
}

func (c *baseCase) GetBurst() int64 {
func (c *baseCase) getBurst() int64 {
return c.cfg.Burst
}

func (c *baseCase) GetConfig() *Config {
func (c *baseCase) getConfig() *Config {
return c.cfg.Clone()
}

// EtcdCase is the interface for all etcd api cases.
type EtcdCase interface {
Case
Init(context.Context, *clientv3.Client) error
Unary(context.Context, *clientv3.Client) error
init(context.Context, *clientv3.Client) error
unary(context.Context, *clientv3.Client) error
}

// EtcdCreateFn is function type to create EtcdCase.
Expand All @@ -138,7 +138,7 @@ var EtcdCaseFnMap = map[string]EtcdCreateFn{
// GRPCCase is the interface for all gRPC cases.
type GRPCCase interface {
Case
Unary(context.Context, pd.Client) error
unary(context.Context, pd.Client) error
}

// GRPCCreateFn is function type to create GRPCCase.
Expand All @@ -159,7 +159,7 @@ var GRPCCaseFnMap = map[string]GRPCCreateFn{
// HTTPCase is the interface for all HTTP cases.
type HTTPCase interface {
Case
Do(context.Context, pdHttp.Client) error
do(context.Context, pdHttp.Client) error
}

// HTTPCreateFn is function type to create HTTPCase.
Expand All @@ -186,7 +186,7 @@ func newMinResolvedTS() func() HTTPCase {
}
}

func (c *minResolvedTS) Do(ctx context.Context, cli pdHttp.Client) error {
func (c *minResolvedTS) do(ctx context.Context, cli pdHttp.Client) error {
minResolvedTS, storesMinResolvedTS, err := cli.GetMinResolvedTSByStoresIDs(ctx, storesID)
if Debug {
log.Info("do HTTP case", zap.String("case", c.name), zap.Uint64("min-resolved-ts", minResolvedTS), zap.Any("store-min-resolved-ts", storesMinResolvedTS), zap.Error(err))
Expand Down Expand Up @@ -214,7 +214,7 @@ func newRegionStats() func() HTTPCase {
}
}

func (c *regionsStats) Do(ctx context.Context, cli pdHttp.Client) error {
func (c *regionsStats) do(ctx context.Context, cli pdHttp.Client) error {
upperBound := totalRegion / c.regionSample
if upperBound < 1 {
upperBound = 1
Expand Down Expand Up @@ -248,7 +248,7 @@ func newUpdateGCSafePoint() func() GRPCCase {
}
}

func (*updateGCSafePoint) Unary(ctx context.Context, cli pd.Client) error {
func (*updateGCSafePoint) unary(ctx context.Context, cli pd.Client) error {
s := time.Now().Unix()
_, err := cli.UpdateGCSafePoint(ctx, uint64(s))
if err != nil {
Expand All @@ -272,7 +272,7 @@ func newUpdateServiceGCSafePoint() func() GRPCCase {
}
}

func (*updateServiceGCSafePoint) Unary(ctx context.Context, cli pd.Client) error {
func (*updateServiceGCSafePoint) unary(ctx context.Context, cli pd.Client) error {
s := time.Now().Unix()
id := rand.Int63n(100) + 1
_, err := cli.UpdateServiceGCSafePoint(ctx, strconv.FormatInt(id, 10), id, uint64(s))
Expand All @@ -297,7 +297,7 @@ func newGetRegion() func() GRPCCase {
}
}

func (*getRegion) Unary(ctx context.Context, cli pd.Client) error {
func (*getRegion) unary(ctx context.Context, cli pd.Client) error {
id := rand.Intn(totalRegion)*4 + 1
_, err := cli.GetRegion(ctx, generateKeyForSimulator(id))
if err != nil {
Expand All @@ -321,7 +321,7 @@ func newGetRegionEnableFollower() func() GRPCCase {
}
}

func (*getRegionEnableFollower) Unary(ctx context.Context, cli pd.Client) error {
func (*getRegionEnableFollower) unary(ctx context.Context, cli pd.Client) error {
id := rand.Intn(totalRegion)*4 + 1
_, err := cli.GetRegion(ctx, generateKeyForSimulator(id), pd.WithAllowFollowerHandle())
if err != nil {
Expand All @@ -347,7 +347,7 @@ func newScanRegions() func() GRPCCase {
}
}

func (c *scanRegions) Unary(ctx context.Context, cli pd.Client) error {
func (c *scanRegions) unary(ctx context.Context, cli pd.Client) error {
upperBound := totalRegion / c.regionSample
random := rand.Intn(upperBound)
startID := c.regionSample*random*4 + 1
Expand Down Expand Up @@ -375,7 +375,7 @@ func newTso() func() GRPCCase {
}
}

func (*tso) Unary(ctx context.Context, cli pd.Client) error {
func (*tso) unary(ctx context.Context, cli pd.Client) error {
_, _, err := cli.GetTS(ctx)
if err != nil {
return err
Expand All @@ -398,7 +398,7 @@ func newGetStore() func() GRPCCase {
}
}

func (*getStore) Unary(ctx context.Context, cli pd.Client) error {
func (*getStore) unary(ctx context.Context, cli pd.Client) error {
storeIdx := rand.Intn(totalStore)
_, err := cli.GetStore(ctx, storesID[storeIdx])
if err != nil {
Expand All @@ -422,7 +422,7 @@ func newGetStores() func() GRPCCase {
}
}

func (*getStores) Unary(ctx context.Context, cli pd.Client) error {
func (*getStores) unary(ctx context.Context, cli pd.Client) error {
_, err := cli.GetAllStores(ctx)
if err != nil {
return err
Expand Down Expand Up @@ -451,7 +451,7 @@ func newGetKV() func() EtcdCase {
}
}

func (*getKV) Init(ctx context.Context, cli *clientv3.Client) error {
func (*getKV) init(ctx context.Context, cli *clientv3.Client) error {
for i := 0; i < 100; i++ {
_, err := cli.Put(ctx, fmt.Sprintf("/test/0001/%4d", i), fmt.Sprintf("%4d", i))
if err != nil {
Expand All @@ -461,7 +461,7 @@ func (*getKV) Init(ctx context.Context, cli *clientv3.Client) error {
return nil
}

func (*getKV) Unary(ctx context.Context, cli *clientv3.Client) error {
func (*getKV) unary(ctx context.Context, cli *clientv3.Client) error {
_, err := cli.Get(ctx, "/test/0001", clientv3.WithPrefix())
return err
}
Expand All @@ -481,9 +481,9 @@ func newPutKV() func() EtcdCase {
}
}

func (*putKV) Init(context.Context, *clientv3.Client) error { return nil }
func (*putKV) init(context.Context, *clientv3.Client) error { return nil }

func (*putKV) Unary(ctx context.Context, cli *clientv3.Client) error {
func (*putKV) unary(ctx context.Context, cli *clientv3.Client) error {
_, err := cli.Put(ctx, "/test/0001/0000", "test")
return err
}
Expand All @@ -503,9 +503,9 @@ func newDeleteKV() func() EtcdCase {
}
}

func (*deleteKV) Init(context.Context, *clientv3.Client) error { return nil }
func (*deleteKV) init(context.Context, *clientv3.Client) error { return nil }

func (*deleteKV) Unary(ctx context.Context, cli *clientv3.Client) error {
func (*deleteKV) unary(ctx context.Context, cli *clientv3.Client) error {
_, err := cli.Delete(ctx, "/test/0001/0000")
return err
}
Expand All @@ -525,9 +525,9 @@ func newTxnKV() func() EtcdCase {
}
}

func (*txnKV) Init(context.Context, *clientv3.Client) error { return nil }
func (*txnKV) init(context.Context, *clientv3.Client) error { return nil }

func (*txnKV) Unary(ctx context.Context, cli *clientv3.Client) error {
func (*txnKV) unary(ctx context.Context, cli *clientv3.Client) error {
txn := cli.Txn(ctx)
txn = txn.If(clientv3.Compare(clientv3.Value("/test/0001/0000"), "=", "test"))
txn = txn.Then(clientv3.OpPut("/test/0001/0000", "test2"))
Expand Down
Loading

0 comments on commit 61a85e5

Please sign in to comment.