github.com/benz9527/xboot@v0.0.0-20240504061247-c23f15593274/dlock/intf.go (about)

     1  package dlock
     2  
     3  import "time"
     4  
     5  type DLocker interface {
     6  	Lock() error
     7  	Unlock() error
     8  	Renewal(newTTL time.Duration) error
     9  	TTL() (time.Duration, error)
    10  }
    11  
    12  type RetryStrategy interface {
    13  	Next() time.Duration
    14  }
    15  
    16  type DLockErr string
    17  
    18  const (
    19  	ErrDLockAcquireFailed DLockErr = "failed to acquire dlock"
    20  	ErrDLockNoInit        DLockErr = "no init the dlock"
    21  )
    22  
    23  var (
    24  	noErr error = nil
    25  )
    26  
    27  func (err DLockErr) Error() string {
    28  	return string(err)
    29  }