ali-skills 0.0.21 → 0.0.22
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/node_modules/@ali/cli-skills/dist/cli.mjs +1214 -287
- package/node_modules/@ali/cli-skills/package.json +5 -2
- package/node_modules/@ali/o2-open-client/.editorconfig +11 -0
- package/node_modules/@ali/o2-open-client/README.md +80 -0
- package/node_modules/@ali/o2-open-client/abc.json +8 -0
- package/node_modules/@ali/o2-open-client/es/browser/ee.d.ts +23 -0
- package/node_modules/@ali/o2-open-client/es/browser/ee.js +82 -0
- package/node_modules/@ali/o2-open-client/es/browser/entry.d.ts +32 -0
- package/node_modules/@ali/o2-open-client/es/browser/entry.js +306 -0
- package/node_modules/@ali/o2-open-client/es/browser/escape.d.ts +12 -0
- package/node_modules/@ali/o2-open-client/es/browser/escape.js +178 -0
- package/node_modules/@ali/o2-open-client/es/browser/fetch.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/browser/fetch.js +14 -0
- package/node_modules/@ali/o2-open-client/es/browser/index.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/browser/index.js +1 -0
- package/node_modules/@ali/o2-open-client/es/common/constant.d.ts +42 -0
- package/node_modules/@ali/o2-open-client/es/common/constant.js +53 -0
- package/node_modules/@ali/o2-open-client/es/common/format.d.ts +14 -0
- package/node_modules/@ali/o2-open-client/es/common/format.js +43 -0
- package/node_modules/@ali/o2-open-client/es/common/service-meta.d.ts +33 -0
- package/node_modules/@ali/o2-open-client/es/common/service-meta.js +33 -0
- package/node_modules/@ali/o2-open-client/es/index.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/index.js +8 -0
- package/node_modules/@ali/o2-open-client/es/node/config.d.ts +47 -0
- package/node_modules/@ali/o2-open-client/es/node/config.js +188 -0
- package/node_modules/@ali/o2-open-client/es/node/escape.d.ts +22 -0
- package/node_modules/@ali/o2-open-client/es/node/escape.js +131 -0
- package/node_modules/@ali/o2-open-client/es/node/help.d.ts +10 -0
- package/node_modules/@ali/o2-open-client/es/node/help.js +96 -0
- package/node_modules/@ali/o2-open-client/es/node/index.d.ts +48 -0
- package/node_modules/@ali/o2-open-client/es/node/index.js +247 -0
- package/node_modules/@ali/o2-open-client/es/node/token-handler.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/es/node/token-handler.js +21 -0
- package/node_modules/@ali/o2-open-client/lib/browser/ee.d.ts +23 -0
- package/node_modules/@ali/o2-open-client/lib/browser/ee.js +86 -0
- package/node_modules/@ali/o2-open-client/lib/browser/entry.d.ts +32 -0
- package/node_modules/@ali/o2-open-client/lib/browser/entry.js +310 -0
- package/node_modules/@ali/o2-open-client/lib/browser/escape.d.ts +12 -0
- package/node_modules/@ali/o2-open-client/lib/browser/escape.js +185 -0
- package/node_modules/@ali/o2-open-client/lib/browser/fetch.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/lib/browser/fetch.js +18 -0
- package/node_modules/@ali/o2-open-client/lib/common/constant.d.ts +42 -0
- package/node_modules/@ali/o2-open-client/lib/common/constant.js +56 -0
- package/node_modules/@ali/o2-open-client/lib/common/format.d.ts +14 -0
- package/node_modules/@ali/o2-open-client/lib/common/format.js +48 -0
- package/node_modules/@ali/o2-open-client/lib/common/service-meta.d.ts +33 -0
- package/node_modules/@ali/o2-open-client/lib/common/service-meta.js +36 -0
- package/node_modules/@ali/o2-open-client/lib/index.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/lib/index.js +20 -0
- package/node_modules/@ali/o2-open-client/lib/node/config.d.ts +47 -0
- package/node_modules/@ali/o2-open-client/lib/node/config.js +192 -0
- package/node_modules/@ali/o2-open-client/lib/node/escape.d.ts +22 -0
- package/node_modules/@ali/o2-open-client/lib/node/escape.js +137 -0
- package/node_modules/@ali/o2-open-client/lib/node/help.d.ts +10 -0
- package/node_modules/@ali/o2-open-client/lib/node/help.js +100 -0
- package/node_modules/@ali/o2-open-client/lib/node/index.d.ts +48 -0
- package/node_modules/@ali/o2-open-client/lib/node/index.js +250 -0
- package/node_modules/@ali/o2-open-client/lib/node/token-handler.d.ts +1 -0
- package/node_modules/@ali/o2-open-client/lib/node/token-handler.js +25 -0
- package/node_modules/@ali/o2-open-client/package.json +46 -0
- package/node_modules/@ali/o2-open-client/playwright.config.ts +54 -0
- package/node_modules/@ali/o2-open-client/tsconfig.es.json +31 -0
- package/node_modules/@ali/o2-open-client/tsconfig.json +31 -0
- package/node_modules/@ali/o2-open-client/tsx2doc.config.js +5 -0
- package/node_modules/@ali/o2-open-client/typings/index.d.ts +36 -0
- package/node_modules/@types/node/LICENSE +21 -0
- package/node_modules/@types/node/README.md +15 -0
- package/node_modules/@types/node/assert/strict.d.ts +8 -0
- package/node_modules/@types/node/assert.d.ts +1062 -0
- package/node_modules/@types/node/async_hooks.d.ts +605 -0
- package/node_modules/@types/node/buffer.buffer.d.ts +471 -0
- package/node_modules/@types/node/buffer.d.ts +1936 -0
- package/node_modules/@types/node/child_process.d.ts +1475 -0
- package/node_modules/@types/node/cluster.d.ts +577 -0
- package/node_modules/@types/node/compatibility/disposable.d.ts +16 -0
- package/node_modules/@types/node/compatibility/index.d.ts +9 -0
- package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
- package/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
- package/node_modules/@types/node/console.d.ts +452 -0
- package/node_modules/@types/node/constants.d.ts +21 -0
- package/node_modules/@types/node/crypto.d.ts +4590 -0
- package/node_modules/@types/node/dgram.d.ts +597 -0
- package/node_modules/@types/node/diagnostics_channel.d.ts +578 -0
- package/node_modules/@types/node/dns/promises.d.ts +479 -0
- package/node_modules/@types/node/dns.d.ts +871 -0
- package/node_modules/@types/node/domain.d.ts +170 -0
- package/node_modules/@types/node/events.d.ts +977 -0
- package/node_modules/@types/node/fs/promises.d.ts +1270 -0
- package/node_modules/@types/node/fs.d.ts +4375 -0
- package/node_modules/@types/node/globals.d.ts +172 -0
- package/node_modules/@types/node/globals.typedarray.d.ts +38 -0
- package/node_modules/@types/node/http.d.ts +2049 -0
- package/node_modules/@types/node/http2.d.ts +2631 -0
- package/node_modules/@types/node/https.d.ts +578 -0
- package/node_modules/@types/node/index.d.ts +93 -0
- package/node_modules/@types/node/inspector.generated.d.ts +3966 -0
- package/node_modules/@types/node/module.d.ts +539 -0
- package/node_modules/@types/node/net.d.ts +1031 -0
- package/node_modules/@types/node/os.d.ts +506 -0
- package/node_modules/@types/node/package.json +140 -0
- package/node_modules/@types/node/path.d.ts +200 -0
- package/node_modules/@types/node/perf_hooks.d.ts +961 -0
- package/node_modules/@types/node/process.d.ts +1961 -0
- package/node_modules/@types/node/punycode.d.ts +117 -0
- package/node_modules/@types/node/querystring.d.ts +152 -0
- package/node_modules/@types/node/readline/promises.d.ts +162 -0
- package/node_modules/@types/node/readline.d.ts +589 -0
- package/node_modules/@types/node/repl.d.ts +430 -0
- package/node_modules/@types/node/sea.d.ts +153 -0
- package/node_modules/@types/node/stream/consumers.d.ts +38 -0
- package/node_modules/@types/node/stream/promises.d.ts +90 -0
- package/node_modules/@types/node/stream/web.d.ts +533 -0
- package/node_modules/@types/node/stream.d.ts +1698 -0
- package/node_modules/@types/node/string_decoder.d.ts +67 -0
- package/node_modules/@types/node/test.d.ts +1787 -0
- package/node_modules/@types/node/timers/promises.d.ts +108 -0
- package/node_modules/@types/node/timers.d.ts +286 -0
- package/node_modules/@types/node/tls.d.ts +1259 -0
- package/node_modules/@types/node/trace_events.d.ts +197 -0
- package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +468 -0
- package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +34 -0
- package/node_modules/@types/node/ts5.6/index.d.ts +93 -0
- package/node_modules/@types/node/tty.d.ts +208 -0
- package/node_modules/@types/node/url.d.ts +964 -0
- package/node_modules/@types/node/util.d.ts +2331 -0
- package/node_modules/@types/node/v8.d.ts +809 -0
- package/node_modules/@types/node/vm.d.ts +1001 -0
- package/node_modules/@types/node/wasi.d.ts +181 -0
- package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
- package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
- package/node_modules/@types/node/web-globals/events.d.ts +97 -0
- package/node_modules/@types/node/web-globals/fetch.d.ts +55 -0
- package/node_modules/@types/node/worker_threads.d.ts +715 -0
- package/node_modules/@types/node/zlib.d.ts +598 -0
- package/node_modules/ansi-styles/index.d.ts +345 -0
- package/node_modules/ansi-styles/index.js +163 -0
- package/node_modules/ansi-styles/license +9 -0
- package/node_modules/ansi-styles/package.json +56 -0
- package/node_modules/ansi-styles/readme.md +152 -0
- package/node_modules/await-event/LICENSE +22 -0
- package/node_modules/await-event/README.md +48 -0
- package/node_modules/await-event/index.js +13 -0
- package/node_modules/await-event/package.json +33 -0
- package/node_modules/await-first/LICENSE +21 -0
- package/node_modules/await-first/README.md +80 -0
- package/node_modules/await-first/lib/index.js +21 -0
- package/node_modules/await-first/package.json +49 -0
- package/node_modules/byte/LICENSE.txt +21 -0
- package/node_modules/byte/README.md +207 -0
- package/node_modules/byte/lib/byte.js +635 -0
- package/node_modules/byte/lib/number.js +82 -0
- package/node_modules/byte/package.json +61 -0
- package/node_modules/chalk/index.d.ts +415 -0
- package/node_modules/chalk/license +9 -0
- package/node_modules/chalk/package.json +68 -0
- package/node_modules/chalk/readme.md +341 -0
- package/node_modules/chalk/source/index.js +229 -0
- package/node_modules/chalk/source/templates.js +134 -0
- package/node_modules/chalk/source/util.js +39 -0
- package/node_modules/circular-json-for-egg/LICENSE.txt +19 -0
- package/node_modules/circular-json-for-egg/README.md +148 -0
- package/node_modules/circular-json-for-egg/build/circular-json.amd.js +2 -0
- package/node_modules/circular-json-for-egg/build/circular-json.js +2 -0
- package/node_modules/circular-json-for-egg/build/circular-json.max.amd.js +210 -0
- package/node_modules/circular-json-for-egg/build/circular-json.max.js +210 -0
- package/node_modules/circular-json-for-egg/build/circular-json.node.js +207 -0
- package/node_modules/circular-json-for-egg/package.json +42 -0
- package/node_modules/cluster-client/LICENSE +21 -0
- package/node_modules/cluster-client/README.md +319 -0
- package/node_modules/cluster-client/index.js +66 -0
- package/node_modules/cluster-client/lib/api_client.js +74 -0
- package/node_modules/cluster-client/lib/connection.js +180 -0
- package/node_modules/cluster-client/lib/const.js +5 -0
- package/node_modules/cluster-client/lib/default_logger.js +11 -0
- package/node_modules/cluster-client/lib/default_transcode.js +6 -0
- package/node_modules/cluster-client/lib/follower.js +331 -0
- package/node_modules/cluster-client/lib/index.js +213 -0
- package/node_modules/cluster-client/lib/leader.js +437 -0
- package/node_modules/cluster-client/lib/protocol/byte_buffer.js +8 -0
- package/node_modules/cluster-client/lib/protocol/packet.js +103 -0
- package/node_modules/cluster-client/lib/protocol/request.js +17 -0
- package/node_modules/cluster-client/lib/protocol/response.js +14 -0
- package/node_modules/cluster-client/lib/server.js +256 -0
- package/node_modules/cluster-client/lib/symbol.js +20 -0
- package/node_modules/cluster-client/lib/utils.js +103 -0
- package/node_modules/cluster-client/lib/wrapper/base.js +210 -0
- package/node_modules/cluster-client/lib/wrapper/cluster.js +57 -0
- package/node_modules/cluster-client/lib/wrapper/single.js +192 -0
- package/node_modules/cluster-client/package.json +60 -0
- package/node_modules/co/LICENSE +22 -0
- package/node_modules/co/Readme.md +212 -0
- package/node_modules/co/index.js +237 -0
- package/node_modules/co/package.json +34 -0
- package/node_modules/color-convert/LICENSE +21 -0
- package/node_modules/color-convert/README.md +68 -0
- package/node_modules/color-convert/conversions.js +839 -0
- package/node_modules/color-convert/index.js +81 -0
- package/node_modules/color-convert/package.json +48 -0
- package/node_modules/color-convert/route.js +97 -0
- package/node_modules/color-name/LICENSE +8 -0
- package/node_modules/color-name/README.md +11 -0
- package/node_modules/color-name/index.js +152 -0
- package/node_modules/color-name/package.json +28 -0
- package/node_modules/core-util-is/LICENSE +19 -0
- package/node_modules/core-util-is/README.md +3 -0
- package/node_modules/core-util-is/lib/util.js +107 -0
- package/node_modules/core-util-is/package.json +38 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +64 -0
- package/node_modules/debug/src/browser.js +272 -0
- package/node_modules/debug/src/common.js +292 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/depd/History.md +103 -0
- package/node_modules/depd/LICENSE +22 -0
- package/node_modules/depd/Readme.md +280 -0
- package/node_modules/depd/index.js +538 -0
- package/node_modules/depd/lib/browser/index.js +77 -0
- package/node_modules/depd/package.json +45 -0
- package/node_modules/ee-first/LICENSE +22 -0
- package/node_modules/ee-first/README.md +80 -0
- package/node_modules/ee-first/index.js +95 -0
- package/node_modules/ee-first/package.json +29 -0
- package/node_modules/egg-errors/LICENSE +21 -0
- package/node_modules/egg-errors/README.md +259 -0
- package/node_modules/egg-errors/lib/base.d.ts +10 -0
- package/node_modules/egg-errors/lib/base.js +28 -0
- package/node_modules/egg-errors/lib/base_error.d.ts +6 -0
- package/node_modules/egg-errors/lib/base_error.js +13 -0
- package/node_modules/egg-errors/lib/base_exception.d.ts +6 -0
- package/node_modules/egg-errors/lib/base_exception.js +13 -0
- package/node_modules/egg-errors/lib/error.d.ts +6 -0
- package/node_modules/egg-errors/lib/error.js +13 -0
- package/node_modules/egg-errors/lib/error_options.d.ts +5 -0
- package/node_modules/egg-errors/lib/error_options.js +6 -0
- package/node_modules/egg-errors/lib/error_type.d.ts +6 -0
- package/node_modules/egg-errors/lib/error_type.js +10 -0
- package/node_modules/egg-errors/lib/exception.d.ts +6 -0
- package/node_modules/egg-errors/lib/exception.js +13 -0
- package/node_modules/egg-errors/lib/framework/formatter.d.ts +6 -0
- package/node_modules/egg-errors/lib/framework/formatter.js +29 -0
- package/node_modules/egg-errors/lib/framework/framework_base_error.d.ts +10 -0
- package/node_modules/egg-errors/lib/framework/framework_base_error.js +32 -0
- package/node_modules/egg-errors/lib/http/400.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/400.js +13 -0
- package/node_modules/egg-errors/lib/http/401.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/401.js +13 -0
- package/node_modules/egg-errors/lib/http/402.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/402.js +13 -0
- package/node_modules/egg-errors/lib/http/403.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/403.js +13 -0
- package/node_modules/egg-errors/lib/http/404.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/404.js +13 -0
- package/node_modules/egg-errors/lib/http/405.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/405.js +13 -0
- package/node_modules/egg-errors/lib/http/406.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/406.js +13 -0
- package/node_modules/egg-errors/lib/http/407.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/407.js +13 -0
- package/node_modules/egg-errors/lib/http/408.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/408.js +13 -0
- package/node_modules/egg-errors/lib/http/409.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/409.js +13 -0
- package/node_modules/egg-errors/lib/http/410.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/410.js +13 -0
- package/node_modules/egg-errors/lib/http/411.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/411.js +13 -0
- package/node_modules/egg-errors/lib/http/412.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/412.js +13 -0
- package/node_modules/egg-errors/lib/http/413.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/413.js +13 -0
- package/node_modules/egg-errors/lib/http/414.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/414.js +13 -0
- package/node_modules/egg-errors/lib/http/415.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/415.js +13 -0
- package/node_modules/egg-errors/lib/http/416.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/416.js +13 -0
- package/node_modules/egg-errors/lib/http/417.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/417.js +13 -0
- package/node_modules/egg-errors/lib/http/418.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/418.js +13 -0
- package/node_modules/egg-errors/lib/http/421.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/421.js +13 -0
- package/node_modules/egg-errors/lib/http/422.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/422.js +13 -0
- package/node_modules/egg-errors/lib/http/423.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/423.js +13 -0
- package/node_modules/egg-errors/lib/http/424.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/424.js +13 -0
- package/node_modules/egg-errors/lib/http/425.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/425.js +13 -0
- package/node_modules/egg-errors/lib/http/426.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/426.js +13 -0
- package/node_modules/egg-errors/lib/http/428.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/428.js +13 -0
- package/node_modules/egg-errors/lib/http/429.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/429.js +13 -0
- package/node_modules/egg-errors/lib/http/431.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/431.js +13 -0
- package/node_modules/egg-errors/lib/http/451.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/451.js +13 -0
- package/node_modules/egg-errors/lib/http/500.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/500.js +13 -0
- package/node_modules/egg-errors/lib/http/501.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/501.js +13 -0
- package/node_modules/egg-errors/lib/http/502.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/502.js +13 -0
- package/node_modules/egg-errors/lib/http/503.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/503.js +13 -0
- package/node_modules/egg-errors/lib/http/504.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/504.js +13 -0
- package/node_modules/egg-errors/lib/http/505.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/505.js +13 -0
- package/node_modules/egg-errors/lib/http/506.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/506.js +13 -0
- package/node_modules/egg-errors/lib/http/507.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/507.js +13 -0
- package/node_modules/egg-errors/lib/http/508.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/508.js +13 -0
- package/node_modules/egg-errors/lib/http/509.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/509.js +13 -0
- package/node_modules/egg-errors/lib/http/510.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/510.js +13 -0
- package/node_modules/egg-errors/lib/http/511.d.ts +5 -0
- package/node_modules/egg-errors/lib/http/511.js +13 -0
- package/node_modules/egg-errors/lib/http/http_error.d.ts +10 -0
- package/node_modules/egg-errors/lib/http/http_error.js +13 -0
- package/node_modules/egg-errors/lib/http/http_error_options.d.ts +6 -0
- package/node_modules/egg-errors/lib/http/http_error_options.js +7 -0
- package/node_modules/egg-errors/lib/http/http_header.d.ts +3 -0
- package/node_modules/egg-errors/lib/http/http_header.js +3 -0
- package/node_modules/egg-errors/lib/index.d.ts +50 -0
- package/node_modules/egg-errors/lib/index.js +149 -0
- package/node_modules/egg-errors/package.json +49 -0
- package/node_modules/egg-logger/LICENSE +21 -0
- package/node_modules/egg-logger/README.md +128 -0
- package/node_modules/egg-logger/README.zh-CN.md +125 -0
- package/node_modules/egg-logger/index.d.ts +233 -0
- package/node_modules/egg-logger/index.js +18 -0
- package/node_modules/egg-logger/lib/egg/console_logger.js +36 -0
- package/node_modules/egg-logger/lib/egg/context_logger.js +43 -0
- package/node_modules/egg-logger/lib/egg/custom_logger.js +10 -0
- package/node_modules/egg-logger/lib/egg/error_logger.js +31 -0
- package/node_modules/egg-logger/lib/egg/logger.js +128 -0
- package/node_modules/egg-logger/lib/egg/loggers.js +163 -0
- package/node_modules/egg-logger/lib/level.js +34 -0
- package/node_modules/egg-logger/lib/logger.js +170 -0
- package/node_modules/egg-logger/lib/transports/console.js +52 -0
- package/node_modules/egg-logger/lib/transports/file.js +134 -0
- package/node_modules/egg-logger/lib/transports/file_buffer.js +113 -0
- package/node_modules/egg-logger/lib/transports/transport.js +129 -0
- package/node_modules/egg-logger/lib/utils.js +296 -0
- package/node_modules/egg-logger/package.json +54 -0
- package/node_modules/escape-html/LICENSE +24 -0
- package/node_modules/escape-html/Readme.md +43 -0
- package/node_modules/escape-html/index.js +78 -0
- package/node_modules/escape-html/package.json +24 -0
- package/node_modules/extend-shallow/LICENSE +21 -0
- package/node_modules/extend-shallow/README.md +61 -0
- package/node_modules/extend-shallow/index.js +33 -0
- package/node_modules/extend-shallow/package.json +56 -0
- package/node_modules/has-flag/index.d.ts +39 -0
- package/node_modules/has-flag/index.js +8 -0
- package/node_modules/has-flag/license +9 -0
- package/node_modules/has-flag/package.json +46 -0
- package/node_modules/has-flag/readme.md +89 -0
- package/node_modules/heartbeats/.eslintrc +151 -0
- package/node_modules/heartbeats/.npmignore +28 -0
- package/node_modules/heartbeats/.travis.yml +10 -0
- package/node_modules/heartbeats/LICENSE +21 -0
- package/node_modules/heartbeats/README.md +323 -0
- package/node_modules/heartbeats/lib/beatevent.js +35 -0
- package/node_modules/heartbeats/lib/heart.js +178 -0
- package/node_modules/heartbeats/lib/pulse.js +39 -0
- package/node_modules/heartbeats/main.js +34 -0
- package/node_modules/heartbeats/package.json +39 -0
- package/node_modules/heartbeats/test/benchmark.js +138 -0
- package/node_modules/heartbeats/test/spawn.js +16 -0
- package/node_modules/heartbeats/test/test.js +158 -0
- package/node_modules/httpx/README.md +96 -0
- package/node_modules/httpx/lib/index.d.ts +31 -0
- package/node_modules/httpx/lib/index.js +396 -0
- package/node_modules/httpx/package.json +36 -0
- package/node_modules/iconv-lite/.github/dependabot.yml +11 -0
- package/node_modules/iconv-lite/.idea/codeStyles/Project.xml +47 -0
- package/node_modules/iconv-lite/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/node_modules/iconv-lite/.idea/iconv-lite.iml +12 -0
- package/node_modules/iconv-lite/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/node_modules/iconv-lite/.idea/modules.xml +8 -0
- package/node_modules/iconv-lite/.idea/vcs.xml +6 -0
- package/node_modules/iconv-lite/Changelog.md +212 -0
- package/node_modules/iconv-lite/LICENSE +21 -0
- package/node_modules/iconv-lite/README.md +130 -0
- package/node_modules/iconv-lite/encodings/dbcs-codec.js +597 -0
- package/node_modules/iconv-lite/encodings/dbcs-data.js +188 -0
- package/node_modules/iconv-lite/encodings/index.js +23 -0
- package/node_modules/iconv-lite/encodings/internal.js +198 -0
- package/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
- package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/node_modules/iconv-lite/encodings/sbcs-data.js +179 -0
- package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
- package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/node_modules/iconv-lite/encodings/utf16.js +197 -0
- package/node_modules/iconv-lite/encodings/utf32.js +319 -0
- package/node_modules/iconv-lite/encodings/utf7.js +290 -0
- package/node_modules/iconv-lite/lib/bom-handling.js +52 -0
- package/node_modules/iconv-lite/lib/index.d.ts +41 -0
- package/node_modules/iconv-lite/lib/index.js +180 -0
- package/node_modules/iconv-lite/lib/streams.js +109 -0
- package/node_modules/iconv-lite/package.json +44 -0
- package/node_modules/ip/README.md +90 -0
- package/node_modules/ip/lib/ip.js +496 -0
- package/node_modules/ip/package.json +25 -0
- package/node_modules/is-class-hotfix/.editorconfig +23 -0
- package/node_modules/is-class-hotfix/.gitattributes +2 -0
- package/node_modules/is-class-hotfix/CHANGELOG.md +7 -0
- package/node_modules/is-class-hotfix/LICENSE.md +21 -0
- package/node_modules/is-class-hotfix/README.md +35 -0
- package/node_modules/is-class-hotfix/bower.json +24 -0
- package/node_modules/is-class-hotfix/is-class.js +28 -0
- package/node_modules/is-class-hotfix/package.json +31 -0
- package/node_modules/is-class-hotfix/test/babel-class.js +27 -0
- package/node_modules/is-class-hotfix/test/is-class.js +31 -0
- package/node_modules/is-extendable/LICENSE +21 -0
- package/node_modules/is-extendable/README.md +72 -0
- package/node_modules/is-extendable/index.js +13 -0
- package/node_modules/is-extendable/package.json +51 -0
- package/node_modules/is-type-of/LICENSE +21 -0
- package/node_modules/is-type-of/README.md +105 -0
- package/node_modules/is-type-of/index.d.ts +65 -0
- package/node_modules/is-type-of/index.js +125 -0
- package/node_modules/is-type-of/package.json +45 -0
- package/node_modules/isstream/.jshintrc +59 -0
- package/node_modules/isstream/.npmignore +1 -0
- package/node_modules/isstream/.travis.yml +12 -0
- package/node_modules/isstream/LICENSE.md +11 -0
- package/node_modules/isstream/README.md +66 -0
- package/node_modules/isstream/isstream.js +27 -0
- package/node_modules/isstream/package.json +33 -0
- package/node_modules/isstream/test.js +168 -0
- package/node_modules/json-stringify-safe/.npmignore +1 -0
- package/node_modules/json-stringify-safe/CHANGELOG.md +14 -0
- package/node_modules/json-stringify-safe/LICENSE +15 -0
- package/node_modules/json-stringify-safe/Makefile +35 -0
- package/node_modules/json-stringify-safe/README.md +52 -0
- package/node_modules/json-stringify-safe/package.json +31 -0
- package/node_modules/json-stringify-safe/stringify.js +27 -0
- package/node_modules/json-stringify-safe/test/mocha.opts +2 -0
- package/node_modules/json-stringify-safe/test/stringify_test.js +246 -0
- package/node_modules/kitx/LICENSE +21 -0
- package/node_modules/kitx/README.md +35 -0
- package/node_modules/kitx/lib/index.d.ts +45 -0
- package/node_modules/kitx/lib/index.js +289 -0
- package/node_modules/kitx/package.json +41 -0
- package/node_modules/long/LICENSE +202 -0
- package/node_modules/long/README.md +246 -0
- package/node_modules/long/dist/long.js +2 -0
- package/node_modules/long/dist/long.js.map +1 -0
- package/node_modules/long/index.js +1 -0
- package/node_modules/long/package.json +34 -0
- package/node_modules/long/src/long.js +1323 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/node_modules/p-timeout/index.d.ts +113 -0
- package/node_modules/p-timeout/index.js +71 -0
- package/node_modules/p-timeout/license +9 -0
- package/node_modules/p-timeout/package.json +44 -0
- package/node_modules/p-timeout/readme.md +117 -0
- package/node_modules/safer-buffer/LICENSE +21 -0
- package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/node_modules/safer-buffer/Readme.md +156 -0
- package/node_modules/safer-buffer/dangerous.js +58 -0
- package/node_modules/safer-buffer/package.json +34 -0
- package/node_modules/safer-buffer/safer.js +77 -0
- package/node_modules/safer-buffer/tests.js +406 -0
- package/node_modules/sdk-base/LICENSE +21 -0
- package/node_modules/sdk-base/README.md +165 -0
- package/node_modules/sdk-base/index.d.ts +29 -0
- package/node_modules/sdk-base/index.js +251 -0
- package/node_modules/sdk-base/package.json +54 -0
- package/node_modules/serialize-json/LICENSE +21 -0
- package/node_modules/serialize-json/README.md +74 -0
- package/node_modules/serialize-json/lib/decoder.js +190 -0
- package/node_modules/serialize-json/lib/encoder.js +200 -0
- package/node_modules/serialize-json/lib/index.js +15 -0
- package/node_modules/serialize-json/package.json +53 -0
- package/node_modules/supports-color/browser.js +5 -0
- package/node_modules/supports-color/index.js +135 -0
- package/node_modules/supports-color/license +9 -0
- package/node_modules/supports-color/package.json +53 -0
- package/node_modules/supports-color/readme.md +76 -0
- package/node_modules/tcp-base/LICENSE +21 -0
- package/node_modules/tcp-base/README.md +134 -0
- package/node_modules/tcp-base/lib/base.js +456 -0
- package/node_modules/tcp-base/package.json +44 -0
- package/node_modules/undici-types/LICENSE +21 -0
- package/node_modules/undici-types/README.md +6 -0
- package/node_modules/undici-types/agent.d.ts +31 -0
- package/node_modules/undici-types/api.d.ts +43 -0
- package/node_modules/undici-types/balanced-pool.d.ts +29 -0
- package/node_modules/undici-types/cache.d.ts +36 -0
- package/node_modules/undici-types/client.d.ts +108 -0
- package/node_modules/undici-types/connector.d.ts +34 -0
- package/node_modules/undici-types/content-type.d.ts +21 -0
- package/node_modules/undici-types/cookies.d.ts +28 -0
- package/node_modules/undici-types/diagnostics-channel.d.ts +66 -0
- package/node_modules/undici-types/dispatcher.d.ts +256 -0
- package/node_modules/undici-types/env-http-proxy-agent.d.ts +21 -0
- package/node_modules/undici-types/errors.d.ts +149 -0
- package/node_modules/undici-types/eventsource.d.ts +61 -0
- package/node_modules/undici-types/fetch.d.ts +209 -0
- package/node_modules/undici-types/file.d.ts +39 -0
- package/node_modules/undici-types/filereader.d.ts +54 -0
- package/node_modules/undici-types/formdata.d.ts +108 -0
- package/node_modules/undici-types/global-dispatcher.d.ts +9 -0
- package/node_modules/undici-types/global-origin.d.ts +7 -0
- package/node_modules/undici-types/handlers.d.ts +15 -0
- package/node_modules/undici-types/header.d.ts +4 -0
- package/node_modules/undici-types/index.d.ts +71 -0
- package/node_modules/undici-types/interceptors.d.ts +17 -0
- package/node_modules/undici-types/mock-agent.d.ts +50 -0
- package/node_modules/undici-types/mock-client.d.ts +25 -0
- package/node_modules/undici-types/mock-errors.d.ts +12 -0
- package/node_modules/undici-types/mock-interceptor.d.ts +93 -0
- package/node_modules/undici-types/mock-pool.d.ts +25 -0
- package/node_modules/undici-types/package.json +55 -0
- package/node_modules/undici-types/patch.d.ts +33 -0
- package/node_modules/undici-types/pool-stats.d.ts +19 -0
- package/node_modules/undici-types/pool.d.ts +39 -0
- package/node_modules/undici-types/proxy-agent.d.ts +28 -0
- package/node_modules/undici-types/readable.d.ts +65 -0
- package/node_modules/undici-types/retry-agent.d.ts +8 -0
- package/node_modules/undici-types/retry-handler.d.ts +116 -0
- package/node_modules/undici-types/util.d.ts +18 -0
- package/node_modules/undici-types/webidl.d.ts +228 -0
- package/node_modules/undici-types/websocket.d.ts +150 -0
- package/node_modules/unescape/LICENSE +21 -0
- package/node_modules/unescape/README.md +134 -0
- package/node_modules/unescape/index.js +103 -0
- package/node_modules/unescape/package.json +67 -0
- package/node_modules/utility/LICENSE.txt +21 -0
- package/node_modules/utility/README.md +370 -0
- package/node_modules/utility/dist/commonjs/array.d.ts +11 -0
- package/node_modules/utility/dist/commonjs/array.js +46 -0
- package/node_modules/utility/dist/commonjs/crypto.d.ts +86 -0
- package/node_modules/utility/dist/commonjs/crypto.js +159 -0
- package/node_modules/utility/dist/commonjs/date.d.ts +63 -0
- package/node_modules/utility/dist/commonjs/date.js +219 -0
- package/node_modules/utility/dist/commonjs/fs.d.ts +6 -0
- package/node_modules/utility/dist/commonjs/fs.js +20 -0
- package/node_modules/utility/dist/commonjs/function.d.ts +12 -0
- package/node_modules/utility/dist/commonjs/function.js +35 -0
- package/node_modules/utility/dist/commonjs/index.d.ts +12 -0
- package/node_modules/utility/dist/commonjs/index.js +29 -0
- package/node_modules/utility/dist/commonjs/json.d.ts +14 -0
- package/node_modules/utility/dist/commonjs/json.js +41 -0
- package/node_modules/utility/dist/commonjs/number.d.ts +24 -0
- package/node_modules/utility/dist/commonjs/number.js +66 -0
- package/node_modules/utility/dist/commonjs/object.d.ts +20 -0
- package/node_modules/utility/dist/commonjs/object.js +73 -0
- package/node_modules/utility/dist/commonjs/optimize.d.ts +21 -0
- package/node_modules/utility/dist/commonjs/optimize.js +60 -0
- package/node_modules/utility/dist/commonjs/package.json +3 -0
- package/node_modules/utility/dist/commonjs/string.d.ts +29 -0
- package/node_modules/utility/dist/commonjs/string.js +126 -0
- package/node_modules/utility/dist/commonjs/timeout.d.ts +6 -0
- package/node_modules/utility/dist/commonjs/timeout.js +34 -0
- package/node_modules/utility/dist/commonjs/web.d.ts +29 -0
- package/node_modules/utility/dist/commonjs/web.js +61 -0
- package/node_modules/utility/dist/esm/array.d.ts +11 -0
- package/node_modules/utility/dist/esm/array.js +42 -0
- package/node_modules/utility/dist/esm/crypto.d.ts +86 -0
- package/node_modules/utility/dist/esm/crypto.js +146 -0
- package/node_modules/utility/dist/esm/date.d.ts +63 -0
- package/node_modules/utility/dist/esm/date.js +204 -0
- package/node_modules/utility/dist/esm/fs.d.ts +6 -0
- package/node_modules/utility/dist/esm/fs.js +17 -0
- package/node_modules/utility/dist/esm/function.d.ts +12 -0
- package/node_modules/utility/dist/esm/function.js +28 -0
- package/node_modules/utility/dist/esm/index.d.ts +12 -0
- package/node_modules/utility/dist/esm/index.js +13 -0
- package/node_modules/utility/dist/esm/json.d.ts +14 -0
- package/node_modules/utility/dist/esm/json.js +34 -0
- package/node_modules/utility/dist/esm/number.d.ts +24 -0
- package/node_modules/utility/dist/esm/number.js +60 -0
- package/node_modules/utility/dist/esm/object.d.ts +20 -0
- package/node_modules/utility/dist/esm/object.js +67 -0
- package/node_modules/utility/dist/esm/optimize.d.ts +21 -0
- package/node_modules/utility/dist/esm/optimize.js +54 -0
- package/node_modules/utility/dist/esm/package.json +3 -0
- package/node_modules/utility/dist/esm/string.d.ts +29 -0
- package/node_modules/utility/dist/esm/string.js +118 -0
- package/node_modules/utility/dist/esm/timeout.d.ts +6 -0
- package/node_modules/utility/dist/esm/timeout.js +28 -0
- package/node_modules/utility/dist/esm/web.d.ts +29 -0
- package/node_modules/utility/dist/esm/web.js +52 -0
- package/node_modules/utility/dist/package.json +4 -0
- package/node_modules/utility/package.json +85 -0
- package/node_modules/utility/src/array.ts +44 -0
- package/node_modules/utility/src/crypto.ts +160 -0
- package/node_modules/utility/src/date.ts +232 -0
- package/node_modules/utility/src/fs.ts +17 -0
- package/node_modules/utility/src/function.ts +30 -0
- package/node_modules/utility/src/index.ts +12 -0
- package/node_modules/utility/src/json.ts +48 -0
- package/node_modules/utility/src/number.ts +63 -0
- package/node_modules/utility/src/object.ts +72 -0
- package/node_modules/utility/src/optimize.ts +62 -0
- package/node_modules/utility/src/string.ts +132 -0
- package/node_modules/utility/src/timeout.ts +37 -0
- package/node_modules/utility/src/web.ts +53 -0
- package/node_modules/ylru/LICENSE +25 -0
- package/node_modules/ylru/README.md +120 -0
- package/node_modules/ylru/dist/commonjs/index.d.ts +21 -0
- package/node_modules/ylru/dist/commonjs/index.js +112 -0
- package/node_modules/ylru/dist/commonjs/package.json +3 -0
- package/node_modules/ylru/dist/esm/index.d.ts +21 -0
- package/node_modules/ylru/dist/esm/index.js +108 -0
- package/node_modules/ylru/dist/esm/package.json +3 -0
- package/node_modules/ylru/package.json +71 -0
- package/node_modules/ylru/src/index.ts +124 -0
- package/package.json +2 -2
- package/node_modules/@ali/cli-skills/dist/_chunks/libs/abort-controller.mjs +0 -424
- package/node_modules/@ali/cli-skills/dist/_chunks/libs/archiver.mjs +0 -19586
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const is = require('is-type-of');
|
|
4
|
+
const symbols = require('./symbol');
|
|
5
|
+
const logger = require('./default_logger');
|
|
6
|
+
const transcode = require('./default_transcode');
|
|
7
|
+
const SingleClient = require('./wrapper/single');
|
|
8
|
+
const ClusterClient = require('./wrapper/cluster');
|
|
9
|
+
const { formatKey } = require('./utils');
|
|
10
|
+
|
|
11
|
+
const defaultOptions = {
|
|
12
|
+
port: parseInt(process.env.NODE_CLUSTER_CLIENT_PORT) || 7777,
|
|
13
|
+
singleMode: process.env.NODE_CLUSTER_CLIENT_SINGLE_MODE === '1',
|
|
14
|
+
maxWaitTime: 30000,
|
|
15
|
+
connectTimeout: parseInt(process.env.NODE_CLUSTER_CLIENT_CONNECT_TIMEOUT) || 10000,
|
|
16
|
+
responseTimeout: 3000,
|
|
17
|
+
heartbeatInterval: 20000,
|
|
18
|
+
isCheckHeartbeat: true,
|
|
19
|
+
autoGenerate: true,
|
|
20
|
+
isBroadcast: true,
|
|
21
|
+
logger,
|
|
22
|
+
transcode,
|
|
23
|
+
formatKey,
|
|
24
|
+
};
|
|
25
|
+
const autoGenerateMethods = [
|
|
26
|
+
'subscribe',
|
|
27
|
+
'unSubscribe',
|
|
28
|
+
'publish',
|
|
29
|
+
'close',
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
class ClientGenerator {
|
|
33
|
+
/**
|
|
34
|
+
* Cluster Client Generator
|
|
35
|
+
*
|
|
36
|
+
* @param {Function} clientClass - the client class
|
|
37
|
+
* @param {Object} options
|
|
38
|
+
* - {Number} responseTimeout - response timeout, default is 3000
|
|
39
|
+
* - {Boolean} autoGenerate - whether generate delegate rule automatically, default is true
|
|
40
|
+
* - {Boolean} isBroadcast - whether broadcast subscrption result to all followers or just one, default is true
|
|
41
|
+
* - {Logger} logger - log instance
|
|
42
|
+
* - {Transcode} [transcode|JSON.stringify/parse]
|
|
43
|
+
* - {Function} encode - custom serialize method
|
|
44
|
+
* - {Function} decode - custom deserialize method
|
|
45
|
+
* - {Boolean} [isLeader|null] - specify whether current instance is leader
|
|
46
|
+
* - {Number} [maxWaitTime|30000] - leader startup max time (ONLY effective on isLeader is true)
|
|
47
|
+
* @class
|
|
48
|
+
*/
|
|
49
|
+
constructor(clientClass, options) {
|
|
50
|
+
this._clientClass = clientClass;
|
|
51
|
+
this._options = Object.assign({
|
|
52
|
+
name: clientClass.prototype.constructor.name,
|
|
53
|
+
}, defaultOptions, options);
|
|
54
|
+
|
|
55
|
+
// wrapper descptions
|
|
56
|
+
this._descriptors = new Map();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* override the property
|
|
61
|
+
*
|
|
62
|
+
* @param {String} name - property name
|
|
63
|
+
* @param {Object} value - property value
|
|
64
|
+
* @return {ClientGenerator} self
|
|
65
|
+
*/
|
|
66
|
+
override(name, value) {
|
|
67
|
+
this._descriptors.set(name, {
|
|
68
|
+
type: 'override',
|
|
69
|
+
value,
|
|
70
|
+
});
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* delegate methods
|
|
76
|
+
*
|
|
77
|
+
* @param {String} from - method name
|
|
78
|
+
* @param {String} to - delegate to subscribe|publish|invoke
|
|
79
|
+
* @return {ClientGenerator} self
|
|
80
|
+
*/
|
|
81
|
+
delegate(from, to) {
|
|
82
|
+
to = to || 'invoke';
|
|
83
|
+
this._descriptors.set(from, {
|
|
84
|
+
type: 'delegate',
|
|
85
|
+
to,
|
|
86
|
+
});
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* create cluster client instance
|
|
92
|
+
*
|
|
93
|
+
* @param {...any} args arguments
|
|
94
|
+
* @return {Object} instance
|
|
95
|
+
*/
|
|
96
|
+
create(...args) {
|
|
97
|
+
const clientClass = this._clientClass;
|
|
98
|
+
const proto = clientClass.prototype;
|
|
99
|
+
const descriptors = this._descriptors;
|
|
100
|
+
|
|
101
|
+
// auto generate description
|
|
102
|
+
if (this._options.autoGenerate) {
|
|
103
|
+
this._generateDescriptors();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function createRealClient() {
|
|
107
|
+
return Reflect.construct(clientClass, args);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const ClientWrapper = this._options.singleMode ? SingleClient : ClusterClient;
|
|
111
|
+
const client = new ClientWrapper(Object.assign({
|
|
112
|
+
createRealClient,
|
|
113
|
+
descriptors: this._descriptors,
|
|
114
|
+
}, this._options));
|
|
115
|
+
|
|
116
|
+
for (const name of descriptors.keys()) {
|
|
117
|
+
let value;
|
|
118
|
+
const descriptor = descriptors.get(name);
|
|
119
|
+
switch (descriptor.type) {
|
|
120
|
+
case 'override':
|
|
121
|
+
value = descriptor.value;
|
|
122
|
+
break;
|
|
123
|
+
case 'delegate':
|
|
124
|
+
if (/^invoke|invokeOneway$/.test(descriptor.to)) {
|
|
125
|
+
if (is.generatorFunction(proto[name])) {
|
|
126
|
+
value = function* (...args) {
|
|
127
|
+
return yield cb => { client[symbols.invoke](name, args, cb); };
|
|
128
|
+
};
|
|
129
|
+
} else if (is.function(proto[name])) {
|
|
130
|
+
if (descriptor.to === 'invoke') {
|
|
131
|
+
value = (...args) => {
|
|
132
|
+
let cb;
|
|
133
|
+
if (is.function(args[args.length - 1])) {
|
|
134
|
+
cb = args.pop();
|
|
135
|
+
}
|
|
136
|
+
// whether callback or promise
|
|
137
|
+
if (cb) {
|
|
138
|
+
client[symbols.invoke](name, args, cb);
|
|
139
|
+
} else {
|
|
140
|
+
return new Promise((resolve, reject) => {
|
|
141
|
+
client[symbols.invoke](name, args, function(err) {
|
|
142
|
+
if (err) {
|
|
143
|
+
reject(err);
|
|
144
|
+
} else {
|
|
145
|
+
resolve.apply(null, Array.from(arguments).slice(1));
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
} else {
|
|
152
|
+
value = (...args) => {
|
|
153
|
+
client[symbols.invoke](name, args);
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
throw new Error(`[ClusterClient] api: ${name} not implement in client`);
|
|
158
|
+
}
|
|
159
|
+
} else {
|
|
160
|
+
value = client[Symbol.for(`ClusterClient#${descriptor.to}`)];
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
default:
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
Object.defineProperty(client, name, {
|
|
167
|
+
value,
|
|
168
|
+
writable: true,
|
|
169
|
+
enumerable: true,
|
|
170
|
+
configurable: true,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return client;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
_generateDescriptors() {
|
|
178
|
+
const clientClass = this._clientClass;
|
|
179
|
+
const proto = clientClass.prototype;
|
|
180
|
+
|
|
181
|
+
const needGenerateMethods = new Set(autoGenerateMethods);
|
|
182
|
+
for (const entry of this._descriptors.entries()) {
|
|
183
|
+
const key = entry[0];
|
|
184
|
+
const value = entry[1];
|
|
185
|
+
if (needGenerateMethods.has(key) ||
|
|
186
|
+
(value.type === 'delegate' && needGenerateMethods.has(value.to))) {
|
|
187
|
+
needGenerateMethods.delete(key);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
for (const method of needGenerateMethods.values()) {
|
|
191
|
+
if (is.function(proto[method])) {
|
|
192
|
+
this.delegate(method, method);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const keys = Reflect.ownKeys(proto)
|
|
197
|
+
.filter(key => typeof key !== 'symbol' &&
|
|
198
|
+
!key.startsWith('_') &&
|
|
199
|
+
!this._descriptors.has(key));
|
|
200
|
+
|
|
201
|
+
for (const key of keys) {
|
|
202
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(proto, key);
|
|
203
|
+
if (descriptor.value &&
|
|
204
|
+
(is.generatorFunction(descriptor.value) || is.asyncFunction(descriptor.value))) {
|
|
205
|
+
this.delegate(key);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
module.exports = function(clientClass, options) {
|
|
212
|
+
return new ClientGenerator(clientClass, options);
|
|
213
|
+
};
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const debug = require('util').debuglog('cluster-client#leader');
|
|
4
|
+
const co = require('co');
|
|
5
|
+
const is = require('is-type-of');
|
|
6
|
+
const Base = require('sdk-base');
|
|
7
|
+
const utils = require('./utils');
|
|
8
|
+
const random = require('utility').random;
|
|
9
|
+
const ClusterServer = require('./server');
|
|
10
|
+
const Connection = require('./connection');
|
|
11
|
+
const Request = require('./protocol/request');
|
|
12
|
+
const Response = require('./protocol/response');
|
|
13
|
+
|
|
14
|
+
class Leader extends Base {
|
|
15
|
+
/**
|
|
16
|
+
* The Leader hold the real client
|
|
17
|
+
*
|
|
18
|
+
* @param {Object} options
|
|
19
|
+
* - {String} name - client name, default is the class name
|
|
20
|
+
* - {ClusterServer} server - the cluster server
|
|
21
|
+
* - {Boolean} isBroadcast - whether broadcast subscrption result to all followers or just one, default is true
|
|
22
|
+
* - {Number} heartbeatInterval - the heartbeat interval
|
|
23
|
+
* - {Function} createRealClient - to create the real client
|
|
24
|
+
* - {Boolean} isCheckHeartbeat - whether check heartbeat, default is true
|
|
25
|
+
* @class
|
|
26
|
+
*/
|
|
27
|
+
constructor(options) {
|
|
28
|
+
super(options);
|
|
29
|
+
this._connections = new Map();
|
|
30
|
+
this._subListeners = new Map(); // subscribe key => listener
|
|
31
|
+
this._subConnMap = new Map(); // subscribe key => conn key
|
|
32
|
+
this._subData = new Map();
|
|
33
|
+
// local socket server
|
|
34
|
+
this._server = this.options.server;
|
|
35
|
+
this._transcode = this.options.transcode;
|
|
36
|
+
this._isReady = false;
|
|
37
|
+
this._closeByUser = false;
|
|
38
|
+
// the real client
|
|
39
|
+
this._realClient = this.options.createRealClient();
|
|
40
|
+
this._subscribeMethodName = this._findMethodName('subscribe');
|
|
41
|
+
this._publishMethodName = this._findMethodName('publish');
|
|
42
|
+
|
|
43
|
+
// event delegate
|
|
44
|
+
utils.delegateEvents(this._realClient, this);
|
|
45
|
+
|
|
46
|
+
if (is.function(this._realClient.ready)) {
|
|
47
|
+
this._realClient.ready(err => {
|
|
48
|
+
if (err) {
|
|
49
|
+
this.ready(err);
|
|
50
|
+
} else {
|
|
51
|
+
this._isReady = true;
|
|
52
|
+
this.ready(true);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
this._isReady = true;
|
|
57
|
+
this.ready(true);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this._handleConnection = this._handleConnection.bind(this);
|
|
61
|
+
|
|
62
|
+
// subscribe its own channel
|
|
63
|
+
this._server.on(`${this.options.name}_connection`, this._handleConnection);
|
|
64
|
+
this._server.once('close', () => { this.emit('server_closed'); });
|
|
65
|
+
this.on('server_closed', () => {
|
|
66
|
+
this._handleClose().catch(err => { this.emit('error', err); });
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
if (this.options.isCheckHeartbeat) {
|
|
70
|
+
// maxIdleTime is 3 times of heartbeatInterval
|
|
71
|
+
const heartbeatInterval = this.options.heartbeatInterval;
|
|
72
|
+
const maxIdleTime = this.options.heartbeatInterval * 3;
|
|
73
|
+
|
|
74
|
+
this._heartbeatTimer = setInterval(() => {
|
|
75
|
+
const now = Date.now();
|
|
76
|
+
for (const conn of this._connections.values()) {
|
|
77
|
+
const dur = now - conn.lastActiveTime;
|
|
78
|
+
if (dur > maxIdleTime) {
|
|
79
|
+
const err = new Error(`client no response in ${dur}ms exceeding maxIdleTime ${maxIdleTime}ms, maybe the connection is close on other side.`);
|
|
80
|
+
err.name = 'ClusterClientNoResponseError';
|
|
81
|
+
conn.close(err);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, heartbeatInterval);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get isLeader() {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get logger() {
|
|
93
|
+
return this.options.logger;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
formatKey(reg) {
|
|
97
|
+
return '$$inner$$__' + this.options.formatKey(reg);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
subscribe(reg, listener) {
|
|
101
|
+
const transcode = this._transcode;
|
|
102
|
+
const conn = Object.create(Base.prototype, {
|
|
103
|
+
isMock: { value: true },
|
|
104
|
+
key: { value: `${this.options.name}_mock_conn_${utils.nextId()}` },
|
|
105
|
+
lastActiveTime: {
|
|
106
|
+
get() {
|
|
107
|
+
return Date.now();
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
listener: {
|
|
111
|
+
get() {
|
|
112
|
+
return listener;
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
send: {
|
|
116
|
+
value(req) {
|
|
117
|
+
const result = transcode.decode(req.data);
|
|
118
|
+
process.nextTick(() => {
|
|
119
|
+
listener(result);
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
close: { value() {} },
|
|
124
|
+
});
|
|
125
|
+
conn.once('close', () => {
|
|
126
|
+
this._connections.delete(conn.key);
|
|
127
|
+
for (const connKeySet of this._subConnMap.values()) {
|
|
128
|
+
connKeySet.delete(conn.key);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
this._connections.set(conn.key, conn);
|
|
133
|
+
this._doSubscribe(reg, conn);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
unSubscribe(reg, listener) {
|
|
137
|
+
const key = this.formatKey(reg);
|
|
138
|
+
const connKeySet = this._subConnMap.get(key) || new Set();
|
|
139
|
+
const newConnKeySet = new Set();
|
|
140
|
+
for (const connKey of connKeySet.values()) {
|
|
141
|
+
const conn = this._connections.get(connKey);
|
|
142
|
+
if (!conn) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (conn.isMock && (!listener || conn.listener === listener)) {
|
|
146
|
+
this._connections.delete(connKey);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
newConnKeySet.add(connKey);
|
|
150
|
+
}
|
|
151
|
+
this._subConnMap.set(key, newConnKeySet);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
publish(reg) {
|
|
155
|
+
this._realClient[this._publishMethodName](reg);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
invoke(methodName, args, callback) {
|
|
159
|
+
let method = this._realClient[methodName];
|
|
160
|
+
// compatible with generatorFunction
|
|
161
|
+
if (is.generatorFunction(method)) {
|
|
162
|
+
method = co.wrap(method);
|
|
163
|
+
}
|
|
164
|
+
args.push(callback);
|
|
165
|
+
const ret = method.apply(this._realClient, args);
|
|
166
|
+
if (callback && is.promise(ret)) {
|
|
167
|
+
ret.then(result => callback(null, result), err => callback(err))
|
|
168
|
+
// to avoid uncaught exception in callback function, then cause unhandledRejection
|
|
169
|
+
.catch(err => { this._errorHandler(err); });
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
_doSubscribe(reg, conn) {
|
|
174
|
+
const key = this.formatKey(reg);
|
|
175
|
+
const callback = err => {
|
|
176
|
+
if (err) {
|
|
177
|
+
this._errorHandler(err);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const isBroadcast = this.options.isBroadcast;
|
|
181
|
+
const timeout = this.options.responseTimeout;
|
|
182
|
+
|
|
183
|
+
const connKeySet = this._subConnMap.get(key) || new Set();
|
|
184
|
+
connKeySet.add(conn.key);
|
|
185
|
+
this._subConnMap.set(key, connKeySet);
|
|
186
|
+
|
|
187
|
+
// only subscribe once in cluster mode, and broadcast to all followers
|
|
188
|
+
if (!this._subListeners.has(key)) {
|
|
189
|
+
const listener = result => {
|
|
190
|
+
const data = this._transcode.encode(result);
|
|
191
|
+
this._subData.set(key, data);
|
|
192
|
+
|
|
193
|
+
const connKeySet = this._subConnMap.get(key);
|
|
194
|
+
if (!connKeySet) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
let keys = Array.from(connKeySet.values());
|
|
198
|
+
// if isBroadcast equal to false, random pick one to notify
|
|
199
|
+
if (!isBroadcast) {
|
|
200
|
+
keys = [ keys[random(keys.length)] ];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
for (const connKey of keys) {
|
|
204
|
+
const conn = this._connections.get(connKey);
|
|
205
|
+
if (conn) {
|
|
206
|
+
debug('[Leader:%s] push subscribe data to cluster client#%s', this.options.name, connKey);
|
|
207
|
+
conn.send(new Request({
|
|
208
|
+
timeout,
|
|
209
|
+
connObj: {
|
|
210
|
+
type: 'subscribe_result',
|
|
211
|
+
key,
|
|
212
|
+
},
|
|
213
|
+
data,
|
|
214
|
+
}), callback);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
this._subListeners.set(key, listener);
|
|
219
|
+
this._realClient[this._subscribeMethodName](reg, listener);
|
|
220
|
+
} else if (this._subData.has(key) && isBroadcast) {
|
|
221
|
+
conn.send(new Request({
|
|
222
|
+
timeout,
|
|
223
|
+
connObj: {
|
|
224
|
+
type: 'subscribe_result',
|
|
225
|
+
key,
|
|
226
|
+
},
|
|
227
|
+
data: this._subData.get(key),
|
|
228
|
+
}), callback);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
_findMethodName(type) {
|
|
233
|
+
return utils.findMethodName(this.options.descriptors, type);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// handle new socket connect
|
|
237
|
+
_handleConnection(socket, req) {
|
|
238
|
+
debug('[Leader:%s] socket connected, port: %d', this.options.name, socket.remotePort);
|
|
239
|
+
|
|
240
|
+
const conn = new Connection({
|
|
241
|
+
socket,
|
|
242
|
+
name: this.options.name,
|
|
243
|
+
logger: this.logger,
|
|
244
|
+
transcode: this.options.transcode,
|
|
245
|
+
requestTimeout: this.options.requestTimeout,
|
|
246
|
+
});
|
|
247
|
+
this._connections.set(conn.key, conn);
|
|
248
|
+
conn.once('close', () => {
|
|
249
|
+
this._connections.delete(conn.key);
|
|
250
|
+
for (const connKeySet of this._subConnMap.values()) {
|
|
251
|
+
connKeySet.delete(conn.key);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
conn.on('error', err => this._errorHandler(err));
|
|
255
|
+
conn.on('request', (req, res) => this._handleRequest(req, res, conn));
|
|
256
|
+
|
|
257
|
+
// handle register channel request
|
|
258
|
+
const res = new Response({
|
|
259
|
+
id: req.id,
|
|
260
|
+
timeout: req.timeout,
|
|
261
|
+
});
|
|
262
|
+
this._handleRequest(req, res, conn);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
_handleSubscribe(req, conn) {
|
|
266
|
+
const connObj = req.connObj || {};
|
|
267
|
+
this._doSubscribe(connObj.reg, conn);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
_handleUnSubscribe(req, conn) {
|
|
271
|
+
const connObj = req.connObj || {};
|
|
272
|
+
const key = this.formatKey(connObj.reg);
|
|
273
|
+
const connKeySet = this._subConnMap.get(key) || new Set();
|
|
274
|
+
connKeySet.delete(conn.key);
|
|
275
|
+
this._subConnMap.set(key, connKeySet);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// handle request from followers
|
|
279
|
+
_handleRequest(req, res, conn) {
|
|
280
|
+
const connObj = req.connObj || {};
|
|
281
|
+
// update last active time to make sure not kick out by leader
|
|
282
|
+
conn.lastActiveTime = Date.now();
|
|
283
|
+
|
|
284
|
+
switch (connObj.type) {
|
|
285
|
+
case 'subscribe':
|
|
286
|
+
debug('[Leader:%s] received subscribe request from follower, req: %j, conn: %s', this.options.name, req, conn.key);
|
|
287
|
+
this._handleSubscribe(req, conn);
|
|
288
|
+
break;
|
|
289
|
+
case 'unSubscribe':
|
|
290
|
+
debug('[Leader:%s] received unSubscribe request from follower, req: %j, conn: %s', this.options.name, req, conn.key);
|
|
291
|
+
this._handleUnSubscribe(req, conn);
|
|
292
|
+
break;
|
|
293
|
+
case 'invoke':
|
|
294
|
+
{
|
|
295
|
+
debug('[Leader:%s] received invoke request from follower, req: %j, conn: %s', this.options.name, req, conn.key);
|
|
296
|
+
const argLength = connObj.argLength;
|
|
297
|
+
const args = [];
|
|
298
|
+
if (argLength > 0) {
|
|
299
|
+
const data = req.data;
|
|
300
|
+
for (let i = 0, offset = 0; i < argLength; ++i) {
|
|
301
|
+
const len = data.readUInt32BE(offset);
|
|
302
|
+
const arg = this._transcode.decode(data.slice(offset + 4, offset + 4 + len));
|
|
303
|
+
args.push(arg);
|
|
304
|
+
offset += (4 + len);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (connObj.oneway) {
|
|
309
|
+
this.invoke(connObj.method, args);
|
|
310
|
+
} else {
|
|
311
|
+
const startTime = Date.now();
|
|
312
|
+
this.invoke(connObj.method, args, (err, result) => {
|
|
313
|
+
// no response if processing timeout, just record error
|
|
314
|
+
if (req.timeout && Date.now() - startTime > req.timeout) {
|
|
315
|
+
const err = new Error(`[Leader:${this.options.name}] invoke method:${connObj.method} timeout for req#${req.id}`);
|
|
316
|
+
err.name = 'ClusterLeaderTimeoutError';
|
|
317
|
+
err.method = connObj.method;
|
|
318
|
+
err.args = args;
|
|
319
|
+
this._errorHandler(err);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (err) {
|
|
324
|
+
const data = {
|
|
325
|
+
stack: err.stack,
|
|
326
|
+
name: err.name,
|
|
327
|
+
message: err.message,
|
|
328
|
+
code: err.code,
|
|
329
|
+
};
|
|
330
|
+
err.method = connObj.method;
|
|
331
|
+
err.args = connObj.args;
|
|
332
|
+
this._errorHandler(err);
|
|
333
|
+
|
|
334
|
+
res.connObj = {
|
|
335
|
+
type: 'invoke_result',
|
|
336
|
+
success: false,
|
|
337
|
+
};
|
|
338
|
+
res.data = this._transcode.encode(data);
|
|
339
|
+
} else {
|
|
340
|
+
debug('[Leader:%s] send method:%s result to follower, result: %j', this.options.name, connObj.method, result);
|
|
341
|
+
const data = this._transcode.encode(result);
|
|
342
|
+
res.connObj = {
|
|
343
|
+
type: 'invoke_result',
|
|
344
|
+
success: true,
|
|
345
|
+
};
|
|
346
|
+
res.data = data;
|
|
347
|
+
}
|
|
348
|
+
conn.send(res);
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
case 'heartbeat':
|
|
354
|
+
debug('[Leader:%s] received heartbeat request from follower, req: %j, conn: %s', this.options.name, req, conn.key);
|
|
355
|
+
res.connObj = { type: 'heartbeat_res' };
|
|
356
|
+
conn.send(res);
|
|
357
|
+
break;
|
|
358
|
+
case 'register_channel':
|
|
359
|
+
// make sure response after leader is ready
|
|
360
|
+
this.ready(err => {
|
|
361
|
+
if (err) {
|
|
362
|
+
res.connObj = { type: 'register_channel_res' };
|
|
363
|
+
const data = {
|
|
364
|
+
message: err.message,
|
|
365
|
+
stack: err.stack,
|
|
366
|
+
name: err.name,
|
|
367
|
+
code: err.code,
|
|
368
|
+
};
|
|
369
|
+
res.data = this._transcode.encode({
|
|
370
|
+
success: false,
|
|
371
|
+
error: data,
|
|
372
|
+
});
|
|
373
|
+
} else {
|
|
374
|
+
res.connObj = { type: 'register_channel_res' };
|
|
375
|
+
res.data = this._transcode.encode({ success: true });
|
|
376
|
+
}
|
|
377
|
+
conn.send(res);
|
|
378
|
+
});
|
|
379
|
+
break;
|
|
380
|
+
default:
|
|
381
|
+
{
|
|
382
|
+
const err = new Error(`unsupport data type: ${connObj.type}`);
|
|
383
|
+
err.name = 'ClusterRequestTypeError';
|
|
384
|
+
this._errorHandler(err);
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// emit error asynchronously
|
|
391
|
+
_errorHandler(err) {
|
|
392
|
+
setImmediate(() => {
|
|
393
|
+
if (!this._closeByUser) {
|
|
394
|
+
this.emit('error', err);
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
async _handleClose() {
|
|
400
|
+
debug('[Leader:%s] leader server is closed', this.options.name);
|
|
401
|
+
// close the real client
|
|
402
|
+
if (this._realClient) {
|
|
403
|
+
const originClose = this._findMethodName('close');
|
|
404
|
+
if (originClose) {
|
|
405
|
+
// support common function, generatorFunction, and function returning a promise
|
|
406
|
+
await utils.callFn(this._realClient[originClose].bind(this._realClient));
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
this._heartbeatTimer && clearInterval(this._heartbeatTimer);
|
|
410
|
+
this._heartbeatTimer = null;
|
|
411
|
+
this.emit('close');
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
async close() {
|
|
415
|
+
this._closeByUser = true;
|
|
416
|
+
debug('[Leader:%s] try to close leader', this.options.name);
|
|
417
|
+
// 1. stop listening to server channel
|
|
418
|
+
this._server.removeListener(`${this.options.name}_connection`, this._handleConnection);
|
|
419
|
+
|
|
420
|
+
// 2. close all mock connections
|
|
421
|
+
for (const conn of this._connections.values()) {
|
|
422
|
+
if (conn.isMock) {
|
|
423
|
+
conn.emit('close');
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// 3. close server
|
|
428
|
+
// CANNOT close server directly by server.close(), other cluster clients may be using it
|
|
429
|
+
this.removeAllListeners('server_closed');
|
|
430
|
+
await ClusterServer.close(this.options.name, this._server);
|
|
431
|
+
|
|
432
|
+
// 5. close real client
|
|
433
|
+
await this._handleClose();
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
module.exports = Leader;
|