-
Notifications
You must be signed in to change notification settings - Fork 4
Implement promise interface for non-stream-based commands #34
Conversation
Ah my workflow now looks like this: let port = 5918;
let agent = await serf.agent(port);
let client = await serf.client(port);
let members = await client.members();
console.log(members); And I can't tell you how happy that makes me that it looks this simple 😄 |
c31ad0d
to
1cec6b8
Compare
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.
Code looks good 👍. Would be nice to add a test for one of the methods.
README.md
Outdated
@@ -42,6 +42,33 @@ var client = Serf.connect(function (err) { | |||
}); | |||
``` | |||
|
|||
All of them non-stream-based commands also have a promise interface if you'd |
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.
Minor typo: s/them/the
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.
Oops my bad, will fix that now and add a test 👍
Wait no the tests are failing, I'll give that a look-over bear with me. |
e2eb4e9
to
c03c973
Compare
Hm, actually I wonder if it should only return a Promise if there is no callback provided. It's unfortunate to get |
Good plan, let's give that one a try. |
e1e2acb
to
cedcc6b
Compare
Okay so this is odd - the particular test case now passes but it breaks all future test cases:
|
ddc7bf3
to
06e6541
Compare
Okay after testing locally this happens too, I hadn't tested multiple access types. For some reason when attempting to make another request after the first promise-based one, none of the other requests work. Will look into this now. |
You can monitor the serf process's output with something like
and get...
I'm not seeing an obvious cause, but let me know if you need help debugging and I'll look more closely. |
b076883
to
6ea2113
Compare
Okay this could take some work. I'm gonna close this for now and revisit this specifically in perhaps a day or two; in the meantime I'm going to test out another solution that I've been working on that I hope to be able to implement into this. |
This PR implements a simple optional promise interface as outlined in #33. Luckily based on what you guys said, it doesn't break backwards-compatability (🎉) as these methods didn't return anything anyway. You can now use the non-streaming commands in the following ways:
Standard
With promises method
With
await
/async
I've also included some brief documentation in the README, but I've had to include b6dd867 because I couldn't get it to work on my machine without including it. Once the other #31 has been merged I'll rebase this with master and remove that commit so it doesn't clog the log, so to speak.