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

feat: auto bind event exchanges to endpoints #6

Closed

Conversation

maxjoehnk
Copy link
Contributor

closes #4

Copy link
Member

@drusellers drusellers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good. I'd like to see some tests on the changes that you are making. I know that the test coverage is lacking but we need to start addressing that.

Additionally, if you have any links to why a library should NOT have package-lock.json I'd be interested to read them. Most of the links that I found are rather stale and can be found to argue each way.

Also , this PR has commits from another PR that post merge may cause issues. Please consider isolating commits to a single PR to simplify reviews.

@@ -127,7 +127,7 @@ export class Transport extends EventEmitter implements Transport {
if (this.channel) {
let channel = this.channel;
return new Promise((resolve, reject) => {
const result = channel.publish(exchange, routingKey, body, {persistent: true},
const result = channel.publish(exchange, routingKey, body, {persistent: true, contentType: "application/vnd.masstransit+json"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get a unit test on this? I know that the unit test coverage is low for this project but any help there would be appreciated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added some tests for the publish mechanism as well as the delayed publishing when sending messages before the channel connection was established.

@@ -135,7 +135,7 @@ class MassTransitBus extends EventEmitter implements Bus {
console.log('Connecting', this.hostAddress.toString());

try {
this.connection = connect(this.hostAddress + '?heartbeat=60');
this.connection = connect(this.hostAddress + '?heartbeat=60') as unknown as Promise<Connection>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does casting it to unknown then Promise help? Why the as unknown at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bluebird promise type seems to be incompatible with the native Promise type which is circumvented by the unknown cast.
When I cast directly to Promise I receive the following error:

TS2352: Conversion of type 'Bluebird' to type 'Promise' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.   The types returned by 'then(...)' are incompatible between these types.     Property '[Symbol.toStringTag]' is missing in type 'Bluebird' but required in type 'Promise'.

If you have a better idea I'll gladly change it.


toExchange(): string {
return `${this.ns}:${this.name}`
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This we can get a test on pretty easily

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

for (const messageType of this.boundEvents) {
await channel.bindExchange(this.queueName, messageType.toExchange(), '');
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get a test on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests for the configureTopology method.

@maxjoehnk
Copy link
Contributor Author

Alright, I'll remove the remove precompiled commit as it is part of #5 anyway.
I would actually like to setup some integration tests between MassTransit and MassTransit-JS as well. Would you be interested in those?
Regarding the lock file, I might've mixed this best practice up between Rust and Javascript development as I'm unable to find an official source for this claim. I'll check on this later. If you want I can revert the commit that removed the lock file.

@phatboyg
Copy link
Member

phatboyg commented Feb 1, 2022

Rebased/merged.

@phatboyg phatboyg closed this Feb 1, 2022
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

Successfully merging this pull request may close these issues.

No Binding between Primary and Intermediate Exchange
3 participants