-
Notifications
You must be signed in to change notification settings - Fork 35
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
feat: add timeout to options and use it in the reqOpts #455
Changes from 2 commits
1af7c88
eec73b0
72ef5db
784ac6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,7 @@ export interface ServiceOptions extends GoogleAuthOptions { | |
promise?: PromiseConstructor; | ||
email?: string; | ||
token?: string; | ||
timeout?: number; // http.request.options.timeout | ||
} | ||
|
||
export class Service { | ||
|
@@ -84,6 +85,7 @@ export class Service { | |
authClient: GoogleAuth; | ||
private getCredentials: {}; | ||
readonly apiEndpoint: string; | ||
timeout: number; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't this be optional? Or are we setting it to a default value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am referencing this below |
||
|
||
/** | ||
* Service is a base class, meant to be inherited from by a "service," like | ||
|
@@ -103,6 +105,7 @@ export class Service { | |
constructor(config: ServiceConfig, options: ServiceOptions = {}) { | ||
this.baseUrl = config.baseUrl; | ||
this.apiEndpoint = config.apiEndpoint; | ||
this.timeout = options.timeout!; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd be nervous using the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
this.globalInterceptors = arrify(options.interceptors_!); | ||
this.interceptors = []; | ||
this.packageJson = config.packageJson; | ||
|
@@ -179,7 +182,7 @@ export class Service { | |
reqOpts: DecorateRequestOptions | StreamRequestOptions, | ||
callback?: BodyResponseCallback | ||
): void | r.Request { | ||
reqOpts = extend(true, {}, reqOpts); | ||
reqOpts = extend(true, {}, reqOpts, {timeout: this.timeout}); | ||
const isAbsoluteUrl = reqOpts.uri.indexOf('http') === 0; | ||
const uriComponents = [this.baseUrl]; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alexander-fenster I'm curious - do we expose a gRPC option for timeout in the GAPIC libraries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly, but GAPIC libraries can pass any gRPC option by prefixing it with
grpc.
and it will be passed all the way down to gRPC.