Documentation
¶
Index ¶
- Variables
- type Service
- func (s *Service) AcquireLock(ctx context.Context, lockName string, ttl time.Duration) (context.Context, context.CancelFunc, error)
- func (s *Service) Close() error
- func (s *Service) GetInstanceID() string
- func (s *Service) GetLockHolder(lockName string) (string, error)
- func (s *Service) IsLocked(lockName string) (bool, error)
- func (s *Service) ReleaseLock(lockName string) error
- func (s *Service) TryLock(lockName string, ttl time.Duration) (bool, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrLockNotAcquired is returned when a lock could not be acquired. ErrLockNotAcquired = errors.New("lock not acquired") // ErrLockLost is returned when a held lock is lost. ErrLockLost = errors.New("lock lost") )
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides distributed locking capabilities for HA deployments.
func NewService ¶
NewService creates a new distributed lock service.
func (*Service) AcquireLock ¶
func (s *Service) AcquireLock(ctx context.Context, lockName string, ttl time.Duration) (context.Context, context.CancelFunc, error)
AcquireLock attempts to acquire a distributed lock with specified TTL. Returns a context that will be canceled when the lock is lost.
func (*Service) GetInstanceID ¶
GetInstanceID returns the instance ID for this lock service.
func (*Service) GetLockHolder ¶
GetLockHolder returns the instance ID that holds the lock, if any.
func (*Service) ReleaseLock ¶
ReleaseLock explicitly releases a lock.
Click to show internal directories.
Click to hide internal directories.