// Lock acquires an exclusive mongoDB lock with the provided id, with the default TTL value.
// If the resource is already locked, an error will be returned.
Lock acquires an exclusive mongoDB lock with the provided id, with the default TTL value.
If the resource is already locked, an error will be returned.
// Lock acquires an exclusive mongoDB lock with the provided id with the default TTL value . // If the resource is already locked an error will be returned .
func (l *Lock) Lock(ctx context.Context, resourceID string) (lockID string, err error) {
	lockID = fmt.Sprintf("%s-%s-%d", l.Resource, resourceID, GenerateTimeID())
	return lockID, l.Client.XLock(ctx,
		fmt.Sprintf("%s-%s", l.Resource, resourceID),
		lockID,
		lock.LockDetails{TTL: TTL},
	)
}
func ( l * Lock ) Lock ( ctx context . Context , resourceID string ) ( lockID string , err error ) { lockID = fmt . Sprintf ( " " , l . Resource , resourceID , GenerateTimeID ( ) ) return lockID , l . Client . XLock ( ctx , fmt . Sprintf ( " " , l . Resource , resourceID ) , lockID , lock . LockDetails { TTL : TTL } , ) }
Lock acquires an exclusive mongoDB lock with the provided id, with the default TTL value.
Lock acquires an exclusive mongoDB lock with the provided id with the default TTL value .