UNPKG

@google-cloud/spanner

Version:
54 lines 1.96 kB
"use strict"; /*! * Copyright 2017 Google Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.END_TO_END_TRACING_HEADER = exports.LEADER_AWARE_ROUTING_HEADER = exports.CLOUD_RESOURCE_HEADER = void 0; exports.addLeaderAwareRoutingHeader = addLeaderAwareRoutingHeader; exports.getCommonHeaders = getCommonHeaders; /*! * HTTP header for the resource prefix to improve routing * by the backend. */ exports.CLOUD_RESOURCE_HEADER = 'google-cloud-resource-prefix'; /*! * HTTP header to route the requests at Leader */ exports.LEADER_AWARE_ROUTING_HEADER = 'x-goog-spanner-route-to-leader'; /* * END TO END TRACING header. */ exports.END_TO_END_TRACING_HEADER = 'x-goog-spanner-end-to-end-tracing'; /** * Add Leader aware routing header to existing header list. * @param headers Existing header list. */ function addLeaderAwareRoutingHeader(headers) { headers[exports.LEADER_AWARE_ROUTING_HEADER] = 'true'; } /** * Returns common headers to add. * @param headers Common header list. */ function getCommonHeaders(resourceName, enableTracing) { const headers = {}; if (process.env.SPANNER_ENABLE_END_TO_END_TRACING === 'true' || enableTracing) { headers[exports.END_TO_END_TRACING_HEADER] = 'true'; } headers[exports.CLOUD_RESOURCE_HEADER] = resourceName; return headers; } //# sourceMappingURL=common.js.map