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

Connections fix #27

Merged
merged 3 commits into from
Sep 15, 2017
Merged

Conversation

mattyouill
Copy link
Contributor

Fix how the client is setup and torn down so that it:

  • Tracks connections that have been opened so they can be closed.
  • Tracks background tasks that have been setup so they can be shut down.
  • Closes connection sockets.
  • Shuts down background tasks.

This was needed to run the test cases as a suite. Previously they only worked individually.

Bound client exit to exit function and also improved debug logging.

This is a step towards fixing #11 but more needs to be done. At least the test suite runs now :)

- Tracks connections that have been opened so they can be closed.
- Tracks background tasks that have been setup so they can be shut down.
- Closes connection sockets.
- Shuts down background tasks.

This was needed to run the test cases as a suite. Previously they only worked individually.

Bound client exit to exit function and also improved debug logging.

This is a step towards fixing VoltDB#11 but more needs to be done. At least the test suite runs now :)
}
//} else {
// callback();
//}
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these lines commented out by accident or on purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey, previously you couldn't clean up a VoltClient so there was a check to see if the client needed to be created (i.e. create client only if client == null). It's not needed anymore, in fact the test a bit more test-ey (is that a word?) as it creates and tears down the connection a few times. Can prob remove those lines entirely... I guess I left them there as this PR is only one of probably a few more before the client is working nicely. Shall I remove commented lines?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Thanks for the clarification. I think you can remove them.

lib/client.js Outdated
/**
* TODO: Previously connection only registered once socket established, but it means
* the connection can't be torn down properly if it doesn't connect. So... it's now registered on
* init. Need to investigate whether registering the connection earlier will cause any problems.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the only problem would be when trying to close a connection failed to connect. If any error is handled on close(), it should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change was made specifically for failed connections... i.e. the flush fn would keep firing and keep generating errors and there was no way to stop it. Seems ok now, even with a bad socket.

Can add a bit more defensive code around clean up if you feel would be better?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think that's a good idea. Then you can remove this TODO. Thanks!

@mattyouill
Copy link
Contributor Author

Hey mate, did the tidy up. Found a typo and fixed that too.

@nshi nshi merged commit 293b6c2 into VoltDB:master Sep 15, 2017
@nshi
Copy link
Contributor

nshi commented Sep 15, 2017

Thanks, @mattyouill !

@mattyouill mattyouill deleted the feature/connections-fix branch September 19, 2017 04:29
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