Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@supertenant/core / src / tracing / actions.js
Size: Mime:
// (c) Copyright 2023 Supertenant Ltd. - all rights reserved.
// See LICENSE file in project root for license terms.
"use strict";const dedupReportError=require("../logger")["dedupReportError"],superconsts=require("@supertenant/superconsts"),DefaultWaitPollInterval=10,MinWaitPollInterval=1,MaxDelayDuration=86400,DefaultHttpRejectActionStatusCode=429,DefaultMysqlRejectActionResult={sqlState:"70100",sqlMessage:"Query execution was interrupted [SuperTenant throttling]",errno:1317},DefaultMongodbRejectActionResult={error_message:"Query execution was interrupted [SuperTenant throttling]",code:11601};function getDelayDuration(actionRef){if(null!==actionRef.Definition&&"object"==typeof actionRef.Definition){var actionRef=actionRef.Definition.delay_duration;if("number"==typeof actionRef&&0<actionRef)return(actionRef=actionRef/1e6)>MaxDelayDuration?0:actionRef<MinWaitPollInterval?MinWaitPollInterval:actionRef}return 0}function getWaitPollInterval(actionRef){if(null!==actionRef.Definition&&"object"==typeof actionRef.Definition){var actionRef=actionRef.Definition.PollInterval;if("number"==typeof actionRef&&0<actionRef)return(actionRef=actionRef/1e6)<MinWaitPollInterval?MinWaitPollInterval:actionRef}return DefaultWaitPollInterval}function getHttpRejectActionStatusCode(actionRef){if(null!==actionRef.Definition&&"object"==typeof actionRef.Definition){var actionRef=actionRef.Definition,httpReject=actionRef.HttpReject;if(null!==httpReject&&"object"==typeof httpReject&&null!==httpReject.http_rc)try{return"number"==typeof httpReject.http_rc?httpReject.http_rc:Number(httpReject.http_rc)}catch(e){dedupReportError("actions:HTTP_REJECT_PARSE_CODE","failed to parse http status code",e)}else if(null!=actionRef[superconsts.RejectAttribute.HttpRc])return"number"==typeof actionRef[superconsts.RejectAttribute.HttpRc]?actionRef[superconsts.RejectAttribute.HttpRc]:Number(actionRef[superconsts.RejectAttribute.HttpRc])}return DefaultHttpRejectActionStatusCode}function getMysqlRejectActionResult(actionRef){if(null===actionRef.Definition||"object"!=typeof actionRef.Definition)return DefaultMysqlRejectActionResult;{var actionRef=actionRef.Definition,sqlReject=actionRef.SqlReject;let errno=1317,sqlMessage="Query execution was interrupted [SuperTenant throttling]",sqlState="70100";if(null!==sqlReject&&"object"==typeof sqlReject){if(null!==sqlReject.sql_rc&&void 0!==sqlReject.sql_rc)try{errno="number"==typeof sqlReject.sql_rc?sqlReject.sql_rc:Number(sqlReject.sql_rc)}catch(e){return dedupReportError("actions:SQL_REJECT_PARSE_ERRNO","failed to parse sql errno",e),DefaultMysqlRejectActionResult}sqlMessage=sqlReject.error_message||"Query execution was interrupted [SuperTenant throttling]",sqlState=sqlReject.sql_state||"70100"}else if(null!=actionRef[superconsts.RejectAttribute.SqlRc])try{errno="number"==typeof actionRef[superconsts.RejectAttribute.SqlRc]?actionRef[superconsts.RejectAttribute.SqlRc]:Number(actionRef[superconsts.RejectAttribute.SqlRc]),sqlMessage=actionRef[superconsts.RejectAttribute.ErrorMessage]||"Query execution was interrupted [SuperTenant throttling]",sqlState=actionRef[superconsts.RejectAttribute.SqlState]||"70100"}catch(e){return dedupReportError("actions:SQL_REJECT_PARSE_ERRNO","failed to parse sql errno",e),DefaultMysqlRejectActionResult}return{errno:errno,sqlMessage:sqlMessage,sqlState:sqlState}}}function getMongodbRejectActionResult(actionRef){if(null===actionRef.Definition||"object"!=typeof actionRef.Definition)return DefaultMongodbRejectActionResult;{var actionRef=actionRef.Definition,mongodbReject=actionRef.MongodbReject;let code=11601,errorMessage="SuperTenant throttled operation";if(null!==mongodbReject&&"object"==typeof mongodbReject){if(null!==mongodbReject.code&&void 0!==mongodbReject.code){try{code="number"==typeof mongodbReject.code?mongodbReject.code:Number(mongodbReject.code)}catch(e){return dedupReportError("actions:MONGODB_REJECT_PARSE_ERRNO","failed to parse mongodb error code",e),DefaultMongodbRejectActionResult}errorMessage=mongodbReject.error_message||"SuperTenant throttled operation"}}else if(null!=actionRef[superconsts.RejectAttribute.Code])try{code="number"==typeof actionRef[superconsts.RejectAttribute.Code]?actionRef[superconsts.RejectAttribute.Code]:Number(actionRef[superconsts.RejectAttribute.Code]),errorMessage=actionRef[superconsts.RejectAttribute.ErrorMessage]||"SuperTenant throttled operation"}catch(e){return dedupReportError("actions:MONGODB_REJECT_PARSE_ERRNO","failed to parse mongodb error code",e),DefaultMongodbRejectActionResult}return{code:code,error_message:errorMessage}}}module.exports={getDelayDuration:getDelayDuration,getWaitPollInterval:getWaitPollInterval,getHttpRejectActionStatusCode:getHttpRejectActionStatusCode,getMysqlRejectActionResult:getMysqlRejectActionResult,getMongodbRejectActionResult:getMongodbRejectActionResult};