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(agent): add close method #317

Merged
merged 5 commits into from Nov 30, 2021
Merged

feat(agent): add close method #317

merged 5 commits into from Nov 30, 2021

Conversation

JKRhb
Copy link
Member

@JKRhb JKRhb commented Nov 16, 2021

This PR adds a close method to the Agent class that aborts all pending requests and resolves #312. To do so, a small bug is fixed in the abort method where the _msgInFlight hasn't been decremented when a request is cancelled.

An additional test is added to assert that the new method works as expected.

@coveralls
Copy link

coveralls commented Nov 16, 2021

Pull Request Test Coverage Report for Build 1473967935

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.9%) to 88.312%

Totals Coverage Status
Change from base Build 1427777898: 0.9%
Covered Lines: 562
Relevant Lines: 610

💛 - Coveralls

@JKRhb
Copy link
Member Author

JKRhb commented Nov 16, 2021

Ping @relu91 :)

@JKRhb JKRhb force-pushed the close-method branch 2 times, most recently from c08521c to dc70ea7 Compare November 17, 2021 20:38
Copy link
Contributor

@relu91 relu91 left a comment

Choose a reason for hiding this comment

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

I'm not coap expert but looking at the logic seems good. This should allow freeing all resources without waiting for responses :)

@JKRhb
Copy link
Member Author

JKRhb commented Nov 17, 2021

I'm not coap expert but looking at the logic seems good. This should allow freeing all resources without waiting for responses :)

Thank you for the feedback! :) I added a last couple of changes to the method so that you can both provide an optional callback and listen for close events. This way the API is more similar to the one the CoAP server provides. I think if @Apollon77 could also have a look on it then the PR should be able to be merged :)

@JKRhb JKRhb requested review from Apollon77 and removed request for Apollon77 November 24, 2021 16:56
@Apollon77
Copy link
Collaborator

Add that close before 1.0 or after? ;-)

@Apollon77
Copy link
Collaborator

BTW: LGTM

@JKRhb
Copy link
Member Author

JKRhb commented Nov 29, 2021

Add that close before 1.0 or after? ;-)

Hmm, good question ;) I think we could already integrate it in 1.0 if this would be fine for you, but we could also put it into a separate minor (or patch?) release if you prefer.

@Apollon77 Apollon77 merged commit fbe3fc3 into coapjs:master Nov 30, 2021
@Apollon77
Copy link
Collaborator

:-)

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

Successfully merging this pull request may close these issues.

Add close() method to Agent
4 participants