UNPKG

@google-cloud/bigtable

Version:
52 lines 1.9 kB
"use strict"; // Copyright 2022 Google LLC // // 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 // // https://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. // // ** This file is automatically generated by gapic-generator-typescript. ** // ** https://github.com/googleapis/gapic-generator-typescript ** // ** All changes to this file may be overwritten. ** Object.defineProperty(exports, "__esModule", { value: true }); exports.MockServer = void 0; const google_gax_1 = require("google-gax"); const DEFAULT_PORT = 1234; class MockServer { port; services = new Set(); server; constructor(callback, port) { const portString = Number(port ? port : DEFAULT_PORT).toString(); this.port = portString; const server = new google_gax_1.grpc.Server(); this.server = server; server.bindAsync(`localhost:${this.port}`, google_gax_1.grpc.ServerCredentials.createInsecure(), () => { callback ? callback(portString) : undefined; }); } setService(service, implementation) { if (this.services.has(service)) { this.server.removeService(service); } else { this.services.add(service); } this.server.addService(service, implementation); } shutdown(callback) { this.server.tryShutdown((err) => { callback(err); }); } } exports.MockServer = MockServer; //# sourceMappingURL=mock-server.js.map