Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Lock] Add a TTL to refresh lock #26232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2018
Merged

Conversation

jderusse
Copy link
Member

@jderusse jderusse commented Feb 19, 2018

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? see LockInterface's comment
Tests pass? yes
Fixed tickets NA
License MIT
Doc PR NA

Using remote locks in long processes needs to defines a fined grain refresh TTL. For instance, when looping over a long list of jobs we can extends the live of the lock by few seconds before processing each item.
But when the the jobs is splitted and each part to take the same time, we can not define the best TTL

Exemple

$lock->acquire();

$this->2minutesJob();

$lock->refresh();
$this->5minutesJob();

$lock->refresh();
$this->1minutesJob();

The purpose of this PR is to be able to override the default TTL

$lock->acquire();

$lock->refresh(120);
$this->2minutesJob();

$lock->refresh(300);
$this->5minutesJob();

$lock->refresh(60);
$this->1minutesJob();

* @throws LockConflictedException If the lock is acquired by someone else
* @throws LockAcquiringException If the lock can not be refreshed
*/
public function refresh();
public function refresh(/* $ttl = null */);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not such this is the right way to keep BC layer on interfaces. ping @nicolas-grekas

Is there a way to trigger a deprecation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can trigger a deprecation in the interface like e8351d8#diff-7994cccf0d9c75a5a481e1240a159cce

@fabpot
Copy link
Member

fabpot commented Feb 19, 2018

Thank you @jderusse.

@fabpot fabpot merged commit 3b1f328 into symfony:master Feb 19, 2018
fabpot added a commit that referenced this pull request Feb 19, 2018
This PR was merged into the 4.1-dev branch.

Discussion
----------

[Lock] Add a TTL to refresh lock

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | see LockInterface's comment
| Tests pass?   | yes
| Fixed tickets | NA
| License       | MIT
| Doc PR        | NA

Using remote locks in long processes needs to defines a fined grain refresh TTL. For instance, when looping over a long list of jobs we can extends the live of the lock by few seconds before processing each item.
But when the the jobs is splitted and each part to take the same time, we can not define the best TTL

Exemple
```
$lock->acquire();

$this->2minutesJob();

$lock->refresh();
$this->5minutesJob();

$lock->refresh();
$this->1minutesJob();
```

The purpose of this PR is to be able to override the default TTL

```
$lock->acquire();

$lock->refresh(120);
$this->2minutesJob();

$lock->refresh(300);
$this->5minutesJob();

$lock->refresh(60);
$this->1minutesJob();
```

Commits
-------

3b1f328 Add a TTL to refresh lock
@fabpot fabpot mentioned this pull request May 7, 2018
@jderusse jderusse deleted the lock-refresh-ttl branch August 2, 2019 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants