package.dist.src.config.middleware.middleware.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.MiddlewareMessage = exports.MiddlewareStatus = exports.MiddlewareMetadata = void 0;
const cache_request_logging_1 = require("./cache-request-logging");
class MiddlewareMetadata {
constructor(metadata) {
this._grpcMetadata = metadata;
}
toJsonObject() {
return this._grpcMetadata.toJSON();
}
toJsonString() {
return JSON.stringify(this._grpcMetadata.toJSON());
}
}
exports.MiddlewareMetadata = MiddlewareMetadata;
class MiddlewareStatus {
constructor(status) {
this._grpcStatus = status;
}
code() {
return this._grpcStatus.code;
}
}
exports.MiddlewareStatus = MiddlewareStatus;
class MiddlewareMessage {
constructor(message) {
this._grpcMessage = message;
}
messageLength() {
if (this._grpcMessage !== null && this._grpcMessage !== undefined) {
return this._grpcMessage.serializeBinary().length;
}
return 0;
}
constructorName() {
return this._grpcMessage.constructor.name;
}
// Note: APIs that use streaming interceptors (e.g. GetBatch and SetBatch)
// will not see these debug messages
toLogFormat() {
const requestToLogConverter = cache_request_logging_1.CacheRequestToLogInterfaceConverter.get(this.constructorName());
if (requestToLogConverter === undefined) {
console.warn('Unable to find requestToLogConverter for', this.constructorName());
return { requestType: this.constructorName() };
}
return requestToLogConverter(this._grpcMessage);
}
}
exports.MiddlewareMessage = MiddlewareMessage;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlkZGxld2FyZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9jb25maWcvbWlkZGxld2FyZS9taWRkbGV3YXJlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUVBLG1FQUdpQztBQUVqQyxNQUFhLGtCQUFrQjtJQUU3QixZQUFZLFFBQWtCO1FBQzVCLElBQUksQ0FB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