package.dist.src.internal.storage-data-client.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk Show documentation
Show all versions of sdk Show documentation
Client SDK for Momento services
The newest version!
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StorageDataClient = void 0;
const sdk_core_1 = require("@gomomento/sdk-core");
const utils_1 = require("@gomomento/sdk-core/dist/src/internal/utils");
const store_1 = require("@gomomento/generated-types/dist/store");
const headers_interceptor_1 = require("./grpc/headers-interceptor");
const grpc_js_1 = require("@grpc/grpc-js");
const package_json_1 = require("../../package.json");
const grpc_channel_options_1 = require("./grpc/grpc-channel-options");
const cache_1 = require("../config/transport/cache");
const cache_service_error_mapper_1 = require("../errors/cache-service-error-mapper");
const retry_interceptor_1 = require("./grpc/retry-interceptor");
class StorageDataClient {
/**
* @param {StorageClientAllProps} props
*/
constructor(props) {
this.configuration = props.configuration;
this.credentialProvider = props.credentialProvider;
this.cacheServiceErrorMapper = new cache_service_error_mapper_1.CacheServiceErrorMapper(false);
this.logger = this.configuration.getLoggerFactory().getLogger(this);
this.requestTimeoutMs = this.configuration
.getTransportStrategy()
.getGrpcConfig()
.getDeadlineMillis();
this.validateRequestTimeout(this.requestTimeoutMs);
this.logger.debug(`Creating storage client using endpoint: '${this.credentialProvider.getStorageEndpoint()}'`);
// NOTE: This is hard-coded for now but we may want to expose it via StorageConfiguration in the
// future, as we do with some of the other clients.
const grpcConfig = new cache_1.StaticGrpcConfiguration({
deadlineMillis: this.configuration
.getTransportStrategy()
.getGrpcConfig()
.getDeadlineMillis(),
maxSessionMemoryMb: StorageDataClient.DEFAULT_MAX_SESSION_MEMORY_MB,
});
const channelOptions = (0, grpc_channel_options_1.grpcChannelOptionsFromGrpcConfig)(grpcConfig);
this.client = new store_1.store.StoreClient(this.credentialProvider.getStorageEndpoint(), this.credentialProvider.isStorageEndpointSecure()
? grpc_js_1.ChannelCredentials.createSsl()
: grpc_js_1.ChannelCredentials.createInsecure(), channelOptions);
this.interceptors = this.initializeInterceptors(this.configuration.getLoggerFactory());
}
close() {
this.logger.debug('Closing storage data clients');
this.client.close();
}
validateRequestTimeout(timeout) {
this.logger.debug(`Request timeout ms: ${String(timeout)}`);
if (timeout !== undefined && timeout <= 0) {
throw new sdk_core_1.InvalidArgumentError('request timeout must be greater than zero.');
}
}
validateStoreNameOrThrowError(storeName) {
try {
(0, utils_1.validateStoreName)(storeName);
return;
}
catch (err) {
return this.cacheServiceErrorMapper.returnOrThrowError(err, err => new sdk_core_1.StoragePut.Error(err));
}
}
initializeInterceptors(_loggerFactory) {
const headers = [
new headers_interceptor_1.Header('Authorization', this.credentialProvider.getAuthToken()),
new headers_interceptor_1.Header('agent', `nodejs:store:${package_json_1.version}`),
new headers_interceptor_1.Header('runtime-version', `nodejs:${process.versions.node}`),
];
return [
headers_interceptor_1.HeaderInterceptor.createHeadersInterceptor(headers),
retry_interceptor_1.RetryInterceptor.createRetryInterceptor({
clientName: 'StorageDataClient',
loggerFactory: this.configuration.getLoggerFactory(),
retryStrategy: this.configuration.getRetryStrategy(),
overallRequestTimeoutMs: this.requestTimeoutMs,
}),
];
}
createMetadata(storeName) {
const metadata = new grpc_js_1.Metadata();
metadata.set('store', storeName);
return metadata;
}
async get(storeName, key) {
try {
(0, utils_1.validateStoreName)(storeName);
}
catch (err) {
return this.cacheServiceErrorMapper.returnOrThrowError(err, err => new sdk_core_1.StorageGet.Error(err));
}
this.logger.trace(`Issuing 'get' request; store: ${storeName}, key: ${key}`);
return await this.sendGet(storeName, key);
}
async sendGet(storeName, key) {
const request = new store_1.store._StoreGetRequest({
key: key,
});
const metadata = this.createMetadata(storeName);
return await new Promise((resolve, reject) => {
this.client.Get(request, metadata, {
interceptors: this.interceptors,
}, (err, resp) => {
var _a;
const value = (_a = resp === null || resp === void 0 ? void 0 : resp.value) === null || _a === void 0 ? void 0 : _a.value;
if (value) {
switch (value) {
case 'double_value': {
return resolve(sdk_core_1.StorageGet.Found.ofDouble(resp.value.double_value));
}
case 'string_value': {
return resolve(sdk_core_1.StorageGet.Found.ofString(resp.value.string_value));
}
case 'bytes_value': {
return resolve(sdk_core_1.StorageGet.Found.ofBytes(resp.value.bytes_value));
}
case 'integer_value': {
return resolve(sdk_core_1.StorageGet.Found.ofInt(resp.value.integer_value));
}
case 'none': {
return resolve(new sdk_core_1.StorageGet.Error(new sdk_core_1.UnknownError('StorageGet responded with an unknown result')));
}
}
}
else {
const sdkError = this.cacheServiceErrorMapper.convertError(err);
if (sdkError.errorCode() ===
sdk_core_1.MomentoErrorCode.STORE_ITEM_NOT_FOUND_ERROR) {
return resolve(new sdk_core_1.StorageGet.NotFound());
}
this.cacheServiceErrorMapper.resolveOrRejectError({
err: err,
errorResponseFactoryFn: e => new sdk_core_1.StorageGet.Error(e),
resolveFn: resolve,
rejectFn: reject,
});
}
});
});
}
async putInt(storeName, key, value) {
this.validateStoreNameOrThrowError(storeName);
this.logger.trace(`Issuing 'put' request; store: ${storeName}, key: ${key}`);
const storeValue = new store_1.store._StoreValue({ integer_value: value });
return await this.sendPut(storeName, key, storeValue);
}
async putDouble(storeName, key, value) {
this.validateStoreNameOrThrowError(storeName);
this.logger.trace(`Issuing 'put' request; store: ${storeName}, key: ${key}`);
const storeValue = new store_1.store._StoreValue({ double_value: value });
return await this.sendPut(storeName, key, storeValue);
}
async putString(storeName, key, value) {
this.validateStoreNameOrThrowError(storeName);
this.logger.trace(`Issuing 'put' request; store: ${storeName}, key: ${key}`);
const storeValue = new store_1.store._StoreValue({ string_value: value });
return await this.sendPut(storeName, key, storeValue);
}
async putBytes(storeName, key, value) {
this.validateStoreNameOrThrowError(storeName);
this.logger.trace(`Issuing 'put' request; store: ${storeName}, key: ${key}`);
const storeValue = new store_1.store._StoreValue({ bytes_value: value });
return await this.sendPut(storeName, key, storeValue);
}
async sendPut(storeName, key, storeValue) {
const request = new store_1.store._StorePutRequest({
key: key,
value: storeValue,
});
const metadata = this.createMetadata(storeName);
return await new Promise((resolve, reject) => {
this.client.Put(request, metadata, {
interceptors: this.interceptors,
}, (err, resp) => {
if (resp) {
resolve(new sdk_core_1.StoragePut.Success());
}
else {
this.cacheServiceErrorMapper.resolveOrRejectError({
err: err,
errorResponseFactoryFn: e => new sdk_core_1.StoragePut.Error(e),
resolveFn: resolve,
rejectFn: reject,
});
}
});
});
}
async delete(storeName, key) {
try {
(0, utils_1.validateStoreName)(storeName);
}
catch (err) {
return this.cacheServiceErrorMapper.returnOrThrowError(err, err => new sdk_core_1.StorageDelete.Error(err));
}
this.logger.trace(`Issuing 'delete' request; store: ${storeName}, key: ${key}`);
return await this.sendDelete(storeName, key);
}
async sendDelete(storeName, key) {
const request = new store_1.store._StoreDeleteRequest({
key: key,
});
const metadata = this.createMetadata(storeName);
return await new Promise((resolve, reject) => {
this.client.Delete(request, metadata, {
interceptors: this.interceptors,
}, (err, resp) => {
if (resp) {
resolve(new sdk_core_1.StorageDelete.Success());
}
else {
this.cacheServiceErrorMapper.resolveOrRejectError({
err: err,
errorResponseFactoryFn: e => new sdk_core_1.StorageDelete.Error(e),
resolveFn: resolve,
rejectFn: reject,
});
}
});
});
}
}
exports.StorageDataClient = StorageDataClient;
StorageDataClient.DEFAULT_MAX_SESSION_MEMORY_MB = 256;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmFnZS1kYXRhLWNsaWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9pbnRlcm5hbC9zdG9yYWdlLWRhdGEtY2xpZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLGtEQVU2QjtBQUM3Qix1RUFBOEU7QUFDOUUsaUVBQTREO0FBQzVELG9FQUFxRTtBQUNyRSwyQ0FLdUI7QUFDdkIscURBQTJDO0FBQzNDLHNFQUE2RTtBQUk3RSxxREFBa0U7QUFDbEUscUZBQTZFO0FBQzdFLGdFQUEwRDtBQUUxRCxNQUFhLGlCQUFpQjt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uIHJlc29sdmUoXG4gICAgICAgICAgICAgICAgICBTdG9yYWdlR2V0LkZvdW5kLm9mU3RyaW5nKHJlc3AudmFsdWUuc3RyaW5nX3ZhbHVlKVxuICAgICAgICAgICAgICAgICk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgY2FzZSAnYnl0ZXNfdmFsdWUnOiB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlc29sdmUoXG4gICAgICAgICAgICAgICAgICBTdG9yYWdlR2V0LkZvdW5kLm9mQnl0ZXMocmVzcC52YWx1ZS5ieXRlc192YWx1ZSlcbiAgICAgICAgICAgICAgICApO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGNhc2UgJ2ludGVnZXJfdmFsdWUnOiB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlc29sdmUoXG4gICAgICAgICAgICAgICAgICBTdG9yYWdlR2V0LkZvdW5kLm9mSW50KHJlc3AudmFsdWUuaW50ZWdlcl92YWx1ZSlcbiAgICAgICAgICAgICAgICApO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIGNhc2UgJ25vbmUnOiB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlc29sdmUoXG4gICAgICAgICAgICAgICAgICBuZXcgU3RvcmFnZUdldC5FcnJvcihcbiAgICAgICAgICAgICAgICAgICAgbmV3IFVua25vd25FcnJvcihcbiAgICAgICAgICAgICAgICAgICAgICAnU3RvcmFnZUdldCByZXNwb25kZWQgd2l0aCBhbiB1bmtub3duIHJlc3VsdCdcbiAgICAgICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgICAgICk7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgY29uc3Qgc2RrRXJyb3IgPSB0aGlzLmNhY2hlU2VydmljZUVycm9yTWFwcGVyLmNvbnZlcnRFcnJvcihlcnIpO1xuICAgIC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ldyBQcm9taXNlKChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICAgIHRoaXMuY2xpZW50LlB1dChcbiAgICAgICAgcmVxdWVzdCxcbiAgICAgICAgbWV0YWRhdGEsXG4gICAgICAgIHtcbiAgICAgICAgICBpbnRlcmNlcHRvcnM6IHRoaXMuaW50ZXJjZXB0b3JzLFxuICAgICAgICB9LFxuICAgICAgICAoZXJyOiBTZXJ2aWNlRXJyb3IgfCBudWxsLCByZXNwKSA9PiB7XG4gICAgICAgICAgaWYgKHJlc3ApIHtcbiAgICAgICAgICAgIHJlc29sdmUobmV3IFN0b3JhZ2VQdXQuU3VjY2VzcygpKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhpcy5jYWNoZVNlcnZpY2VFcnJvck1hcHBlci5yZXNvbHZlT3JSZWplY3RFcnJvcih7XG4gICAgICAgICAgICAgIGVycjogZXJyLFxuICAgICAgICAgICAgICBlcnJvclJlc3BvbnNlRmFjdG9yeUZuOiBlID0+IG5ldyBTdG9yYWdlUHV0LkVycm9yKGUpLFxuICAgICAgICAgICAgICByZXNvbHZlRm46IHJlc29sdmUsXG4gICAgICAgICAgICAgIHJlamVjdEZuOiByZWplY3QsXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICk7XG4gICAgfSk7XG4gIH1cblxuICBwdWJsaWMgYXN5bmMgZGVsZXRlKFxuICAgIHN0b3JlTmFtZTogc3RyaW5nLFxuICAgIGtleTogc3RyaW5nXG4gICk6IFByb21pc2U8U3RvcmFnZURlbGV0ZS5SZXNwb25zZT4ge1xuICAgIHRyeSB7XG4gICAgICB2YWxpZGF0ZVN0b3JlTmFtZShzdG9yZU5hbWUpO1xuICAgIH0gY2F0Y2ggKGVycikge1xuICAgICAgcmV0dXJuIHRoaXMuY2FjaGVTZXJ2aWNlRXJyb3JNYXBwZXIucmV0dXJuT3JUaHJvd0Vycm9yKFxuICAgICAgICBlcnIgYXMgRX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JNYXBwZXIucmVzb2x2ZU9yUmVqZWN0RXJyb3Ioe1xuICAgICAgICAgICAgICBlcnI6IGVycixcbiAgICAgICAgICAgICAgZXJyb3JSZXNwb25zZUZhY3RvcnlGbjogZSA9PiBuZXcgU3RvcmFnZURlbGV0ZS5FcnJvcihlKSxcbiAgICAgICAgICAgICAgcmVzb2x2ZUZuOiByZXNvbHZlLFxuICAgICAgICAgICAgICByZWplY3RGbjogcmVqZWN0LFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICApO1xuICAgIH0pO1xuICB9XG59XG4iXX0=
© 2015 - 2025 Weber Informatics LLC | Privacy Policy