Refactor Transaction and Dataset into DatastoreRequest#231
Refactor Transaction and Dataset into DatastoreRequest#231ryanseys wants to merge 9 commits intogoogleapis:masterfrom ryanseys:refactor-transaction-dataset
Conversation
|
regression test |
|
Just linking these together for us: #204 Thoughts so far:
Overall, I like the separation. We should make sure this structure is 👍 so that we can mimic it throughout the codebase as we go on supporting the other services. To support that goal, is there a way we could make an even more abstract var remoteStream = https.request(request, function(resp) {
var buffer = new Buffer('');
resp.on('data', function(chunk) {
buffer = Buffer.concat([buffer, chunk]);
});
resp.on('end', function() {
util.handleResp(null, resp, buffer.toString(), function(err) {
if (err) {
cb(err);
return;
}
cb(null, respType.decode(buffer));
});
});
});
remoteStream.on('error', cb);
remoteStream.write(req.toBuffer());
remoteStream.end();Something like: Any of these sub-classes can implement their own |
|
Yes that would be ideal, to separate into a common module that can be used across all APIs. |
|
Having any class have to create a new |
|
There is still a benefit to abstracting some commonalities, such as creating streams, handling errors/responses, creating authenticated requests, etc. but it's ok to put this off for now. If we think we need to abstract later, we can revisit that then. Are there any changes you want to make to this pr or is it ready for review? |
|
Yes. I agree. It's important to pull out the streaming stuff and some common entities but it's beyond the scope of this PR. |
|
I changed DatastoreRequester to DatastoreRequest and fixed small transaction bug so I think this is ready for more formal review. 😄 thanks! |
|
Should |
|
I like it, but I think we're going to have a tough time working this into the docs. Atm, the only thing I can think of is having a new docs page for the DatastoreRequest module that is linked to from Dataset. |
lib/datastore/dataset.js
Outdated
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
How about |
|
sure just as long as we don't confuse it with |
|
We can still name it in a way that's helpful locally, if you think something like this is better: var DatastoreRequest = require('./request.js'); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
lib/datastore/dataset.js
Outdated
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
…ncy versions (#231) This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/a1c25589-9aeb-49f0-922e-4037066a83df/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: googleapis/synthtool@fdd03c1
* chore(deps): upgrade @google-cloud/paginator to v0.1.2 * fix(system-test): filter by label when testing pagination
* build: run tests on node11 * build: run tests on node11 * build: run tests on node11 * build: run tests on node11
Might be missing documentation in a few areas because I wanted to get the structural changes out first before we refine it.
Separates the request logic out from Dataset and Transaction into a
DatastoreRequesterwhich probably isn't the best name but can be refactored as well. Feel free to send suggestions.