-
Notifications
You must be signed in to change notification settings - Fork 207
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(routing): manual mediator pickup lifecycle management #989
Changes from 4 commits
083b670
6dd1cf9
600400f
e92b912
5c41bc6
cea59d6
d8f7f63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,21 +7,17 @@ import { SubjectInboundTransport } from '../../../../../../tests/transport/Subje | |
import { SubjectOutboundTransport } from '../../../../../../tests/transport/SubjectOutboundTransport' | ||
import { getBaseConfig, waitForBasicMessage } from '../../../../tests/helpers' | ||
import { Agent } from '../../../agent/Agent' | ||
import { ConsoleLogger, LogLevel } from '../../../logger' | ||
import { HandshakeProtocol } from '../../connections' | ||
import { MediatorPickupStrategy } from '../MediatorPickupStrategy' | ||
|
||
const logger = new ConsoleLogger(LogLevel.info) | ||
const recipientConfig = getBaseConfig('Mediation: Recipient', { | ||
const recipientConfig = getBaseConfig('Pickup: Recipient', { | ||
autoAcceptConnections: true, | ||
indyLedgers: [], | ||
logger, | ||
}) | ||
const mediatorConfig = getBaseConfig('Mediation: Mediator', { | ||
const mediatorConfig = getBaseConfig('Pickup: Mediator', { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also ran into issues with this 😆 |
||
autoAcceptConnections: true, | ||
endpoints: ['rxjs:mediator'], | ||
indyLedgers: [], | ||
logger, | ||
}) | ||
|
||
describe('E2E Pick Up protocol', () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,10 +35,13 @@ export class WsOutboundTransport implements OutboundTransport { | |
|
||
public async stop() { | ||
this.logger.debug('Stopping WS outbound transport') | ||
this.transportTable.forEach((socket) => { | ||
socket.removeEventListener('message', this.handleMessageEvent) | ||
socket.close() | ||
}) | ||
|
||
await Promise.all( | ||
Array.from(this.transportTable.values()).map((socket) => { | ||
socket.removeEventListener('message', this.handleMessageEvent) | ||
socket.close() | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there are any promises involved here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. Was part of an experiment and left it by mistake 🙈 |
||
) | ||
} | ||
|
||
public async sendMessage(outboundPackage: OutboundPackage) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ import { | |
} from '../src/modules/proofs' | ||
import { MediatorPickupStrategy } from '../src/modules/routing' | ||
import { LinkedAttachment } from '../src/utils/LinkedAttachment' | ||
import { sleep } from '../src/utils/sleep' | ||
import { uuid } from '../src/utils/uuid' | ||
|
||
import { | ||
|
@@ -342,11 +341,7 @@ describe('Present Proof', () => { | |
state: ProofState.Done, | ||
}) | ||
|
||
// We want to stop the mediator polling before the agent is shutdown. | ||
// FIXME: add a way to stop mediator polling from the public api, and make sure this is | ||
// being handled in the agent shutdown so we don't get any errors with wallets being closed. | ||
faberAgent.config.stop$.next(true) | ||
aliceAgent.config.stop$.next(true) | ||
await sleep(2000) | ||
await aliceAgent.mediationRecipient.stopMessagePickup() | ||
await faberAgent.mediationRecipient.stopMessagePickup() | ||
}) | ||
Comment on lines
+344
to
346
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. much better API |
||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we give this a more specific name? I'm already not a huge fan I named it stop$ for the generic agent shutdown subject
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've set it to stopMessagePickup$ to be more specific. Didn't want it to collide with stopMessagePickup() method but, as it is a private field, it should not be confusing I think.