Skip to content

Commit 7165818

Browse files
committed
[FrameworkBundle] Using existing services as lock/semaphore resources
1 parent 44687d8 commit 7165818

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

lock.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ this behavior by using the ``lock`` key like:
6262
lock: 'oci:host=127.0.0.1;dbname=app'
6363
lock: 'mongodb://127.0.0.1/app?collection=lock'
6464
lock: '%env(LOCK_DSN)%'
65+
# using an existing service
66+
lock: 'snc_redis.default'
6567
6668
# named locks
6769
lock:
@@ -119,6 +121,9 @@ this behavior by using the ``lock`` key like:
119121
120122
<framework:resource>%env(LOCK_DSN)%</framework:resource>
121123
124+
<!-- using an existing service -->
125+
<framework:resource>snc_redis.default</framework:resource>
126+
122127
<!-- named locks -->
123128
<framework:resource name="invoice">semaphore</framework:resource>
124129
<framework:resource name="invoice">redis://r2.docker</framework:resource>
@@ -152,6 +157,8 @@ this behavior by using the ``lock`` key like:
152157
->resource('default', ['oci:host=127.0.0.1;dbname=app'])
153158
->resource('default', ['mongodb://127.0.0.1/app?collection=lock'])
154159
->resource('default', [env('LOCK_DSN')])
160+
// using an existing service
161+
->resource('default', ['snc_redis.default'])
155162
156163
// named locks
157164
->resource('invoice', ['semaphore', 'redis://r2.docker'])

reference/configuration/framework.rst

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,7 +2048,7 @@ resources
20482048
**type**: ``array``
20492049

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

20532053
.. configuration-block::
20542054

@@ -2057,6 +2057,8 @@ the name as key and DSN as value:
20572057
# config/packages/lock.yaml
20582058
framework:
20592059
lock: '%env(LOCK_DSN)%'
2060+
# or
2061+
lock: 'service.id'
20602062
20612063
.. code-block:: xml
20622064
@@ -2072,6 +2074,8 @@ the name as key and DSN as value:
20722074
<framework:config>
20732075
<framework:lock>
20742076
<framework:resource name="default">%env(LOCK_DSN)%</framework:resource>
2077+
<!-- or -->
2078+
<framework:resource name="default">service.id</framework:resource>
20752079
</framework:lock>
20762080
</framework:config>
20772081
</container>
@@ -2083,7 +2087,10 @@ the name as key and DSN as value:
20832087
20842088
return static function (FrameworkConfig $framework): void {
20852089
$framework->lock()
2086-
->resource('default', [env('LOCK_DSN')]);
2090+
->resource('default', [env('LOCK_DSN')])
2091+
// or
2092+
->resource('default', ['service.id'])
2093+
;
20872094
};
20882095
20892096
.. seealso::
@@ -2725,7 +2732,7 @@ resources
27252732
**type**: ``array``
27262733

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

27302737
.. configuration-block::
27312738

@@ -2734,6 +2741,8 @@ the name as key and DSN as value:
27342741
# config/packages/semaphore.yaml
27352742
framework:
27362743
semaphore: '%env(SEMAPHORE_DSN)%'
2744+
# or
2745+
semaphore: 'service.id'
27372746
27382747
.. code-block:: xml
27392748
@@ -2749,6 +2758,8 @@ the name as key and DSN as value:
27492758
<framework:config>
27502759
<framework:semaphore>
27512760
<framework:resource name="default">%env(SEMAPHORE_DSN)%</framework:resource>
2761+
<!-- or -->
2762+
<framework:resource name="default">service.id</framework:resource>
27522763
</framework:semaphore>
27532764
</framework:config>
27542765
</container>
@@ -2760,7 +2771,10 @@ the name as key and DSN as value:
27602771
27612772
return static function (FrameworkConfig $framework): void {
27622773
$framework->semaphore()
2763-
->resource('default', ['%env(SEMAPHORE_DSN)%']);
2774+
->resource('default', [env('SEMAPHORE_DSN')])
2775+
// or
2776+
->resource('default', ['service.id'])
2777+
;
27642778
};
27652779
27662780
.. _reference-semaphore-resources-name:

0 commit comments

Comments
 (0)