Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

distributed-promise as a feature here #103

Open
jpwilliams opened this issue Jan 5, 2020 · 0 comments
Open

distributed-promise as a feature here #103

jpwilliams opened this issue Jan 5, 2020 · 0 comments
Assignees

Comments

@jpwilliams
Copy link
Owner

It's occured to me that the technique used at @jpwilliams/distributed-promise might also be a very relevant feature here.

If it were to be added, the result would never be cached, as that's not a good idea within RabbitMQ. We could still make use of the distributed promises though.

So how might it work? I see two possibilities right now - either a new API or add it to request's functionality.

// endpoint
remit.endpoint('user.get')
	.handler(() => ({ id: 1, name: 'Jack' }))
	.start()
// service A
const getUser = remit.request('user.get')
const user = await getUser()
// ...
// service B
const getUser = remit.request('user.get')
const user = await getUser()
// finds call by service A with same args currently in-flight,
// so doesn't send another request, but waits for that response.

Ignoring implementation details, would we have to ensure that all arguments are the same here? As in, not just the input going to the endpoint, but also things like the local request's timeout? It might also be pertinent to either have to opt in or out of the functionality via RequestOptions.

Really interesting little idea.

@jpwilliams jpwilliams self-assigned this Jan 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant