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

distributed-promise as a feature here #103

@jpwilliams

Description

@jpwilliams

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.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions