Skip to content

Datastore: allow user-defined timeouts #2221

Description

@justinrosenthal

The datastore package uses grpc to communicate with the Datastore API. Currently none of the RPC calls set a timeout which results in a timeout of infinity (no timeout).

There does not appear to be a way for the user to either set a default timeout at the Datastore instance level (i.e. Datastore({defaultTimeout: 10000})), nor is there a way to specify one on a per-request basis (i.e. datastore.save(entity, {timeout: 10000})).

As a specific example, in the save() method, protoOpts gets created internally and there are no hooks for the user to modify it: https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/packages/datastore/src/request.js#L953

It seems to me that a default timeout could be applied by doing something like this in the _request() method, but I'm not familiar enough with google-cloud-node to know if this is the right way to go about things for your APIs:

if (protoOpts.timeout === undefined) {
  protoOpts.timeout = this.defaultTimeout;
}

Activity

  1. stephenplusplus commented on Apr 14, 2017

    @stephenplusplus
    Contributor

    Thanks for bringing this up, and you're correct that there isn't a way to override that currently. That will be allowed as we knock out this mega-issue: #1859. The Datastore PR is #2195. It will use a middle layer between us and gRPC called gax. That layer sets defaults for the timeout here: https://github.com/GoogleCloudPlatform/google-cloud-node/blob/master/packages/datastore/src/v1/datastore_client_config.json I think beyond that, we will only allow per-request configuration.

    I'm going to close, since this is asking for a feature that will be accomplished with the progress of that issue. Please subscribe to that or the PR for a heads-up when we add this behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: datastoreIssues related to the Datastore API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions