Requires
- module:@google-cloud/firestore
- module:@google-cloud/error-reporting
- module:debug
- module:gax
Members
(inner, constant) commonObjects :object
Common constant values and functions.
(inner, constant) gaxOptions
Configure call CallSettings object.
(inner, constant) options :Object
Gax retry options.
Request configuration options, outlined here:
Methods
(inner) authInfoHandler(req, res)
Returns JSON base64 encoded X-Endpoint-API-UserInfo.
Parameters:
| Name | Type | Description |
|---|---|---|
req |
object |
The req object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on. In this documentation and by convention, the object is always referred to as req (and the HTTP response is res) but its actual name is determined by the parameters to the callback function in which you are working. |
res |
object |
The res object represents the HTTP response that an Express app sends when it gets an HTTP request. In this documentation and by convention, the object is always referred to as res (and the HTTP request is req) but its actual name is determined by the parameters to the callback function in which you are working. The res object is an enhanced version of Node’s own response object and supports all |
- Source:
- See:
(inner) callWithRetry(fn, depth)
Generic async function used to retry a function until the supplied max depth.
Parameters:
| Name | Type | Description |
|---|---|---|
fn |
function |
Name of the async function to execute. |
depth |
number |
max number of times to retry the supplied async function. |
(inner) firestoreConvertResponse(documentPath, response, resource, keyName, component, globalLogFields) → {object}
Converts a Firestore response payload to clean JSON object.
Parameters:
| Name | Type | Description |
|---|---|---|
documentPath |
string |
Firestore document path for the document.get() operation. |
response |
object |
Parsed Firestore javascript object. |
resource |
string |
Resource name (aka table name) of the object - so for example 'orders' or 'customers'. |
keyName |
string |
Name of the primary key of the resource - so for example 'orderId' or 'customerId'. |
component |
string |
Name of the component the custom metric is for. Component is used to group together all the log entries related to a request. |
globalLogFields |
object |
Object used to add log correlation which nest all log messages for a request beneath the request log in Log Viewer. |
Returns:
| Type | Description |
|---|---|
| object |
Converted resource object. |
(inner) firestoreGetValue(node) → {object}
Retrieves a Firestore value from different data type objects (String, Boolean, Geo, Timestamp)
Parameters:
| Name | Type | Description |
|---|---|---|
node |
object |
The Firestore input object. |
Returns:
| Type | Description |
|---|---|
| object |
|
(inner) getGlobalLogFields(req)
Add log correlation to nest all log messages beneath request log in Log Viewer.
Parameters:
| Name | Type | Description |
|---|---|---|
req |
object |
The req object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on. In this documentation and by convention, the object is always referred to as req (and the HTTP response is res) but its actual name is determined by the parameters to the callback function in which you are working. |
(async, inner) getMediaInfo(id, component, globalLogFields) → {Promise.<*>}
Return Bynder media asset object.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
Bynder asset unique identifier. |
component |
string |
Name of the component the custom metric is for. Component is used to group together all the log entries related to a request. |
globalLogFields |
object |
Object used to add log correlation which nest all log messages for a request beneath the request log in Log Viewer. |
Returns:
| Type | Description |
|---|---|
| Promise.<*> |
(async, inner) getMetaproperties(component, globalLogFields) → {Promise.<*>}
Return all Bynder metaproperties.
Parameters:
| Name | Type | Description |
|---|---|---|
component |
string |
Name of the component the custom metric is for. Component is used to group together all the log entries related to a request. |
globalLogFields |
object |
Object used to add log correlation which nest all log messages for a request beneath the request log in Log Viewer. |
Returns:
| Type | Description |
|---|---|
| Promise.<*> |
(inner) logAppError(message, component, globalLogFields)
In production, creates JSON structured Google Stackdriver log ERROR entry. Log viewer accesses 'component' as 'jsonPayload.component'. Otherwise, logs message to stderr.
Parameters:
| Name | Type | Description |
|---|---|---|
message |
string |
Error message description. |
component |
string |
Name of the component that generated the error. |
globalLogFields |
object |
Global logging.googleapis.com/trace object. |
(inner) logAppInfo(message, component, globalLogFields)
In production, creates JSON structured Google Stackdriver log INFO entry. Log viewer accesses 'component' as 'jsonPayload.component'. Otherwise, logs message to stderr.
Parameters:
| Name | Type | Description |
|---|---|---|
message |
string |
Info message description. |
component |
string |
Name of the component that log message is for. |
globalLogFields |
object |
Global logging.googleapis.com/trace object. |
(inner) logError()
Control stderr logging using DEBUG command line flag. set DEBUG=app:error on the command line to enable stderr logging.
Examples
DEBUG=app:error node index.js
DEBUG=app:* node index.js
when DEBUG=app:error command line flag is not set stderr logging is disabled.
node index.js
(inner) logError()
Control stderr logging using DEBUG command line flag. set DEBUG=app:error on the command line to enable stderr logging.
Examples
DEBUG=app:error node index.js
DEBUG=app:* node index.js
when DEBUG=app:error command line flag is not set stderr logging is disabled.
node index.js
(inner) logInfo()
Control stderr logging using DEBUG command line flag. set DEBUG=app:log on the command line to enable stderr logging.
Examples
DEBUG=app:error node index.js
DEBUG=app:* node index.js
when DEBUG=app:log command line flag is not set stderr logging is disabled.
node index.js
(inner) logInfo()
Control stdout logging using DEBUG command line flag. set DEBUG=app:log on the command line to enable stdout logging.
Examples
DEBUG=app:log node index.js
DEBUG=app:* node index.js
when DEBUG=app:log command line flag is not set stdout logging is disabled.
node index.js
(inner) onExit(childProcess) → {Promise.<*>}
Child process stderr, stdout and exit event listener.
Parameters:
| Name | Type | Description |
|---|---|---|
childProcess |
object |
The child process object to listen to events for. |
Returns:
| Type | Description |
|---|---|
| Promise.<*> |
(inner) writeEndpointRequestCountTimeSeriesDataPoint(req, endpoint, component, globalLogFields, productIds, subject)
Write custom metric time series data to track request count by endpoint and requestor IP.
Parameters:
| Name | Type | Description |
|---|---|---|
req |
object |
The req object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on. In this documentation and by convention, the object is always referred to as req (and the HTTP response is res) but its actual name is determined by the parameters to the callback function in which you are working. |
endpoint |
string |
Name of the API Endpoint. |
component |
string |
Name of the component the custom metric is for. Component is used to group together all the log entries related to a request. |
globalLogFields |
object |
Object used to add log correlation which nest all log messages for a request beneath the request log in Log Viewer. |
productIds |
string |
One or more product ids the request is for. |
subject |
string |
SNS Notification subject or GET request header. |
(inner) writeFile(filePath, data)
Write JSON data to file system.
Parameters:
| Name | Type | Description |
|---|---|---|
filePath |
string |
File systems path for the file to create. |
data |
object |
JSON object to write to a file. |
Type Definitions
BackoffSettings
Parameters to the exponential backoff algorithm for retrying.
Properties:
| Name | Type | Description |
|---|---|---|
initialRetryDelayMillis |
number |
the initial delay time, in milliseconds, between the completion of the first failed request and the initiation of the first retrying request. |
retryDelayMultiplier |
number |
the multiplier by which to increase the delay time between the completion of failed requests, and the initiation of the subsequent retrying request. |
maxRetryDelayMillis |
number |
the maximum delay time, in
milliseconds, between requests. When this value is reached,
|
initialRpcTimeoutMillis |
number |
the initial timeout parameter to the request. |
rpcTimeoutMultiplier |
number |
the multiplier by which to increase the timeout parameter between failed requests. |
maxRpcTimeoutMillis |
number |
the maximum timeout parameter, in
milliseconds, for a request. When this value is reached,
|
totalTimeoutMillis |
number |
the total time, in milliseconds, starting from when the initial request is sent, after which an error will be returned, regardless of the retrying attempts made meanwhile. |
CallOptions
Encapsulates the overridable settings for a particular API call.
CallOptions is an optional arg for all GAX API calls. It is used to
configure the settings of a specific API call.
When provided, its values override the GAX service defaults for that particular call.
Typically, the API clients will accept this as the second to the last argument. See the examples below.
Properties:
| Name | Type | Description |
|---|---|---|
timeout |
number |
The client-side timeout for API calls. |
retry |
object |
determines whether and how to retry on transient errors. When set to null, the call will not retry. |
autoPaginate |
boolean |
If set to false and the call is configured for paged iteration, page unrolling is not performed, instead the callback will be called with the response object. |
pageToken |
object |
If set and the call is configured for paged iteration, paged iteration is not performed and requested with this pageToken. |
maxResults |
number |
If set and the call is configured for paged iteration, the call will stop when the number of response elements reaches to the specified size. By default, it will unroll the page to the end of the list. |
isBundling |
boolean |
If set to false and the call is configured for bundling, bundling is not performed. |
longrunning |
BackoffSettings |
BackoffSettings used for polling. |
Examples
// suppress bundling for bundled method.
api.bundlingMethod(
param, {optParam: aValue, isBundling: false}, function(err, response) {
// handle response.
});
// suppress streaming for page-streaming method.
api.pageStreamingMethod(
param, {optParam: aValue, autoPaginate: false}, function(err, page) {
// not returning a stream, but callback is called with the paged response.
});