Skip to content

[FrameworkBundle] Using existing services as lock/semaphore resources #20738

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ this behavior by using the ``lock`` key like:
lock: 'oci:host=127.0.0.1;dbname=app'
lock: 'mongodb://127.0.0.1/app?collection=lock'
lock: '%env(LOCK_DSN)%'
# using an existing service
lock: 'snc_redis.default'

# named locks
lock:
Expand Down Expand Up @@ -119,6 +121,9 @@ this behavior by using the ``lock`` key like:

<framework:resource>%env(LOCK_DSN)%</framework:resource>

<!-- using an existing service -->
<framework:resource>snc_redis.default</framework:resource>

<!-- named locks -->
<framework:resource name="invoice">semaphore</framework:resource>
<framework:resource name="invoice">redis://r2.docker</framework:resource>
Expand All @@ -130,6 +135,7 @@ this behavior by using the ``lock`` key like:
.. code-block:: php

// config/packages/lock.php
use function Symfony\Component\DependencyInjection\Loader\Configurator\env;
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework): void {
Expand All @@ -152,6 +158,8 @@ this behavior by using the ``lock`` key like:
->resource('default', ['oci:host=127.0.0.1;dbname=app'])
->resource('default', ['mongodb://127.0.0.1/app?collection=lock'])
->resource('default', [env('LOCK_DSN')])
// using an existing service
->resource('default', ['snc_redis.default'])

// named locks
->resource('invoice', ['semaphore', 'redis://r2.docker'])
Expand Down
7 changes: 4 additions & 3 deletions reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,7 @@ resources
**type**: ``array``

A map of lock stores to be created by the framework extension, with
the name as key and DSN as value:
the name as key and DSN or service id as value:

.. configuration-block::

Expand Down Expand Up @@ -2725,7 +2725,7 @@ resources
**type**: ``array``

A map of semaphore stores to be created by the framework extension, with
the name as key and DSN as value:
the name as key and DSN or service id as value:

.. configuration-block::

Expand Down Expand Up @@ -2756,11 +2756,12 @@ the name as key and DSN as value:
.. code-block:: php

// config/packages/semaphore.php
use function Symfony\Component\DependencyInjection\Loader\Configurator\env;
use Symfony\Config\FrameworkConfig;

return static function (FrameworkConfig $framework): void {
$framework->semaphore()
->resource('default', ['%env(SEMAPHORE_DSN)%']);
->resource('default', [env('SEMAPHORE_DSN')]);
};

.. _reference-semaphore-resources-name:
Expand Down