I having difficulty using mutex's custom
Closed this issue · 1 comments
Nghiait123456 commented
in https://github.com/go-redsync/redsync/blob/master/mutex.go#L17-L34
// A Mutex is a distributed mutual exclusion lock.
type Mutex struct {
name string
expiry time.Duration
tries int
delayFunc DelayFunc
driftFactor float64
timeoutFactor float64
quorum int
genValueFunc func() (string, error)
value string
until time.Time
pools []redis.Pool
}
Mutex is public, but element of this (name, tries,...) is private, when custom default mutex, i have only one way:
mutex := rs.NewMutex("test-redsync", redsync.OptionFunc(func(mutex *redsync.Mutex) {
mutex = &redsync.Mutex{
name: "test-redsync",
expiry: 1 * time.Second,
tries: 32,
delayFunc: func(tries int) time.Duration {
return time.Duration(rand.Intn(maxRetryDelayMilliSec-minRetryDelayMilliSec)+minRetryDelayMilliSec) * time.Millisecond
},
genValueFunc: genValue,
driftFactor: 0.01,
timeoutFactor: 0.05,
quorum: len(r.pools)/2 + 1,
pools: r.pools,
}
fmt.Println("call f fc")
}))
```
it's rich, i only want custom one parram, but i must pass to all param.
Can i help you this problem?
Nghiait123456 commented
duplication