-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add Temporal support #49
base: 2.x
Are you sure you want to change the base?
Conversation
Hi! Thank you for the great work, and sorry for the late review! I like the autoconfiguration of workflows / activities :) |
HttpWorker $httpWorker, | ||
TemporalWorker $temporalWorker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing that forces the DIC to resolve the 2 workers but only one is used (and Temporal might even be not installed).
It's the kind of place where we could inject the container and use return $container->get(HttpWorkerInferface::class)
so the service is created only if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've marked them with lazy()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking them lazy
force the users to install symfony/proxy-manager-bridge
.
If you feel incomfortable injecting the whole container, maybe we could use a service locator
to inject a scoped container, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like service locator. As you can see :)
What do you think if I add supports($mode): bool
method into workers and configure resolver to get array of workers and pass the conditions below into them?
It will look like the following:
TemporalWorker:
supports($mode):
$mode === 'temporal'
HttpWorker:
supports($mode):
$mode === 'http'
And this resolver will look:
class WorkerResolver
{
function __construct(iterable $workers){}
function resolve($mode) {
foreach($this->workers as $worker)) {
if($worker->supports($mode){
return $worker;
}
throw new Exception();
}
WorkerResolver will be configured in the container with a tag
and !tagged_iterator
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do this, the DIC may still instantiate the 2 workers but only one is useful, I think a locator is the best way, it's precisily why service locators exists, in the Symfony doc:
Sometimes, a service needs access to several other services without being sure that all of them will actually be used
Hi, I will look at your comments at the weekends or a bit later. |
@Baldinof I've resolved your comments. Can you please review again?
Like this format: temporal_workers:
first_worker:
option1: value1
option2: value2:
second_worker:
option1: value3
option2: value4 This settings will be converted and used in the factory that mentioned above. |
@Baldinof can you have a look? |
Yes! Sorry for being late, I will try to have a look by the end of this week!
|
HttpWorker $httpWorker, | ||
TemporalWorker $temporalWorker |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Marking them lazy
force the users to install symfony/proxy-manager-bridge
.
If you feel incomfortable injecting the whole container, maybe we could use a service locator
to inject a scoped container, what do you think?
service(TemporalWorker::class), | ||
]); | ||
|
||
$services |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in services.php
|
||
namespace Baldinof\RoadRunnerBundle\Worker; | ||
|
||
interface WorkerResolverInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also be used in Baldinof\RoadRunnerBundle\Runtime\Runner
@rmikalkenas if you mind you may finalize this PR by yourself. I lost all context of this PR and don't have time to reproduce all scenarios |
[#48] Added https://github.com/temporalio/sdk-php support.
If you want also tests I can add them a bit later or you can do it yourself 😉 .
Now I want to discuss about solution in general.
You can see how it works in https://github.com/xepozz/symfony-temporal-demo.