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

Add versionAllWithErrors to return info on which hosts succeeded or failed #21

Merged
merged 4 commits into from
Nov 16, 2023

Conversation

schleyfox
Copy link

versionAll throws on the first error it receives and does not include information on which host was responsible for the error. If the error is thrown quickly, the method will be stopped before other hosts have a chance to respond. Observers of the callbacks will view this as a host timeout.

versionAllWithErrors changes this to wait on all responses regardless of error status and return a map of servers containing either the returned version or the error. The callbacks are extended to also record the error case explicitly so that in a case where there is a timeout in the monitoring code before the method returns the observer can record partial success and specific errors.

dummyServer2.write = function () {
dummyServer2.error({
name: "ErrorName",
message: "This is an expected error.",

Choose a reason for hiding this comment

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

Is there any real error example?
Something like EConnectError?

Copy link
Author

@schleyfox schleyfox Nov 16, 2023

Choose a reason for hiding this comment

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

In the test we use a non-error object for ease of equality checking (though I suppose we could just construct an Error object of our choosing)

Possible errors are:

throw new Error("ERROR Too many open connections");

this.error(new Error("Memcached server authentication failed!"));

self.error(new Error("socket closed unexpectedly."));

self.error(new Error("socket timed out connecting to server."));

server.error(new Error("socket timed out waiting on response."));

any errors that socket can have (things like ECONNRESET, etc):

memjs/src/memjs/server.ts

Lines 225 to 227 in c84319e

self._socket.on("error", function (error) {
self.error(error);
});

and whatever this is

this.createAndLogError("VERSION", response!.header.status)

@schleyfox schleyfox merged commit 9137a13 into master Nov 16, 2023
1 check passed
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