nodejs-datastore icon indicating copy to clipboard operation
nodejs-datastore copied to clipboard

Several options not available on DatastoreOptions

Open chadbr opened this issue 6 years ago • 3 comments

Hello,

I use several option flags for datastore that aren't defined in the current type definition.

Today I define my options as 'any' but I'd like to be able to have some type safety.

Examples: servicePath - this has the hostname of the datastore instance... we use it to ensure unit tests are running against localhost and not a production database...

maxRetries -- self explanatory...

We also set these because of an older bug... but I could see not wanting to add them to options? 'grpc.max_send_message_length': -1, // unlimited 'grpc.max_receive_message_length': -1 // unlimited

Thanks, Chad

chadbr avatar Oct 17 '19 16:10 chadbr

@chadbr Datastore constructor accepts options: DatastoreOptions which include apiEndpoint as one of the parameters, you should be able to

const datastoreClient = new Datastore({
    apiEndpoint: 'localhost:' + customPort,
})

to set a custom hostname for unit tests.

All rpc call functions take gaxOptions: CallOptions as part of function's options or directly. And gaxOptions expose maxRetries parameter.

As far as grpc.max_send_message_length: -1 grpc.max_receive_message_length: -1 These are no longer needed as Datastore switched to grpc-js and grpc-js does not have an issue with pre-set maximum send/receive message size (similar issue from bigtable library)

Is this information helpful?

AVaksman avatar Oct 18 '19 04:10 AVaksman

@AVaksman

Yes, We use those options to create the endpoint -- it's at a later point we want to check the connected Datastore object... We can use apiEndpoint -- but servicePath is simply more convenient.

On the gaxOptions -- Can I set those in the options passed to Datastore constructor? Or I have to set them on every call?

Thanks, Chad

chadbr avatar Oct 18 '19 13:10 chadbr

gaxOptions needs to be passed on every call.

AVaksman avatar Oct 18 '19 14:10 AVaksman