Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[FrameworkBundle] Allow user to specify folder for flock #26923

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
Sep 4, 2018

Conversation

MaksSlesarenko
Copy link
Contributor

@MaksSlesarenko MaksSlesarenko commented Apr 13, 2018

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
License MIT
Doc PR

In case multiple applications running on same server allow user to specify folder for flock
example:


framework: 
   lock:` 'flock://var/flock' # var/flock will be provided as path to flock constructor
   lock: 'flock:///var/flock' # /var/flock will be provided as path to flock constructor
   lock: flock # works as usual, null is provided to constructor and system temp folder is used


@nicolas-grekas nicolas-grekas changed the title Allow user to specify folder for flock [FrameworkBundle] Allow user to specify folder for flock Apr 14, 2018
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

looks like a good idea to me
ping @jderusse for 2nd review
what about adding some tests?

@@ -1374,8 +1374,18 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont
foreach ($resourceStores as $storeDsn) {
$storeDsn = $container->resolveEnvPlaceholders($storeDsn, null, $usedEnvs);
switch (true) {
case 'flock' === $storeDsn:
Copy link
Member

Choose a reason for hiding this comment

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

I think we should keep this case, and add a new one after

@@ -1374,8 +1374,18 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont
foreach ($resourceStores as $storeDsn) {
$storeDsn = $container->resolveEnvPlaceholders($storeDsn, null, $usedEnvs);
switch (true) {
case 'flock' === $storeDsn:
$storeDefinition = new Reference('lock.store.flock');
case 0 === strpos($storeDsn, 'flock'):
Copy link
Member

Choose a reason for hiding this comment

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

case 0 === strpos($storeDsn, 'flock://'): + substr instead of str_replace below


if ($isMatched) {
$storeDefinition = new Definition(FlockStore::class);
$storeDefinition->setPublic(false);
Copy link
Member

Choose a reason for hiding this comment

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

not required anymore, this is the default since 4.0

$storeDefinition = new Definition(FlockStore::class);
$storeDefinition->setPublic(false);
$storeDefinition->setArguments(array($flockPath));
$container->setDefinition($storeDefinitionId = 'lock.flock.store.'.$container->hash($storeDsn), $storeDefinition);
Copy link
Member

Choose a reason for hiding this comment

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

anticipating for #26921, the service name should start with a dot

Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest this:

$storeDefinitionId = '.lock.flock.store.'.$container->hash($storeDsn);
$container->register($storeDefinitionId, FlockStore::class)->addArgument($flockPath);

Copy link
Member

@jderusse jderusse left a comment

Choose a reason for hiding this comment

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

Great idea, I like the use of DSN for such purpose.

Nothing to add to @nicolas-grekas 's comments :)

@MaksSlesarenko
Copy link
Contributor Author

updated pr.
I don't mind adding couple tests, but I'm not seeing any for lock component in framework bundle to begin with

@@ -1377,6 +1377,14 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont
case 'flock' === $storeDsn:
$storeDefinition = new Reference('lock.store.flock');
break;
case 0 === strpos($storeDsn, 'flock'):
Copy link
Member

Choose a reason for hiding this comment

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

'flock://'

case 0 === strpos($storeDsn, 'flock'):
$flockPath = substr($storeDsn, 8);

$storeDefinitionId = 'lock.flock.store.'.$container->hash($storeDsn);
Copy link
Member

Choose a reason for hiding this comment

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

'.lock.flock.store.'.$container->hash($storeDsn); as per @nicolas-grekas 's comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can someone enlighten me about purpose of the starting dot?

Copy link
Member

Choose a reason for hiding this comment

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

@MaksSlesarenko
Copy link
Contributor Author

up

@nicolas-grekas
Copy link
Member

see fabbot failure :)

$flockPath = substr($storeDsn, 8);

$storeDefinitionId = '.lock.flock.store.'.$container->hash($storeDsn);
$container->register($storeDefinitionId, FlockStore::class)->addArgument($flockPath);
Copy link
Member

Choose a reason for hiding this comment

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

missing use statement for the FlockStore class

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@fabpot fabpot modified the milestones: 4.1, next Apr 22, 2018
@MaksSlesarenko
Copy link
Contributor Author

MaksSlesarenko commented May 8, 2018

Is there anything else I forgot to fix?

$storeDefinitionId = '.lock.flock.store.'.$container->hash($storeDsn);
$container->register($storeDefinitionId, FlockStore::class)->addArgument($flockPath);

$storeDefinition = new Reference($storeDefinitionId);
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the reference? I mean if I don't miss anything, we do not reuse it anyway, so something like this should work the same:

$flockPath = substr($storeDsn, 8);
$storeDefinitionId = '.lock.flock.store.'.$container->hash($storeDsn);
$storeDefinition = $container->register($storeDefinitionId, FlockStore::class)->addArgument($flockPath);

Copy link
Contributor Author

@MaksSlesarenko MaksSlesarenko May 11, 2018

Choose a reason for hiding this comment

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

Same can be said for both 'flock' and 'semaphore' cases. But I'm not sure that this PR is correct place for such refactoring. Besides '$storeDefinitions' already contains 'Reference' objects so it would be not cool to add strings or non-Reference type

@MaksSlesarenko
Copy link
Contributor Author

up

@fabpot
Copy link
Member

fabpot commented Sep 4, 2018

Thank you @MaksSlesarenko.

@fabpot fabpot merged commit 244d762 into symfony:master Sep 4, 2018
fabpot added a commit that referenced this pull request Sep 4, 2018
…ck (MaksSlesarenko)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[FrameworkBundle] Allow user to specify folder for flock

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| License       | MIT
| Doc PR        |

In case multiple applications running on same server allow user to specify folder for flock
example:
```

framework:
   lock:` 'flock://var/flock' # var/flock will be provided as path to flock constructor
   lock: 'flock:///var/flock' # /var/flock will be provided as path to flock constructor
   lock: flock # works as usual, null is provided to constructor and system temp folder is used

```

Commits
-------

244d762 added ability to specify folder for flock
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.2 Nov 1, 2018
This was referenced Nov 3, 2018
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Sep 26, 2019
…rence (HypeMC)

This PR was submitted for the 4.2 branch but it was squashed and merged into the 4.3 branch instead (closes #11466).

Discussion
----------

Add flock:// option to framework lock configuration reference

Fixes #9779 & extends #11465 .

Documents the `flock://` option which was added with symfony/symfony#26923 .

**NOTE 1**: The xml configuration doesn't currently work, see symfony/symfony#31197
**NOTE 2**: This PR has all the changes that #11465 has plus some symfony 4.2 specific additions, so #11465 should probably be merged first.

Commits
-------

d9125fd Add flock:// option to framework lock configuration reference
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.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.