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

QueryBus with Guzzle/Promises? #174

Closed
enumag opened this issue Nov 29, 2017 · 5 comments
Closed

QueryBus with Guzzle/Promises? #174

enumag opened this issue Nov 29, 2017 · 5 comments

Comments

@enumag
Copy link
Member

enumag commented Nov 29, 2017

Is it possible to somehow use QueryBus with Guzzle/Promises?

The main reason why I'd like to use Guzzle promises is the synchrionous wait method. From the examples I found for QueryBus it seems we need to get the result with

		$promise = $this->queryBus->dispatch($query);

		$result = null;
		$promise->then(
			function ($value) use (&$result) {
				$result = $value;
			}
		);

		return $result;

which is quite disgusting imo. If there is some nicer way, please tell me.

Also Guzzle promises have more installations on packagist (by far the most installations among all php promise libraries) and implement Promises/A+ where as React only implements the older Promises/A spec.

@prolic
Copy link
Member

prolic commented Nov 30, 2017

This would be a BC break and can only be done with new major release. But you can also copy paste the query bus implementation and make your desired adjustments, if you need it.

@codeliner
Copy link
Member

We hoped to see a promise PSR but async-interop group failed :( If someone has an idea how we can use a promise interface only and make it possible to work with different promise implementations this would be a good reason for a new major version. But switching promise implementation is not an option. Can't you use a react promise to guzzle promise converter?

@enumag
Copy link
Member Author

enumag commented Dec 2, 2017

I understand - and agree. I was quite confused that there is no Promise PSR yet to be honest.

Can't you use a react promise to guzzle promise converter?

Maybe, I don't know enough about promises to try that.

@prolic
Copy link
Member

prolic commented Dec 2, 2017 via email

@enumag
Copy link
Member Author

enumag commented Dec 2, 2017

I talked with a friend who explained to me how promises work. Now I see that the example code I linked in the first post will only work if the promise is a FulfilledPromise. So it doesn't make sense to use promises at all since I don't use any non-blocking API to get the results anyway - shame but PHP database API is not really made for that. So what I'll try to do instead is to write a QueryBus which won't use promises at all.

@enumag enumag closed this as completed Dec 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants