github.com/songzhibin97/gkit@v1.2.13/distributed/locker/lock_ridis/option.go (about)

     1  package lock_ridis
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/songzhibin97/gkit/options"
     7  )
     8  
     9  // config
    10  type config struct {
    11  	// interval: 重试间隔时间
    12  	// 只有 retries > 0 才有效
    13  	// interval < 0 的话 retries 同样无效
    14  	interval time.Duration
    15  
    16  	// retries间隔次数
    17  	// retries > 0
    18  	retries int
    19  }
    20  
    21  // SetInterval 设置重试间隔时间
    22  func SetInterval(duration time.Duration) options.Option {
    23  	return func(c interface{}) {
    24  		c.(*config).interval = duration
    25  	}
    26  }
    27  
    28  // SetRetries 设置重试次数
    29  func SetRetries(retries int) options.Option {
    30  	return func(c interface{}) {
    31  		c.(*config).retries = retries
    32  	}
    33  }