package.dist.src.internal.grpc.middlewares-interceptor.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.middlewaresInterceptor = void 0;
const grpc_js_1 = require("@grpc/grpc-js");
const middleware_1 = require("../../config/middleware/middleware");
const constants_1 = require("@grpc/grpc-js/build/src/constants");
const connectivity_state_1 = require("@grpc/grpc-js/build/src/connectivity-state");
function middlewaresInterceptor(loggerFactory, middlewares, middlewareRequestContext, grpcClient = null) {
const logger = loggerFactory.getLogger('grpc-interceptor');
return (options, nextCall) => {
const middlewareRequestHandlers = middlewares.map(m => m.onNewRequest(middlewareRequestContext));
// create a copy of the handlers and reverse it, because for the response life cycle actions we should call
// the middlewares in the opposite order.
const reversedMiddlewareRequestHandlers = [
...middlewareRequestHandlers,
].reverse();
const requester = {
start: function (metadata, listener, next) {
const newListener = {
onReceiveMetadata: function (metadata, next) {
applyMiddlewareHandlers('onResponseMetadata', reversedMiddlewareRequestHandlers, (h) => (m) => h.onResponseMetadata(m), new middleware_1.MiddlewareMetadata(metadata), (metadata) => next(metadata._grpcMetadata));
},
onReceiveMessage: function (
// unfortunately grpc uses `any` in their type defs for these
// eslint-disable-next-line @typescript-eslint/no-explicit-any
message,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
next) {
applyMiddlewareHandlers('onResponseBody', reversedMiddlewareRequestHandlers, (h) => (request) => h.onResponseBody(request), new middleware_1.MiddlewareMessage(message), (msg) => next(msg === null || msg === void 0 ? void 0 : msg._grpcMessage));
},
onReceiveStatus: function (status, next) {
var _a, _b;
if (status.code === constants_1.Status.DEADLINE_EXCEEDED) {
// getConnectivityState(true) will return state of connection and
// also try to connect if it's idle, false will just get the status
const connectionStatus = (_b = (_a = grpcClient === null || grpcClient === void 0 ? void 0 : grpcClient.getChannel()) === null || _a === void 0 ? void 0 : _a.getConnectivityState(false)) !== null && _b !== void 0 ? _b : null;
logger.warn(`Deadline Exceeded! Received status: ${status.code} ${status.details} and grpc connection status: ${connectionStatus
? connectivity_state_1.ConnectivityState[connectionStatus]
: 'unable to get connection status'}`);
}
applyMiddlewareHandlers('onResponseStatus', reversedMiddlewareRequestHandlers, (h) => (s) => h.onResponseStatus(s), new middleware_1.MiddlewareStatus(status), (s) => next(s._grpcStatus));
},
};
applyMiddlewareHandlers('onRequestMetadata', middlewareRequestHandlers, (h) => (m) => h.onRequestMetadata(m), new middleware_1.MiddlewareMetadata(metadata), (m) => next(m._grpcMetadata, newListener));
},
// unfortunately grpc uses `any` in their type defs for these
// eslint-disable-next-line @typescript-eslint/no-explicit-any
sendMessage: function (message, next) {
applyMiddlewareHandlers('onRequestBody', middlewareRequestHandlers, (h) => (request) => h.onRequestBody(request), new middleware_1.MiddlewareMessage(message), (m) => next(m._grpcMessage));
},
};
return new grpc_js_1.InterceptingCall(nextCall(options), requester);
};
}
exports.middlewaresInterceptor = middlewaresInterceptor;
function applyMiddlewareHandlers(name, handlers, middlewareHandlerReduceFn, originalInput, nextFn) {
let remainingHandlers = handlers;
let middlewarePromise = Promise.resolve(originalInput);
while (remainingHandlers.length > 0) {
const nextHandler = middlewareHandlerReduceFn(remainingHandlers[0]);
middlewarePromise = middlewarePromise
.then(newT => nextHandler(newT))
.catch(e => {
throw e;
});
remainingHandlers = remainingHandlers.slice(1);
}
middlewarePromise
.then(newT => nextFn(newT))
.catch(e => {
throw e;
});
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWlkZGxld2FyZXMtaW50ZXJjZXB0b3IuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvaW50ZXJuYWwvZ3JwYy9taWRkbGV3YXJlcy1pbnRlcmNlcHRvci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSwyQ0FRdUI7QUFFdkIsbUVBTzRDO0FB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bnQtZGlzYWJsZS1uZXh0LWxpbmUgQHR5cGVzY3JpcHQtZXNsaW50L25vLWV4cGxpY2l0LWFueVxuICAgICAgICAgICAgbWVzc2FnZTogYW55LFxuICAgICAgICAgICAgLy8gZXNsaW50LWRpc2FibGUtbmV4dC1saW5lIEB0eXBlc2NyaXB0LWVzbGludC9uby1leHBsaWNpdC1hbnlcbiAgICAgICAgICAgIG5leHQ6IChtZXNzYWdlOiBhbnkpID0+IHZvaWRcbiAgICAgICAgICApOiB2b2lkIHtcbiAgICAgICAgICAgIGFwcGx5TWlkZGxld2FyZUhhbmRsZXJzKFxuICAgICAgICAgICAgICAnb25SZXNwb25zZUJvZHknLFxuICAgICAgICAgICAgICByZXZlcnNlZE1pZGRsZXdhcmVSZXF1ZXN0SGFuZGxlcnMsXG4gICAgICAgICAgICAgIChoOiBNaWRkbGV3YXJlUmVxdWVzdEhhbmRsZXIpID0+XG4gICAgICAgICAgICAgICAgKHJlcXVlc3Q6IE1pZGRsZXdhcmVNZXNzYWdlIHwgbnVsbCkgPT5cbiAgICAgICAgICAgICAgICAgIGgub25SZXNwb25zZUJvZHkocmVxdWVzdCksXG4gICAgICAgICAgICAgIG5ldyBNaWRkbGV3YXJlTWVzc2FnZShtZXNzYWdlIGFzIE1lc3NhZ2UpLFxuICAgICAgICAgICAgICAobXNnOiBNaWRkbGV3YXJlTWVzc2FnZSB8IG51bGwpID0+IG5leHQobXNnPy5fZ3JwY01lc3NhZ2UpXG4gICAgICAgICAgICApO1xuICAgICAgICAgIH0sXG4gICAgICAgICAgb25SZWNlaXZlU3RhdHVzOiBmdW5jdGlvbiAoXG4gICAgICAgICAgICBzdGF0dXM6IFN0YXR1c09iamVjdCxcbiAgICAgICAgICAgIG5leHQ6IChzdGF0dXM6IFN0YXR1c09iamVjdCkgPT4gdm9pZFxuICAgICAgICAgICk6IHZvaWQge1xuICAgICAgICAgICAgaWYgKHN0YXR1cy5jb2RlID09PSBTdGF0dXMuREVBRExJTkVfRVhDRUVERUQpIHtcbiAgICAgICAgICAgICAgLy8gZ2V0Q29ubmVjdGl2aXR5U3RhdGUodHJ1ZSkgd2lsbCByZXR1cm4gc3RhdGUgb2YgY29ubmVjdGlvbiBhbmRcbiAgICAgICAgICAgICAgLy8gYWxzbyB0cnkgdG8gY29ubmVjdCBpZiBpdCdzIGlkbGUsIGZhbHNlIHdpbGwganVzdCBnZXQgdGhlIHN0YXR1c1xuICAgICAgICAgICAgICBjb25zdCBjb25uZWN0aW9uU3RhdHVzID1cbiAgICAgICAgICAgICAgICBncnBjQ2xpZW50Py5nZXRDaGFubmVsKCk/LmdldENvbm5lY3Rpdml0eVN0YXRlKGZhbHNlKSA/PyBudWxsO1xuICAgICAgICAgICAgICBsb2dnZXIud2FybihcbiAgICAgICAgICAgICAgICBgRGVhZGxpbmUgRXhjZWVkZWQhIFJlY2VpdmVkIHN0YXR1czogJHtzdGF0dXMuY29kZX0gJHtcbiAgICAgICAgICAgICAgICAgIHN0YXR1cy5kZXRhaWxzXG4gICAgICAgICAgICAgICAgfSBhbmQgZ3JwYyBjb25uZWN0aW9uIHN0YXR1czogJHtcbiAgICAgICAgICAgICAgICAgIGNvbm5lY3Rpb25TdGF0dXNcbiAgICAgICAgICAgICAgICAgICAgPyBDb25uZWN0aXZpdHlTdGF0ZVtjb25uZWN0aW9uU3RhdHVzXVxuICAgICAgICAgICAgICAgICAgICA6ICd1bmFibGUgdG8gZ2V0IGNvbm5lY3Rpb24gc3RhdHVzJ1xuICAgICAgICAgICAgICAgIH1gXG4gICAgICAgICAgICAgICk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBhcHBseU1pZGRsZXdhcmVIYW5kbGVycyhcbiAgICAgICAgICAgICAgJ29uUmVzcG9uc2VTdGF0dXMnLFxuICAgICAgICAgICAgICByZXZlcnNlZE1pZGRsZXdhcmVSZXF1ZXN0SGFuZGxlcnMsXG4gICAgICAgICAgICAgIChoOiBNaWRkbGV3YXJlUmVxdWVzdEhhbmRsZXIpID0+IChz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