-
Notifications
You must be signed in to change notification settings - Fork 92
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
google-cloud-node idioms, for consideration #71
Comments
👍 |
In addition to everything @stephenplusplus mentioned, there are a few differences between the gapic layer and GCN.
|
I think this is being addressed in #64 |
@callmehiphop does this work for the Emulator support point: #46? |
Basically, we made the design decision that the gapic layers to be close to gRPC definitions (i.e. the same method names + protobuf messages directly). @omaray and @anthmgoogle for the confirmation. cc @bjwatson too. Because of this, naming changes or restructuring the data structure might conflict with the design policy unfortunately -- and that would require lots of changes on our code generators and codegen configurations (for mapping). |
You're right, it's not possible to use other implementations of promises. Filed #72.
I don't remember why that's only them. @geigerj might remember why those error codes are chosen (I vaguely remember some documentations for which codes should be retryable, but I've lost it).
It is also discussed internally, allow customizing the emulator endpoints as some environment variable IIRC. I haven't heard any updates for that recently, but that will be addressed later. |
I think it could! Here's how we currently do emulator support var bigtable = require('@google-cloud/bigtable')({
customEndpoint: 'a/b/c:8080'
}); I believe the gapic equivalent would be something like var grpc = require('grpc');
var bigtable = require('@google-cloud/bigtable')({
servicePath: 'a/b/c',
port: 8080,
sslCreds: grpc.credentials.createInsecure()
}); |
(note: we should review the discussion again and create issues for individual improvements and fixes) |
2.5 years in - I think most of the APIs we have exposed here in gax are pretty settled in sadly. @stephenplusplus @callmehiphop - if we want to make any of this stuff actionable, I would really love it if y'all would create individually actionable bugs that can be picked at one at a time :) |
Originally brought up: googleapis/google-cloud-node#1801 (comment)
google-cloud-node (GCN) has some conventions which ideally could be used here. It would be great to achieve a common UX that can be re-used by a developer when hopping between APIs.
Resource hierarchy
The GCN library layers its classes so that if you need a GCS "Object", for example, you go through 2 parent layers, the GCS class, and then a bucket:
I can't speak for certain how this would look with the generated layer, but a simple interpretation would be something like:
The hierarchy used by GCN is nice because it lets you cache one resource that you intend to make multiple calls with;
myFile.delete()
,myFile.createReadStream()
, etc.Accessor methods
GCN distinguishes between two types of objects: a "Service" (Google Cloud Storage), and a "ServiceObject" (a Bucket). A consistent set of methods are exposed on a ServiceObject:
ServiceObject#create({ config options }, function(err, serviceObjectInstance, apiResponse) {})
ServiceObject#delete(function(err, apiResponse) {})
ServiceObject#exists(function(err, exists, apiResponse) {})
ServiceObject#get(function(err, serviceObjectInstance, apiResponse) {})
ServiceObject#getMetadata(function(err, metadata, apiResponse) {})
ServiceObject#setMetadata({ new metadata }, function(err, apiResponse) {})
*Methods that don't apply for a specific ServiceObject are removed, e.g. you can't delete a Compute Engine Region, but you can get its metadata.
Streaming methods / naming conventions
The upstream API has its own implementation of logical naming patterns, and in the generated layer, those probably shouldn't be tampered with. However, it might be appreciated by Node.js developers to recognize some names they know from other libraries, for example,
createReadStream()
andcreateWriteStream()
where there are readable and writable streams.In GCN's Bigtable API, we expose a
createReadStream()
to access the proto service's "ReadRows" method.We've also seen naming conflicts between JavaScript/Node.js definitions and the language-agnostic API terminology. Having a small handwritten map of convenience/conventional names to upstream names might be a big help.
// cc: @bjwatson @jgeewax @callmehiphop @jmdobry
The text was updated successfully, but these errors were encountered: