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

Close the AMQP client on CLI exit #74

Merged
merged 1 commit into from
Jan 15, 2025
Merged

Conversation

swansontec
Copy link
Contributor

@swansontec swansontec commented Dec 31, 2024

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

none

Copy link
Contributor

@samholmes samholmes left a comment

Choose a reason for hiding this comment

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

Is explicit client closing necessary for the main app (server) between restarts?

src/cli/cli.ts Outdated
Comment on lines 35 to 36
process.exitCode = await cli.run(args, context)
await connections.amqpClient.close()
Copy link
Contributor

Choose a reason for hiding this comment

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

Idea: You can create closeConnections(connections: DbConnections) function to close all connected resources. In there you can either close the connection to the ampqClient like you do here, or you can leverage the reference on the AMQPQueue interface:

function closeConnections(connections: DbConnections): Promise<void> {
  await connections.queue.channel.connection.close()
}

This way you can keep all resource cleanup in this single function and you can avoid leaking the abstraction provided by the queue interface.

@swansontec swansontec force-pushed the william/fix-cli-lifetime branch from 741bb0c to b40eeda Compare January 9, 2025 22:35
@swansontec swansontec force-pushed the william/fix-cli-lifetime branch from b40eeda to dd6beb4 Compare January 15, 2025 18:12
@swansontec swansontec enabled auto-merge January 15, 2025 18:12
@swansontec swansontec merged commit 8f9feab into master Jan 15, 2025
3 checks passed
@swansontec swansontec deleted the william/fix-cli-lifetime branch January 15, 2025 18:15
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.

2 participants