 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Index ¶
Constants ¶
This section is empty.
Variables ¶
      View Source
      
  
    var ( Name = self.Name Using = self.Using )
      View Source
      
  
    var ( // ErrNotAcquired is an error indicating that the distributed lock was not acquired. It is returned by IDistMutex.Unlock and IDistMutex.Extend when the lock was not successfully acquired or has expired. ErrNotAcquired = errors.New("dsync: lock is not acquired") )
      View Source
      
  
var With _Option
    Functions ¶
This section is empty.
Types ¶
type DistMutexOptions ¶
type DistMutexOptions struct {
	Expiry        time.Duration
	Tries         int
	DelayFunc     DelayFunc
	DriftFactor   float64
	TimeoutFactor float64
	GenValueFunc  GenValueFunc
	Value         string
}
    DistMutexOptions represents the options for acquiring a distributed mutex.
type GenValueFunc ¶
GenValueFunc is used to generate a random value.
type IDistMutex ¶
type IDistMutex interface {
	// Name returns mutex name.
	Name() string
	// Value returns the current random value. The value will be empty until a lock is acquired (or Value option is used).
	Value() string
	// Until returns the time of validity of acquired lock. The value will be zero value until a lock is acquired.
	Until() time.Time
	// Lock locks m. In case it returns an error on failure, you may retry to acquire the lock by calling this method again.
	Lock(ctx context.Context) error
	// Unlock unlocks m and returns the status of unlock.
	Unlock(ctx context.Context) error
	// Extend resets the mutex's expiry and returns the status of expiry extension.
	Extend(ctx context.Context) error
	// Valid returns true if the lock acquired through m is still valid. It may also return true erroneously if quorum is achieved during the call and at
	// least one node then takes long enough to respond for the lock to expire.
	Valid(ctx context.Context) (bool, error)
}
    A IDistMutex is a distributed mutual exclusion lock. Avoid sharing the same IDistMutex instance among multiple goroutines. Create a separate IDistMutex instance for each goroutine.
type IDistMutexSettings ¶ added in v0.2.39
type IDistMutexSettings interface {
	// With applies additional settings to the distributed mutex.
	With(settings ...option.Setting[DistMutexOptions]) IDistMutex
}
    IDistMutexSettings represents an interface for configuring a distributed mutex.
type IDistSync ¶
type IDistSync interface {
	// NewMutex returns a new distributed mutex with given name.
	NewMutex(name string, settings ...option.Setting[DistMutexOptions]) IDistMutex
	// NewMutexf returns a new distributed mutex using a formatted string.
	NewMutexf(format string, args ...any) IDistMutexSettings
	// NewMutexp returns a new distributed mutex using elements.
	NewMutexp(elems ...string) IDistMutexSettings
	// GetSeparator return name path separator.
	GetSeparator() string
}
    IDistSync represents a distributed synchronization mechanism.
 Click to show internal directories. 
   Click to hide internal directories.