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

Missing factory for StopWorkers #196

Open
pimjansen opened this issue Apr 14, 2023 · 2 comments
Open

Missing factory for StopWorkers #196

pimjansen opened this issue Apr 14, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@pimjansen
Copy link

Hey,

I noticed that the messenger:stop-workers command is not implemented. This is not a problem however i am struggling a but to implement the factory myself where the command requires a CacheItemPoolInterface

Any guide on how to handle this? It would be a good addition to add the factory to this lib i suppose.

Thanks!

@gsteel
Copy link
Member

gsteel commented Apr 14, 2023

Good idea to implement a factory here 👍

The cache pool will need to be identified in configuration, for example:

return [
  'symfony' => [
    'messenger' => [
      'signalCachePool' => 'MyCachePoolServiceId',
    ],
  ],
  'dependencies' => [
    'factories' => [
      'MyCachePoolServiceId' => SomeFactory::class,
    ],
  ]
];

With the above, a factory for the command would then look up the service id in symfony.messenger.signalCachePool and fetch that from the container.

In order for the command to do anything, the listener StopWorkerOnRestartSignalListener has to be attached to each worker - this listener also needs the same cache pool.

The main problem for this lib is that the Stop command will need to be optional because its factory will throw an exception when there's no cache pool configured - we can't provide some kind of default cache because the cache needs to be distributed in order for it to work between processes.

@gsteel gsteel added the enhancement New feature or request label Apr 14, 2023
@pimjansen
Copy link
Author

Yeah thats why im reaching out since it important to see what this lib wants.

We can ship a default factory that resolves to a factory on a static key? From there everyone can use it and resolve to their own implementation.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants