Skip to content
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

Lock store configuration improvement #155

Open
jvancoillie opened this issue Jun 20, 2021 · 4 comments
Open

Lock store configuration improvement #155

jvancoillie opened this issue Jun 20, 2021 · 4 comments

Comments

@jvancoillie
Copy link
Contributor

Would it be possible to configure the default lock_store with the framework.lock: '%env(LOCK_DSN)%' configuration
instead of having to redefine it ?

in addition the following lock_store configuration: lock_store:'%env(LOCK_DSN)%' does not work, you must pass it a service name.

scheduler_bundle:
  lock_store: lock.default
@Guikingone
Copy link
Owner

Guikingone commented Apr 26, 2022

Hi @jvancoillie 👋🏻

Still this issue interesting in your current usages (if you still use this bundle)?

Thanks 🙂

@Guikingone Guikingone removed this from the Next (as minor) milestone Apr 26, 2022
@jvancoillie
Copy link
Contributor Author

Hi @Guikingone 😛

Sorry for this late return,

I was unable to continue using the bundle. The delivery date of the application on which I used the bundle did not match with the release 1.0.0 of the bundle.

But I think this configuration would be useful for me, what do you think

@ToshY
Copy link
Contributor

ToshY commented Nov 18, 2022

Hey @Guikingone 👋

I'm unsure if I'm having the same issue, but I was following the docs and wanted to specify a Redis DSN, but I'm unable to get this to work.

# services.yaml
parameters:
  redis.dsn.general: '%env(REDIS_DSN_GENERAL)%'
# lock.yaml
framework:
  lock:
    default: '%redis.dsn.general%'
    scheduler: '%redis.dsn.general%'
# scheduler.yaml
scheduler_bundle:
  timezone: UTC
  lock_store: 'lock.scheduler.store'

When doing debug:container store, I get an exception:

  [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
  The service "scheduler.lock_store.factory" has a dependency on a non-existent service "lock.scheduler.store".

So I tried changing to lock_store: 'lock.default.factory', which gave me an exception in the scheduler

2022-11-18T23:38:52.957009057Z 2022-11-19T00:38:52+01:00 [critical] Uncaught Error: Symfony\Component\Lock\LockFactory::__construct(): Argument #1 ($store) must be of type Symfony\Component\Lock\PersistingStoreInterface, Symfony\Component\Lock\LockFactory given, called in /app/var/cache/dev/ContainerZT6xVhd/App_KernelDevDebugContainer.php on line 14525
2022-11-18T23:39:19.188351417Z TypeError {#358
2022-11-18T23:39:19.188377556Z   #message: "Symfony\Component\Lock\LockFactory::__construct(): Argument #1 ($store) must be of type Symfony\Component\Lock\PersistingStoreInterface, Symfony\Component\Lock\LockFactory given, called in /app/var/cache/dev/ContainerZT6xVhd/App_KernelDevDebugContainer.php on line 14525"
2022-11-18T23:39:19.188383637Z   #code: 0
2022-11-18T23:39:19.188385671Z   #file: "./vendor/symfony/lock/LockFactory.php"
2022-11-18T23:39:19.188387675Z   #line: 30
2022-11-18T23:39:19.188389508Z   trace: {
2022-11-18T23:39:19.188391502Z     ./vendor/symfony/lock/LockFactory.php:30 { …}
2022-11-18T23:39:19.188393957Z     ./var/cache/dev/ContainerZT6xVhd/App_KernelDevDebugContainer.php:14525 {
2022-11-18T23:39:19.188396161Z       ContainerZT6xVhd\App_KernelDevDebugContainer->getScheduler_LockStore_FactoryService()
2022-11-18T23:39:19.188398646Z       › {
2022-11-18T23:39:19.188400559Z       ›     $this->privates['scheduler.lock_store.factory'] = $instance = new \Symfony\Component\Lock\LockFactory(($this->privates['lock.default.factory'] ?? $this->getLock_Default_FactoryService()));
2022-11-18T23:39:19.188402924Z       ›
2022-11-18T23:39:19.188404817Z       arguments: {
2022-11-18T23:39:19.188406661Z         $store: Symfony\Component\Lock\LockFactory {#369 …}
2022-11-18T23:39:19.188408744Z       }
2022-11-18T23:39:19.188410568Z     }
2022-11-18T23:39:19.188412371Z     ./var/cache/dev/ContainerZT6xVhd/App_KernelDevDebugContainer.php:9394 { …}
2022-11-18T23:39:19.188414355Z     ./var/cache/dev/ContainerZT6xVhd/App_KernelDevDebugContainer.php:9336 { …}
2022-11-18T23:39:19.188416449Z     ContainerZT6xVhd\App_KernelDevDebugContainer->ContainerZT6xVhd\{closure}() {}
2022-11-18T23:39:19.188418513Z     ./vendor/guikingone/scheduler-bundle/src/Middleware/MiddlewareRegistry.php:36 { …}
2022-11-18T23:39:19.188420567Z     ./var/cache/dev/ContainerZT6xVhd/App_KernelDevDebugContainer.php:9338 { …}
2022-11-18T23:39:19.188422460Z     ./var/cache/dev/ContainerZT6xVhd/App_KernelDevDebugContainer.php:9365 { …}
2022-11-18T23:39:19.188424574Z     ./var/cache/dev/ContainerZT6xVhd/App_KernelDevDebugContainer.php:9483 { …}
2022-11-18T23:39:19.188426488Z     ./var/cache/dev/ContainerZT6xVhd/App_KernelDevDebugContainer.php:9012 { …}
2022-11-18T23:39:19.188428431Z     ./var/cache/dev/ContainerZT6xVhd/App_KernelDevDebugContainer.php:3868 { …}
2022-11-18T23:39:19.188440494Z     ./vendor/symfony/console/Command/LazyCommand.php:190 { …}
2022-11-18T23:39:19.188442668Z     ./vendor/symfony/console/Application.php:297 { …}
2022-11-18T23:39:19.188444732Z     ./vendor/symfony/framework-bundle/Console/Application.php:80 { …}
2022-11-18T23:39:19.188446685Z     ./vendor/symfony/console/Application.php:171 { …}
2022-11-18T23:39:19.188448840Z     ./bin/console:43 { …}
2022-11-18T23:39:19.188450763Z   }
2022-11-18T23:39:19.188452607Z }

What am I missing here?

Versions
scheduler-bundle: 0.10
symfony/lock: 6.1.7


Edit

I've defined it in my services.yaml and it seemingly works now.

  lock.scheduler.store:
    class: 'Symfony\Component\Lock\Store\RedisStore'
    arguments:
      - '@app.redis.provider.general'

  app.redis.provider.general:
    class: Redis
    factory: [ 'Symfony\Component\Cache\Adapter\RedisAdapter', 'createConnection' ]
    arguments:
      - '%redis.dsn.general%'
      - { retry_interval: 3, timeout: 30, persistent: 1, tcp_keepalive: 300 }

@Guikingone
Copy link
Owner

Hi @ToshY 👋🏻

Could you create a dedicated issue, just in case, I can take a look and see if it can be improved? Thanks 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants