Documentation ¶
Index ¶
Constants ¶
View Source
const DefaultLockExpiration = time.Minute * 5
Variables ¶
View Source
var ( ErrNotAcquired = errors.New("lock not acquired") ErrNotReleased = errors.New("lock not released") )
View Source
var (
NoRetryStrategy = LinearBackoffStrategy(0)
)
Functions ¶
This section is empty.
Types ¶
type MockLock ¶
func ExpectAcquireAndRelease ¶
func ExpectAcquireAndRelease(locker *MockLocker, key string) *MockLock
func NewMockLock ¶
func NewMockLock() *MockLock
type MockLocker ¶
func NewMockLocker ¶
func NewMockLocker() *MockLocker
type RetryAttempt ¶
type RetryAttempt interface { // NextBackoff returns the next backoff duration. NextBackoff() time.Duration }
RetryAttempt allows to customise the lock retry strategy.
func ExponentialBackoff ¶
func ExponentialBackoff(min, max time.Duration) RetryAttempt
ExponentialBackoff strategy is an optimization strategy with a retry time of 2**n milliseconds (n means number of times). You can set a minimum and maximum value, the recommended minimum value is not less than 16ms.
func LinearBackoff ¶
func LinearBackoff(backoff time.Duration) RetryAttempt
LinearBackoff allows retries regularly with customized intervals
type RetryStrategy ¶
type RetryStrategy func() RetryAttempt
func AttemptBoundRetryStrategy ¶ added in v2.3.0
func AttemptBoundRetryStrategy(maxAttempts int, retryStrategy RetryStrategy) RetryStrategy
func ExponentialBackoffStrategy ¶
func ExponentialBackoffStrategy(min, max time.Duration) RetryStrategy
func LinearBackoffStrategy ¶
func LinearBackoffStrategy(backoff time.Duration) RetryStrategy
Click to show internal directories.
Click to hide internal directories.