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

fix: mediator updates #432

Merged

Conversation

TimoGlastra
Copy link
Contributor

  • extract logic for implicit pickup from websocket transport to mediation module
    • This will make it easier to move to implicit pickup of non-websocket transports
  • add test for restarting recipient agent
  • add timeout to return when is connected
  • fix issue where services were not reassigned after sorting or filtering
  • add persistence for mediator routing keys

Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
Signed-off-by: Timo Glastra <timo@animo.id>
@TimoGlastra TimoGlastra requested a review from a team as a code owner August 20, 2021 08:23
@codecov-commenter
Copy link

codecov-commenter commented Aug 20, 2021

Codecov Report

Merging #432 (5ea2270) into main (56cb9f2) will increase coverage by 0.41%.
The diff coverage is 68.81%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #432      +/-   ##
==========================================
+ Coverage   85.66%   86.07%   +0.41%     
==========================================
  Files         249      252       +3     
  Lines        5351     5394      +43     
  Branches      796      797       +1     
==========================================
+ Hits         4584     4643      +59     
+ Misses        767      751      -16     
Impacted Files Coverage Δ
packages/core/src/types.ts 100.00% <ø> (ø)
packages/core/src/transport/WsOutboundTransport.ts 7.81% <18.18%> (+3.86%) ⬆️
...ckages/core/src/modules/routing/RecipientModule.ts 63.81% <21.73%> (+0.77%) ⬆️
packages/core/src/agent/MessageSender.ts 71.42% <33.33%> (ø)
.../modules/connections/services/ConnectionService.ts 98.85% <100.00%> (+<0.01%) ⬆️
...odules/routing/repository/MediatorRoutingRecord.ts 100.00% <100.00%> (ø)
...es/routing/repository/MediatorRoutingRepository.ts 100.00% <100.00%> (ø)
...kages/core/src/modules/routing/repository/index.ts 100.00% <100.00%> (ø)
...re/src/modules/routing/services/MediatorService.ts 73.00% <100.00%> (+4.03%) ⬆️
packages/core/src/storage/BaseRecord.ts 72.22% <100.00%> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 56cb9f2...5ea2270. Read the comment docs.

const queueService = allServices.find((s) => isDidCommTransportQueue(s.serviceEndpoint))

//If restrictive will remove services not listed in schemes list
if (transportPriority?.restrictive) {
services.filter((service) => {
services = services.filter((service) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JamesKEbert @burdettadam The services were not being reassigned meaning the sort and filter did not do anything. This should fix it.

This means that currently it will take the http endpoint, send the ping and receive the ping response after which the http endpoint is closed 😄

So if we could merge this rather sooner than later that would be great!

Copy link
Contributor

Choose a reason for hiding this comment

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

How embarrassing! Thanks for catching that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Whoooops--my bad!
As a side note, the array.sort() method does actually do its operation in place and returns too, so it doesn't necessarily have to be reassigned too, but doesn't hurt to reassign it. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah you're right. So weird that filter does not do its operation in place, but sort does. Thanks

@TimoGlastra TimoGlastra linked an issue Aug 20, 2021 that may be closed by this pull request
Signed-off-by: Timo Glastra <timo@animo.id>
Copy link
Contributor

@JamesKEbert JamesKEbert left a comment

Choose a reason for hiding this comment

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

These are great, thanks @TimoGlastra! I am okay merging, but definitely would like to remove our need to externalize the connectionRecords to the transports.

this.transportTable.forEach((socket) => {
socket.removeEventListener('message', this.handleMessageEvent)
socket.close()
})
}

public async sendMessage(outboundPackage: OutboundPackage) {
const { payload, endpoint } = outboundPackage
const { payload, endpoint, connection } = outboundPackage
Copy link
Contributor

Choose a reason for hiding this comment

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

I personally would really like to see this be connectionId as a string vs sending the whole connectionRecord, since that starts to really tie our transports into the inner workings of the Framework more than they are now.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's an interesting point. But connectionRecrod is already part of the public API of the framework 🤔 If you think we're exposing too much framework internal info via connectionRecord, maybe, we should introduce some domain object hiding unnecessary details.

})

await this.openMediationWebSocket(mediator)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't those methods be part of the transport layer rather than inside the core of the framework? Or, it's just temporary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What it does is sending a trust ping message with a restriction to only use websocket. The websocket will be kept alive autmoatically (I'd like to make the keep alive more explicit)

I'm not sure yet how we could nicely integrate this into the transport layer. Would be nice to not make it WebSocket specific (so just send a ping and keep the socket alive), but we need to specify somewhere which transports are capable of this, as e.g. HTTP isn't.

Maybe a transport should be able to specify whether it can send multiple messages (WebSocket is ∞, while HTTP is 1 request, 1 response). That way we wouldn't have to specify WS explicitly, but rather whether we want a transport that can stay open (for implicit pickup)

I'm going to think about it for a while. We can have a discussion about it in the WG call

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 have opened #435. Please leave your thoughts :)

this.transportTable.forEach((socket) => {
socket.removeEventListener('message', this.handleMessageEvent)
socket.close()
})
}

public async sendMessage(outboundPackage: OutboundPackage) {
const { payload, endpoint } = outboundPackage
const { payload, endpoint, connection } = outboundPackage
Copy link
Contributor

Choose a reason for hiding this comment

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

That's an interesting point. But connectionRecrod is already part of the public API of the framework 🤔 If you think we're exposing too much framework internal info via connectionRecord, maybe, we should introduce some domain object hiding unnecessary details.

@jakubkoci
Copy link
Contributor

I see there is some bugfix as part of the PR so we should merge it.

Signed-off-by: Timo Glastra <timo@animo.id>
@TimoGlastra TimoGlastra enabled auto-merge (squash) August 21, 2021 09:57
@TimoGlastra TimoGlastra merged commit 163cda1 into openwallet-foundation:main Aug 21, 2021
@TimoGlastra TimoGlastra deleted the feat/mediation-updates branch October 28, 2021 10:11
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.

Mediator routing keys are not persisted between startups
6 participants