@cloudbase/manager-node 4.1.3 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/constant.js CHANGED
@@ -4,7 +4,7 @@
4
4
  // static credentail = 'credential'
5
5
  // }
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.COS_SDK_PROTOCOL = exports.USE_INTERNAL_ENDPOINT = exports.SCF_STATUS = exports.ROLE_NAME = exports.PUBLIC_RSA_KEY = exports.ERROR = exports.SERVICE_TYPE = exports.ENDPOINT = exports.RUN_ENV = exports.SDK_VERSION = exports.ENV_NAME = void 0;
7
+ exports.COS_SDK_KEEPALIVE = exports.COS_SDK_PROTOCOL = exports.USE_INTERNAL_ENDPOINT = exports.SCF_STATUS = exports.ROLE_NAME = exports.PUBLIC_RSA_KEY = exports.ERROR = exports.SERVICE_TYPE = exports.ENDPOINT = exports.RUN_ENV = exports.SDK_VERSION = exports.ENV_NAME = void 0;
8
8
  exports.ENV_NAME = {
9
9
  ENV_SECRETID: 'TENCENTCLOUD_SECRETID',
10
10
  ENV_SECRETKEY: 'TENCENTCLOUD_SECRETKEY',
@@ -52,3 +52,4 @@ exports.SCF_STATUS = {
52
52
  // 是否使用内网域名
53
53
  exports.USE_INTERNAL_ENDPOINT = "USE_INTERNAL_ENDPOINT" in process.env;
54
54
  exports.COS_SDK_PROTOCOL = process.env.COS_SDK_PROTOCOL;
55
+ exports.COS_SDK_KEEPALIVE = process.env.COS_SDK_KEEPALIVE;
@@ -20,6 +20,7 @@ const cos_nodejs_sdk_v5_1 = __importDefault(require("cos-nodejs-sdk-v5"));
20
20
  const utils_1 = require("../utils");
21
21
  const error_1 = require("../error");
22
22
  const parallel_1 = require("../utils/parallel");
23
+ const runenv_1 = require("../utils/runenv");
23
24
  const constant_1 = require("../constant");
24
25
  const BIG_FILE_SIZE = 5242880; // 5MB 1024*1024*5
25
26
  class StorageService {
@@ -853,6 +854,13 @@ class StorageService {
853
854
  ? constant_1.COS_SDK_PROTOCOL.toLowerCase()
854
855
  : constant_1.COS_SDK_PROTOCOL.toLowerCase() + ':';
855
856
  }
857
+ // COSSDK 默认开启 KeepAlive,这里提供关闭的方式
858
+ if (constant_1.COS_SDK_KEEPALIVE) {
859
+ cosConfig.KeepAlive = { true: true, false: false }[constant_1.COS_SDK_KEEPALIVE];
860
+ }
861
+ else if (runenv_1.checkIsInScf()) {
862
+ cosConfig.KeepAlive = false;
863
+ }
856
864
  return new cos_nodejs_sdk_v5_1.default(cosConfig);
857
865
  }
858
866
  /**
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkIsInScf = void 0;
4
+ function checkIsInScf() {
5
+ // TENCENTCLOUD_RUNENV
6
+ return process.env.TENCENTCLOUD_RUNENV === 'SCF';
7
+ }
8
+ exports.checkIsInScf = checkIsInScf;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/manager-node",
3
- "version": "4.1.3",
3
+ "version": "4.2.0",
4
4
  "description": "The node manage service api for cloudbase.",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -41,3 +41,4 @@ export declare const enum COS_ENDPOINT {
41
41
  PUBLIC = "{Bucket}.cos.{Region}.tencentcos.cn"
42
42
  }
43
43
  export declare const COS_SDK_PROTOCOL: string;
44
+ export declare const COS_SDK_KEEPALIVE: string;
@@ -0,0 +1 @@
1
+ export declare function checkIsInScf(): boolean;
@@ -1,3 +0,0 @@
1
- {
2
- "typescript.tsdk": "node_modules\\typescript\\lib"
3
- }