-
Notifications
You must be signed in to change notification settings - Fork 213
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
wait for job result before emitting complete. #85
Conversation
I'm not sure what the official rules are for making breaking changes are now that we're |
We could add an option, e.g. |
The BigQuery team has previously requested that we provide both a high and low level method for all methods that create a job. Aside from that using an option to change the signature of a callback has generally been frowned upon in the past. Not to mention this behavior might be found confusing since no other job related methods follow this pattern. |
API team feedback is welcome. We wouldn't change the signature-- we can still emit "complete" with the job. IMO, we'd be making the behavior of the method more logical.
Do we have stream methods that follow that pattern? |
But the Job itself would be in a different state, hence why this is a breaking change. IMO that is a signature change. I'll go with whatever the group decides, but my vote would be for a new higher level method instead of using an option. |
I think there's room for multiple interpretations of breaking-- to me, the contestants for considering this a breaking change are:
The candidates for this to be a bug fix to me are:
If we decide a breaking change, that's fine. When considering how to solve, I'll just mention that |
@stephenplusplus what's the status on this one? |
Codecov Report
@@ Coverage Diff @@
## master #85 +/- ##
=========================================
Coverage ? 99.68%
=========================================
Files ? 4
Lines ? 640
Branches ? 0
=========================================
Hits ? 638
Misses ? 2
Partials ? 0
Continue to review full report at Codecov.
|
I've updated the PR, it still needs tests. Before I get to that point, I suppose a quick roundup of opinions on this change would help decide if we want this change. My thoughts are stated above and throughout the discussion so far. @JustinBeckwith hearing your thoughts would be great! |
I'm going to be honest - I'm not deep enough with this module to make an informed decision on what we should do :) We have a semver major bump coming up very soon, so if we're going to make a breaking change, now's the time. I would trust the opinion @tswast here. |
I've definitely found it confusing that
We actually somewhat ignored this advice in the Python client because it made a whole lot more sense to make a flexible method for creating a job (well, technically we have a method for each job type) and provide multiple ways to wait for it to finish (blocking + asynchronously). I think the same logic applies to Node.js: we should use the the built-in ways to wait for things. I'm happy so long as the following are satisfied:
|
415e53b
to
c33f10b
Compare
👍 I made the change. Here's the old and new: Beforetable.createWriteStream(...)
.on('complete', job => {
job
.on('error', err => {
// Job failed.
})
.on('complete', () => {
// Job completed successfully.
});
}); Aftertable.createWriteStream(...)
.on('error', err => {
// Job failed.
})
.on('job', job => {
// `job` is a Job object.
})
.on('finish', () => {
// Job completed successfully.
}); And, table.createWriteStream(...)
.on('error', err => {
// Job failed.
})
.on('complete', job => {
// `job` is a Job object.
// Job completed successfully.
}); |
Fixes #174 Closes #173 - [x] Tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary) The original issue being addressed (#174) was remedied by simply upgrading the common package. However additional bugs were identified after that were introduced via #85. A second commit to fix said bug was created.
Fixes #8
This would be a breaking change
Currently, if you call
table.createWriteStream()
, the stream will emit "complete" with a Job object. You can then use that Job object to assign event handlers, as usual with an LRO. Judging from #8, I'm not sure this pattern is clear to the users. And aside from that, I'm not sure what we're doing is ideal, either.Ideally, we would not emit "complete" until the Job finished, instead of making the user do it manually. This PR shows how easy it would be for us to implement. However, I believe this would be a breaking change, although it's hard to say if it's actually a bugfix.
I'm leaving this open for discussion on how we should handle this. Please share your thoughts!
Before
After
And,
complete
still works to combine those. I added the "finish" event, because that's the natural writable stream closing event.