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

Not using pair key in pipeToRouter() #738

Closed
piranna opened this issue Dec 21, 2021 · 4 comments
Closed

Not using pair key in pipeToRouter() #738

piranna opened this issue Dec 21, 2021 · 4 comments

Comments

@piranna
Copy link
Contributor

piranna commented Dec 21, 2021

At

const pipeTransportPairKey = router.id;
pipeToRouter() is using only destination Router ID as key of the pair of Router instances, as it was discussed in #697. Later on
this.#mapRouterPairPipeTransportPairPromise.set(
pipeTransportPairKey, pipeTransportPairPromise);
router.addPipeTransportPair(this.id, pipeTransportPairPromise);
it's being stored at mapRouterPairPipeTransportPairPromise with router.id and at addPipeTransportPair() with this.id, so not using pair key at all but just storing them twice (equally acceptable) and removing it later on both
localPipeTransport.observer.on('close', () =>
{
remotePipeTransport.close();
this.#mapRouterPairPipeTransportPairPromise.delete(
pipeTransportPairKey);
});
remotePipeTransport.observer.on('close', () =>
{
localPipeTransport.close();
this.#mapRouterPairPipeTransportPairPromise.delete(
pipeTransportPairKey);
});
and
pipeTransportPairPromise
.then((pipeTransportPair) =>
{
const localPipeTransport = pipeTransportPair[this.id];
// NOTE: No need to do any other cleanup here since that is done by the
// Router calling this method on us.
localPipeTransport.observer.on('close', () =>
{
this.#mapRouterPairPipeTransportPairPromise.delete(
pipeTransportPairKey);
});
})
.catch(() =>
{
this.#mapRouterPairPipeTransportPairPromise.delete(
pipeTransportPairKey);
});
. Is this right? The rest of the pair selection code seems to be ok, just only missing the [this.id, router.id].sort().join(',') part, isn't it? Or am I missing something? Are we storing the pair in local pairs and also in remote Router ones instead of having a common list with unique IDs? Is it just not using a global list the only reason of doing it that way?

@ibc
Copy link
Member

ibc commented Dec 21, 2021

Please let's not open issues in GH for asking questions or having discussions.

Are we storing the pair in local pairs and also in remote Router ones instead of having a common list with unique IDs? Is it just not using a global list the only reason of doing it that way?

Yes

@ibc ibc closed this as completed Dec 21, 2021
@piranna
Copy link
Contributor Author

piranna commented Dec 21, 2021

Please let's not open issues in GH for asking questions or having discussions.

Yeah, sorry for that, I first was writting a bug report since only saw the first const pipeTransportPairKey = router.id line and got confused with it being the key and though it was a bug, but later while writting the bug issue I was collecting references on the code to see if there was something I was overlooking, that's why finally I asked about it to ensure my conclusions were right, code got to be a bit complex to understand in this feature...

@ibc
Copy link
Member

ibc commented Dec 21, 2021

Code got a bit complex to avoid having global state, but not that much.

@piranna
Copy link
Contributor Author

piranna commented Dec 21, 2021

Code got a bit complex to avoid having global state, but not that much.

Logic is fine, and I really like the aproach, very smart :-) It's more about code structure, that Promise with Promise.then() inside... ugh :-/

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

No branches or pull requests

2 participants