UNPKG

@openland/foundationdb-core

Version:

Node.js bindings for the FoundationDB database

56 lines (54 loc) 2.12 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const native_1 = __importDefault(require("./native")); // To update: // - regenerate lib/opts.g.ts using scripts/gentsopts.ts // - re-run the test suite and binding test suite exports.MAX_VERSION = 600; let apiVersion = null; exports.get = () => apiVersion; function set(version, headerVersion) { if (typeof version !== 'number') { throw TypeError('version must be a number'); } if (apiVersion != null) { if (apiVersion !== version) { throw Error('foundationdb already initialized with API version ' + apiVersion); } } else { // Old versions probably work fine, but there are no tests to check. if (version < 500) { throw Error('FDB Node bindings only support API versions >= 500'); } if (version > exports.MAX_VERSION) { // I'd like allow it to work with newer versions anyway since API // changes seem to be backwards compatible, but native.setAPIVersion // will throw anyway. throw Error(`Cannot use foundationdb protocol version ${version} > ${exports.MAX_VERSION}. This version of node-foundationdb only supports protocol versions <= ${exports.MAX_VERSION}. Please update node-foundationdb if you haven't done so then file a ticket: https://github.com/josephg/node-foundationdb/issues Until this is fixed, use FDB API version ${exports.MAX_VERSION}. `); } try { if (headerVersion == null) { native_1.default.setAPIVersion(version); } else { native_1.default.setAPIVersionImpl(version, headerVersion); } } catch (e) { if (!e || e.message !== 'API version may be set only once') { throw e; } } apiVersion = version; } } exports.set = set; //# sourceMappingURL=apiVersion.js.map