Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Propositions #6

Open
mderrien29 opened this issue May 30, 2022 · 1 comment
Open

Propositions #6

mderrien29 opened this issue May 30, 2022 · 1 comment

Comments

@mderrien29
Copy link

First of all, good work, now that's a lib i want to use ! :)

Some suggestions:

Do we ever want to change the setup function ?

It looks like we would always want to assert, assert, bind.
Maybe we could hide it ?

const adapter = createRabbitMQAdapter(...)();
adapter.consume('exchange', 'queue', 'routingKey', handler);

Maybe this can help remove the duplicate 'my-queue' in await adapter.consumeEvent('my-queue', consumer)();

How do we respond to commands ?

I see the EventHandler, is there something similar such as a CommandHandler which takes an extra publisher parameter (very express-like) ? Or something more complicated ?

EventHandler<Payload> = (event) => ...
CommandHandler<Payload> = (command, response) => ...
@jeremylvln
Copy link
Member

I kinda like this setup function mechanism, it mimic what the underlying amqp-connection-manager library requires. More, I guess we should stick to the amqp standard, we consume a queue and not a exchange/routing key pair, so adding the "shortcut" here will just make things more complex :/

For the commands, I've added an example file, you were close but the type is RPCHandler<RequestPayload, ReplyPayload>. It is exactly the same as the EventHandler<Payload> with only the Right side of the TaskEither different: the event requires a void here (as no response) whereas the RPC requires the ReplyPayload given as generic.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants