@tencent-rtc/mcp 1.0.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/@tencent/aegis-node-sdk/CHANGELOG.md +8 -0
- package/@tencent/aegis-node-sdk/LICENSE +21 -0
- package/@tencent/aegis-node-sdk/README.md +562 -0
- package/@tencent/aegis-node-sdk/lib/aegis.min.js +1 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/constant/config.d.ts +14 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/constant/global.d.ts +1 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/constant/index.d.ts +9 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/constant/report-ignore.d.ts +2 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/core.d.ts +85 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/hooks/afterRequestHooks.d.ts +3 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/hooks/beforeRequestHooks.d.ts +9 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/hooks/modifyRequestHooks.d.ts +3 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/index.d.ts +9 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/interface/config.d.ts +62 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/interface/env.d.ts +11 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/interface/index.d.ts +4 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/interface/log.d.ts +130 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/interface/send.d.ts +34 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/format.d.ts +2 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/index.d.ts +18 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/length-limit.d.ts +8 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/pv.d.ts +8 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/remove-payload.d.ts +2 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/repeat-limit.d.ts +4 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/report.d.ts +10 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/sample.d.ts +3 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/throttle.d.ts +3 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/trace/index.d.ts +34 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/trace/jwt.d.ts +12 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/trace/ot-js.d.ts +14 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/trace/uuid.d.ts +2 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/whitelist.d.ts +12 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/pipes/write-before.d.ts +3 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/plugin.d.ts +33 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/polyfill.d.ts +0 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/util/destroy.d.ts +2 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/util/event-emitter.d.ts +18 -0
- package/@tencent/aegis-node-sdk/lib/packages/core/src/util/index.d.ts +60 -0
- package/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/index.d.ts +15 -0
- package/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/interface/selector.d.ts +5 -0
- package/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/pipes/batch-report-pipe.d.ts +6 -0
- package/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/protocol/protocol_base.d.ts +18 -0
- package/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/protocol/protocol_http.d.ts +12 -0
- package/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/selector/ip_selector.d.ts +10 -0
- package/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/selector/polaris_selector.d.ts +20 -0
- package/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/selector/selector_base.d.ts +27 -0
- package/@tencent/aegis-node-sdk/lib/packages/node-sdk/src/util/eval_require.d.ts +2 -0
- package/@tencent/aegis-node-sdk/package.json +19 -0
- package/@tencent/polaris/README.md +407 -0
- package/@tencent/polaris/dist/consumer/health.d.ts +126 -0
- package/@tencent/polaris/dist/consumer/health.js +283 -0
- package/@tencent/polaris/dist/consumer/health.js.map +1 -0
- package/@tencent/polaris/dist/consumer/index.d.ts +120 -0
- package/@tencent/polaris/dist/consumer/index.js +348 -0
- package/@tencent/polaris/dist/consumer/index.js.map +1 -0
- package/@tencent/polaris/dist/consumer/monitor.d.ts +145 -0
- package/@tencent/polaris/dist/consumer/monitor.js +343 -0
- package/@tencent/polaris/dist/consumer/monitor.js.map +1 -0
- package/@tencent/polaris/dist/consumer/selector.d.ts +73 -0
- package/@tencent/polaris/dist/consumer/selector.js +316 -0
- package/@tencent/polaris/dist/consumer/selector.js.map +1 -0
- package/@tencent/polaris/dist/errors.d.ts +373 -0
- package/@tencent/polaris/dist/errors.js +154 -0
- package/@tencent/polaris/dist/errors.js.map +1 -0
- package/@tencent/polaris/dist/global.d.ts +16 -0
- package/@tencent/polaris/dist/global.js +18 -0
- package/@tencent/polaris/dist/global.js.map +1 -0
- package/@tencent/polaris/dist/index.d.ts +62 -0
- package/@tencent/polaris/dist/index.js +145 -0
- package/@tencent/polaris/dist/index.js.map +1 -0
- package/@tencent/polaris/dist/instance.d.ts +109 -0
- package/@tencent/polaris/dist/instance.js +38 -0
- package/@tencent/polaris/dist/instance.js.map +1 -0
- package/@tencent/polaris/dist/limiter/bucket.d.ts +51 -0
- package/@tencent/polaris/dist/limiter/bucket.js +152 -0
- package/@tencent/polaris/dist/limiter/bucket.js.map +1 -0
- package/@tencent/polaris/dist/limiter/index.d.ts +73 -0
- package/@tencent/polaris/dist/limiter/index.js +149 -0
- package/@tencent/polaris/dist/limiter/index.js.map +1 -0
- package/@tencent/polaris/dist/limiter/ratelimit.d.ts +27 -0
- package/@tencent/polaris/dist/limiter/ratelimit.js +134 -0
- package/@tencent/polaris/dist/limiter/ratelimit.js.map +1 -0
- package/@tencent/polaris/dist/limiter/ratelimiter/base.d.ts +17 -0
- package/@tencent/polaris/dist/limiter/ratelimiter/base.js +15 -0
- package/@tencent/polaris/dist/limiter/ratelimiter/base.js.map +1 -0
- package/@tencent/polaris/dist/limiter/ratelimiter/global.d.ts +59 -0
- package/@tencent/polaris/dist/limiter/ratelimiter/global.js +397 -0
- package/@tencent/polaris/dist/limiter/ratelimiter/global.js.map +1 -0
- package/@tencent/polaris/dist/limiter/ratelimiter/index.d.ts +3 -0
- package/@tencent/polaris/dist/limiter/ratelimiter/index.js +19 -0
- package/@tencent/polaris/dist/limiter/ratelimiter/index.js.map +1 -0
- package/@tencent/polaris/dist/limiter/ratelimiter/local.d.ts +17 -0
- package/@tencent/polaris/dist/limiter/ratelimiter/local.js +52 -0
- package/@tencent/polaris/dist/limiter/ratelimiter/local.js.map +1 -0
- package/@tencent/polaris/dist/location.d.ts +48 -0
- package/@tencent/polaris/dist/location.js +67 -0
- package/@tencent/polaris/dist/location.js.map +1 -0
- package/@tencent/polaris/dist/logging.d.ts +106 -0
- package/@tencent/polaris/dist/logging.js +130 -0
- package/@tencent/polaris/dist/logging.js.map +1 -0
- package/@tencent/polaris/dist/metadata.d.ts +78 -0
- package/@tencent/polaris/dist/metadata.js +119 -0
- package/@tencent/polaris/dist/metadata.js.map +1 -0
- package/@tencent/polaris/dist/plugins/breaker/polaris.d.ts +47 -0
- package/@tencent/polaris/dist/plugins/breaker/polaris.js +162 -0
- package/@tencent/polaris/dist/plugins/breaker/polaris.js.map +1 -0
- package/@tencent/polaris/dist/plugins/lb/base.d.ts +24 -0
- package/@tencent/polaris/dist/plugins/lb/base.js +32 -0
- package/@tencent/polaris/dist/plugins/lb/base.js.map +1 -0
- package/@tencent/polaris/dist/plugins/lb/edf.d.ts +24 -0
- package/@tencent/polaris/dist/plugins/lb/edf.js +77 -0
- package/@tencent/polaris/dist/plugins/lb/edf.js.map +1 -0
- package/@tencent/polaris/dist/plugins/lb/hashring.d.ts +24 -0
- package/@tencent/polaris/dist/plugins/lb/hashring.js +53 -0
- package/@tencent/polaris/dist/plugins/lb/hashring.js.map +1 -0
- package/@tencent/polaris/dist/plugins/lb/sticky.d.ts +31 -0
- package/@tencent/polaris/dist/plugins/lb/sticky.js +88 -0
- package/@tencent/polaris/dist/plugins/lb/sticky.js.map +1 -0
- package/@tencent/polaris/dist/plugins/lb/swrr.d.ts +25 -0
- package/@tencent/polaris/dist/plugins/lb/swrr.js +72 -0
- package/@tencent/polaris/dist/plugins/lb/swrr.js.map +1 -0
- package/@tencent/polaris/dist/plugins/lb/wr.d.ts +17 -0
- package/@tencent/polaris/dist/plugins/lb/wr.js +50 -0
- package/@tencent/polaris/dist/plugins/lb/wr.js.map +1 -0
- package/@tencent/polaris/dist/plugins/lb/wrr.d.ts +19 -0
- package/@tencent/polaris/dist/plugins/lb/wrr.js +81 -0
- package/@tencent/polaris/dist/plugins/lb/wrr.js.map +1 -0
- package/@tencent/polaris/dist/plugins/logging/console.d.ts +10 -0
- package/@tencent/polaris/dist/plugins/logging/console.js +38 -0
- package/@tencent/polaris/dist/plugins/logging/console.js.map +1 -0
- package/@tencent/polaris/dist/plugins/naming/local-server/index.d.ts +32 -0
- package/@tencent/polaris/dist/plugins/naming/local-server/index.js +88 -0
- package/@tencent/polaris/dist/plugins/naming/local-server/index.js.map +1 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/base.d.ts +124 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/base.js +398 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/base.js.map +1 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/discover.d.ts +27 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/discover.js +287 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/discover.js.map +1 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/index.d.ts +15 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/index.js +43 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/index.js.map +1 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/monitor.d.ts +28 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/monitor.js +249 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/monitor.js.map +1 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/ratelimit.d.ts +19 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/ratelimit.js +222 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/adapter/ratelimit.js.map +1 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/bidi.d.ts +26 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/bidi.js +99 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/bidi.js.map +1 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/index.d.ts +60 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/index.js +259 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/index.js.map +1 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/pb/discover.proto +24 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/pb/monitor.proto +18 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/connector/grpc/pb/ratelimit.proto +12 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/connector/http/index.d.ts +39 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/connector/http/index.js +115 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/connector/http/index.js.map +1 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/api.proto +24 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/client.proto +22 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/model.proto +28 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/ratelimit.proto +80 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/request.proto +18 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/response.proto +65 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/routing.proto +66 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/service.proto +95 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/discover-pb/types.d.ts +1568 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/index.d.ts +36 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/index.js +51 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/index.js.map +1 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/api.proto +18 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/circuitbreak.proto +67 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/request.proto +82 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/response.proto +11 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/sdkcache.proto +46 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/sdkconfiguration.proto +16 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/sdktoken.proto +10 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/monitor-pb/types.d.ts +1102 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/pool.d.ts +29 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/pool.js +77 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/pool.js.map +1 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/ratelimit-pb/api.proto +12 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/ratelimit-pb/ratelimit.proto +28 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/ratelimit-pb/types.d.ts +395 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/rules.d.ts +13 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/rules.js +116 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/rules.js.map +1 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/types.d.ts +67 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/types.js +67 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/types.js.map +1 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/utils.d.ts +99 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/utils.js +217 -0
- package/@tencent/polaris/dist/plugins/naming/polaris-server/utils.js.map +1 -0
- package/@tencent/polaris/dist/plugins/registry/memory.d.ts +10 -0
- package/@tencent/polaris/dist/plugins/registry/memory.js +50 -0
- package/@tencent/polaris/dist/plugins/registry/memory.js.map +1 -0
- package/@tencent/polaris/dist/plugins/router/polaris/nearby.d.ts +51 -0
- package/@tencent/polaris/dist/plugins/router/polaris/nearby.js +145 -0
- package/@tencent/polaris/dist/plugins/router/polaris/nearby.js.map +1 -0
- package/@tencent/polaris/dist/plugins/router/polaris/rule.d.ts +11 -0
- package/@tencent/polaris/dist/plugins/router/polaris/rule.js +174 -0
- package/@tencent/polaris/dist/plugins/router/polaris/rule.js.map +1 -0
- package/@tencent/polaris/dist/plugins/router/trpc/canary.d.ts +25 -0
- package/@tencent/polaris/dist/plugins/router/trpc/canary.js +36 -0
- package/@tencent/polaris/dist/plugins/router/trpc/canary.js.map +1 -0
- package/@tencent/polaris/dist/plugins/router/trpc/env.d.ts +10 -0
- package/@tencent/polaris/dist/plugins/router/trpc/env.js +34 -0
- package/@tencent/polaris/dist/plugins/router/trpc/env.js.map +1 -0
- package/@tencent/polaris/dist/plugins/router/trpc/set.d.ts +56 -0
- package/@tencent/polaris/dist/plugins/router/trpc/set.js +106 -0
- package/@tencent/polaris/dist/plugins/router/trpc/set.js.map +1 -0
- package/@tencent/polaris/dist/plugins/shaping/unirate.d.ts +31 -0
- package/@tencent/polaris/dist/plugins/shaping/unirate.js +124 -0
- package/@tencent/polaris/dist/plugins/shaping/unirate.js.map +1 -0
- package/@tencent/polaris/dist/plugins/shaping/warmup.d.ts +61 -0
- package/@tencent/polaris/dist/plugins/shaping/warmup.js +171 -0
- package/@tencent/polaris/dist/plugins/shaping/warmup.js.map +1 -0
- package/@tencent/polaris/dist/plugins/weight/polaris.d.ts +23 -0
- package/@tencent/polaris/dist/plugins/weight/polaris.js +159 -0
- package/@tencent/polaris/dist/plugins/weight/polaris.js.map +1 -0
- package/@tencent/polaris/dist/plugins.d.ts +619 -0
- package/@tencent/polaris/dist/plugins.js +91 -0
- package/@tencent/polaris/dist/plugins.js.map +1 -0
- package/@tencent/polaris/dist/polaris.d.ts +33 -0
- package/@tencent/polaris/dist/polaris.js +59 -0
- package/@tencent/polaris/dist/polaris.js.map +1 -0
- package/@tencent/polaris/dist/provider/index.d.ts +102 -0
- package/@tencent/polaris/dist/provider/index.js +168 -0
- package/@tencent/polaris/dist/provider/index.js.map +1 -0
- package/@tencent/polaris/dist/registry.d.ts +174 -0
- package/@tencent/polaris/dist/registry.js +660 -0
- package/@tencent/polaris/dist/registry.js.map +1 -0
- package/@tencent/polaris/dist/rules.d.ts +163 -0
- package/@tencent/polaris/dist/rules.js +24 -0
- package/@tencent/polaris/dist/rules.js.map +1 -0
- package/@tencent/polaris/dist/scripts/postinstall.d.ts +1 -0
- package/@tencent/polaris/dist/scripts/postinstall.js +71 -0
- package/@tencent/polaris/dist/scripts/postinstall.js.map +1 -0
- package/@tencent/polaris/dist/service.d.ts +18 -0
- package/@tencent/polaris/dist/service.js +3 -0
- package/@tencent/polaris/dist/service.js.map +1 -0
- package/@tencent/polaris/dist/skeleton.d.ts +87 -0
- package/@tencent/polaris/dist/skeleton.js +282 -0
- package/@tencent/polaris/dist/skeleton.js.map +1 -0
- package/@tencent/polaris/dist/utils.d.ts +36 -0
- package/@tencent/polaris/dist/utils.js +74 -0
- package/@tencent/polaris/dist/utils.js.map +1 -0
- package/@tencent/polaris/dist/weak.d.ts +11 -0
- package/@tencent/polaris/dist/weak.js +44 -0
- package/@tencent/polaris/dist/weak.js.map +1 -0
- package/@tencent/polaris/package.json +114 -0
- package/README.md +61 -0
- package/cursor-setting.png +0 -0
- package/index.js +16 -0
- package/index.js.map +1 -0
- package/mcp-server-prompt.png +0 -0
- package/mcp.json +8 -0
- package/package.json +49 -0
- package/resource/doc/tuicallkit/android/.gitkeep +0 -0
- package/resource/doc/tuicallkit/android/api_TUICallKit.md +610 -0
- package/resource/doc/tuicallkit/android/api_TUICallObserver.md +784 -0
- package/resource/doc/tuicallkit/android/how_to_integrated_android_callkit.md +286 -0
- package/resource/doc/tuicallkit/faq/faq.md +127 -0
- package/resource/doc/tuicallkit/flutter/api_TUICallDefine.md +938 -0
- package/resource/doc/tuicallkit/flutter/api_TUICallKit.md +469 -0
- package/resource/doc/tuicallkit/flutter/api_TUICallObserver.md +897 -0
- package/resource/doc/tuicallkit/flutter/how_to_integrated_flutter_callkit.md +226 -0
- package/resource/doc/tuicallkit/flutter/how_to_run_flutter_callkit_demo.md +101 -0
- package/resource/doc/tuicallkit/iOS/api_TUICallKit.md +398 -0
- package/resource/doc/tuicallkit/iOS/api_TUICallObserver.md +781 -0
- package/resource/doc/tuicallkit/iOS/how_to_integrated_iOS_callkit.md +268 -0
- package/resource/doc/tuicallkit/iOS/how_to_run_iOS_callkit_demo.md +98 -0
- package/resource/doc/tuicallkit/react/.gitkeep +0 -0
- package/resource/doc/tuicallkit/react/api_TUICallKit.md +354 -0
- package/resource/doc/tuicallkit/react/how_to_integrated_react_callkit.md +166 -0
- package/resource/doc/tuicallkit/react/how_to_run_react_callkit_demo.md +61 -0
- package/resource/doc/tuicallkit/vue/.gitkeep +0 -0
- package/resource/doc/tuicallkit/vue/api_TUICallKit.md +354 -0
- package/resource/doc/tuicallkit/vue/how_to_integrated_vue_callkit.md +187 -0
- package/resource/doc/tuicallkit/vue/how_to_run_vue_callkit_demo.md +61 -0
- package/server.js +132 -0
- package/server.js.map +1 -0
- package/streamableHttp.js +74 -0
- package/streamableHttp.js.map +1 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Limiter = exports.Provider = exports.Consumer = exports.PolarisServerClient = exports.PolarisGRPCClient = exports.PolarisHTTPClient = exports.getEmbeddedDiscoverHosts = void 0;
|
|
18
|
+
const polaris_1 = require("./polaris");
|
|
19
|
+
__exportStar(require("./polaris"), exports);
|
|
20
|
+
// #region Embedded Host
|
|
21
|
+
var DiscoverBackend;
|
|
22
|
+
(function (DiscoverBackend) {
|
|
23
|
+
/** 正式环境 */
|
|
24
|
+
DiscoverBackend[DiscoverBackend["Formal"] = 0] = "Formal";
|
|
25
|
+
/** 测试环境 */
|
|
26
|
+
DiscoverBackend[DiscoverBackend["Debug"] = 1] = "Debug";
|
|
27
|
+
})(DiscoverBackend || (DiscoverBackend = {}));
|
|
28
|
+
const kDiscoverHosts = {
|
|
29
|
+
[DiscoverBackend.Debug]: [
|
|
30
|
+
"9.205.2.29",
|
|
31
|
+
"9.205.2.123"
|
|
32
|
+
],
|
|
33
|
+
[DiscoverBackend.Formal]: [
|
|
34
|
+
"9.141.66.244",
|
|
35
|
+
"9.146.202.27",
|
|
36
|
+
"9.146.200.81",
|
|
37
|
+
"9.146.202.35",
|
|
38
|
+
"9.146.205.191",
|
|
39
|
+
"9.146.200.61",
|
|
40
|
+
"9.141.66.219",
|
|
41
|
+
"9.141.65.110",
|
|
42
|
+
"9.141.65.29",
|
|
43
|
+
"9.141.121.7"
|
|
44
|
+
]
|
|
45
|
+
};
|
|
46
|
+
const getEmbeddedDiscoverHosts = (port) => {
|
|
47
|
+
const hosts = kDiscoverHosts[process.env.POLARIS_NAMING_DISCOVER_DEBUG ? DiscoverBackend.Debug : DiscoverBackend.Formal];
|
|
48
|
+
return port ? hosts.map(host => `${host}:${port}`) : hosts;
|
|
49
|
+
};
|
|
50
|
+
exports.getEmbeddedDiscoverHosts = getEmbeddedDiscoverHosts;
|
|
51
|
+
// #endregion
|
|
52
|
+
// #region AOP
|
|
53
|
+
// #region plugins.naming.PolarisServerClient
|
|
54
|
+
class PolarisHTTPClient extends polaris_1.PolarisHTTPClient {
|
|
55
|
+
constructor(remotes = (0, exports.getEmbeddedDiscoverHosts)(polaris_1.PolarisHTTPClient.port), options) {
|
|
56
|
+
super(remotes, options);
|
|
57
|
+
}
|
|
58
|
+
// #region Mock monitor
|
|
59
|
+
/**
|
|
60
|
+
* HTTP 后端默认没有部署上报模块,故移除相关实现
|
|
61
|
+
* @returns always `false`
|
|
62
|
+
*/
|
|
63
|
+
async serviceStatistics() {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* HTTP 后端默认没有部署上报模块,故移除相关实现
|
|
68
|
+
* @returns always `false`
|
|
69
|
+
*/
|
|
70
|
+
async registryCache() {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* HTTP 后端默认没有部署上报模块,故移除相关实现
|
|
75
|
+
* @returns always `false`
|
|
76
|
+
*/
|
|
77
|
+
async apiStatistics() {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* HTTP 后端默认没有部署上报模块,故移除相关实现
|
|
82
|
+
* @returns always `false`
|
|
83
|
+
*/
|
|
84
|
+
async systemConfig() {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* HTTP 后端默认没有部署上报模块,故移除相关实现
|
|
89
|
+
* @returns always `false`
|
|
90
|
+
*/
|
|
91
|
+
async statusChangelog() {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.PolarisHTTPClient = PolarisHTTPClient;
|
|
96
|
+
class PolarisGRPCClient extends polaris_1.PolarisGRPCClient {
|
|
97
|
+
constructor(remotes = (0, exports.getEmbeddedDiscoverHosts)(polaris_1.PolarisGRPCClient.port), options) {
|
|
98
|
+
super(remotes, options);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.PolarisGRPCClient = PolarisGRPCClient;
|
|
102
|
+
exports.PolarisServerClient = [PolarisGRPCClient].find(client => client.isSupported()) || PolarisHTTPClient;
|
|
103
|
+
// #endregion
|
|
104
|
+
// #region API
|
|
105
|
+
const { NamingService: NamingServiceType } = polaris_1.plugins.PluginType;
|
|
106
|
+
class Consumer extends polaris_1.Consumer {
|
|
107
|
+
/**
|
|
108
|
+
* Create Consumer
|
|
109
|
+
* @param plugins 插件(可选)
|
|
110
|
+
* @param options 配置参数(可选)
|
|
111
|
+
*/
|
|
112
|
+
constructor(plugins = {}, options = {}) {
|
|
113
|
+
super(plugins[NamingServiceType]
|
|
114
|
+
? plugins : Object.assign(Object.assign({}, plugins), { [NamingServiceType]: new exports.PolarisServerClient() }), options);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.Consumer = Consumer;
|
|
118
|
+
class Provider extends polaris_1.Provider {
|
|
119
|
+
/**
|
|
120
|
+
* Create Provider
|
|
121
|
+
* @param plugins 插件(可选)
|
|
122
|
+
* @param options 配置参数(可选)
|
|
123
|
+
*/
|
|
124
|
+
constructor(plugins = {}, options = {}) {
|
|
125
|
+
super(plugins[NamingServiceType]
|
|
126
|
+
? plugins : Object.assign(Object.assign({}, plugins), { [NamingServiceType]: new exports.PolarisServerClient() }), options);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.Provider = Provider;
|
|
130
|
+
class Limiter extends polaris_1.Limiter {
|
|
131
|
+
/**
|
|
132
|
+
* Create Limiter
|
|
133
|
+
* @param plugins 插件(可选)
|
|
134
|
+
* @param options 配置参数(可选)
|
|
135
|
+
*/
|
|
136
|
+
constructor(plugins = {}, options = {}) {
|
|
137
|
+
super(plugins[NamingServiceType]
|
|
138
|
+
? plugins : Object.assign(Object.assign({}, plugins), { [NamingServiceType]: new exports.PolarisServerClient() }), options);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
exports.Limiter = Limiter;
|
|
142
|
+
// #endregion
|
|
143
|
+
// #endregion
|
|
144
|
+
// #endregion
|
|
145
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAOmB;AAEnB,4CAA0B;AAE1B,wBAAwB;AACxB,IAAK,eAKJ;AALD,WAAK,eAAe;IAClB,WAAW;IACX,yDAAM,CAAA;IACN,WAAW;IACX,uDAAK,CAAA;AACP,CAAC,EALI,eAAe,KAAf,eAAe,QAKnB;AAED,MAAM,cAAc,GAAG;IACrB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AC,CAAC,iCACnC,OAAO,KACV,CAAC,iBAAiB,CAAC,EAAE,IAAI,2BAAmB,EAAE,GAC/C,EAAE,OAAO,CACb,CAAC;IACJ,CAAC;CACF;AAfD,0BAeC;AACD,aAAa;AAEb,aAAa;AACb,aAAa"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Location } from "./location";
|
|
2
|
+
import { Metadata } from "./metadata";
|
|
3
|
+
/**
|
|
4
|
+
* 实例状态
|
|
5
|
+
*
|
|
6
|
+
* ```
|
|
7
|
+
* STD:
|
|
8
|
+
* +---------------------------------------(`CircuitBreaker`)-----------------------------------------------+
|
|
9
|
+
* | |
|
|
10
|
+
* v +
|
|
11
|
+
* Fused +---(`OutlierDetector`)---> HalfOpen +---(`LoadBalancer`)---> HalfClose +---(`CircuitBreaker`)---> Normal
|
|
12
|
+
* ^ +
|
|
13
|
+
* | |
|
|
14
|
+
* +------------------------(`CircuitBreaker`)---------------------------+
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const enum InstanceStatus {
|
|
18
|
+
/**
|
|
19
|
+
* 正常
|
|
20
|
+
*/
|
|
21
|
+
Normal = 0,
|
|
22
|
+
/**
|
|
23
|
+
* 半打开
|
|
24
|
+
*
|
|
25
|
+
* 各周期只选出极少次,负责探活
|
|
26
|
+
*/
|
|
27
|
+
HalfOpen = 1,
|
|
28
|
+
/**
|
|
29
|
+
* 半关闭
|
|
30
|
+
*
|
|
31
|
+
* 不在任何模块中被选出,但计算调用结果
|
|
32
|
+
*/
|
|
33
|
+
HalfClose = 2,
|
|
34
|
+
/**
|
|
35
|
+
* 熔断
|
|
36
|
+
*
|
|
37
|
+
* 不在任何模块中被选出
|
|
38
|
+
*/
|
|
39
|
+
Fused = 3
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 实例
|
|
43
|
+
*/
|
|
44
|
+
export interface Instance {
|
|
45
|
+
/**
|
|
46
|
+
* 唯一 ID
|
|
47
|
+
*/
|
|
48
|
+
readonly id: string;
|
|
49
|
+
/**
|
|
50
|
+
* vpc_id
|
|
51
|
+
*/
|
|
52
|
+
vpcId: string;
|
|
53
|
+
/**
|
|
54
|
+
* IP 或 域名
|
|
55
|
+
*/
|
|
56
|
+
host: string;
|
|
57
|
+
/**
|
|
58
|
+
* 端口号
|
|
59
|
+
*/
|
|
60
|
+
port: number;
|
|
61
|
+
/**
|
|
62
|
+
* 协议信息
|
|
63
|
+
*/
|
|
64
|
+
protocol: string;
|
|
65
|
+
/**
|
|
66
|
+
* 静态权重值, 0-1000
|
|
67
|
+
*/
|
|
68
|
+
staticWeight: number;
|
|
69
|
+
/**
|
|
70
|
+
* 动态权重值
|
|
71
|
+
*/
|
|
72
|
+
dynamicWeight: number;
|
|
73
|
+
/**
|
|
74
|
+
* 当前状态
|
|
75
|
+
*/
|
|
76
|
+
status: InstanceStatus;
|
|
77
|
+
/**
|
|
78
|
+
* 元数据信息
|
|
79
|
+
*/
|
|
80
|
+
metadata: Metadata;
|
|
81
|
+
/**
|
|
82
|
+
* 优先级
|
|
83
|
+
*/
|
|
84
|
+
priority: number;
|
|
85
|
+
/**
|
|
86
|
+
* 版本号
|
|
87
|
+
*/
|
|
88
|
+
version: string;
|
|
89
|
+
/**
|
|
90
|
+
* 逻辑区域
|
|
91
|
+
*/
|
|
92
|
+
logicSet: string;
|
|
93
|
+
/**
|
|
94
|
+
* 地理位置
|
|
95
|
+
*/
|
|
96
|
+
location: Location;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 实例静态拷贝
|
|
100
|
+
* @param from 源实例
|
|
101
|
+
* @param to 目标实例
|
|
102
|
+
*/
|
|
103
|
+
export declare const instanceCopy: (from: Instance, to: Instance) => void;
|
|
104
|
+
/**
|
|
105
|
+
* 判断实例是否可被选取
|
|
106
|
+
* @param instance 实例
|
|
107
|
+
* @returns 是否可选取
|
|
108
|
+
*/
|
|
109
|
+
export declare const isChoosableInstance: (instance: Instance) => boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isChoosableInstance = exports.instanceCopy = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 所需拷贝的静态属性值
|
|
6
|
+
* note:这里不拷贝 `status` 与 `dynamicWeight`,以 `id` 进行关联
|
|
7
|
+
*/
|
|
8
|
+
const kStaticProps = [
|
|
9
|
+
"vpcId",
|
|
10
|
+
"host",
|
|
11
|
+
"port",
|
|
12
|
+
"metadata",
|
|
13
|
+
"protocol",
|
|
14
|
+
"staticWeight",
|
|
15
|
+
"priority",
|
|
16
|
+
"version",
|
|
17
|
+
"logicSet",
|
|
18
|
+
"location"
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* 实例静态拷贝
|
|
22
|
+
* @param from 源实例
|
|
23
|
+
* @param to 目标实例
|
|
24
|
+
*/
|
|
25
|
+
const instanceCopy = (from, to) => {
|
|
26
|
+
kStaticProps.forEach((key) => {
|
|
27
|
+
to[key] = from[key];
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
exports.instanceCopy = instanceCopy;
|
|
31
|
+
/**
|
|
32
|
+
* 判断实例是否可被选取
|
|
33
|
+
* @param instance 实例
|
|
34
|
+
* @returns 是否可选取
|
|
35
|
+
*/
|
|
36
|
+
const isChoosableInstance = (instance) => (instance.status === 1 /* HalfOpen */ || instance.status === 0 /* Normal */);
|
|
37
|
+
exports.isChoosableInstance = isChoosableInstance;
|
|
38
|
+
//# sourceMappingURL=instance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance.js","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":";;;AAmHA;;;GAGG;AACH,MAAM,YAAY,GAAoC;IACpD,OAAO;IACP,MAAM;IACN,MAAM;IACN,UAAU;IACV,UAAU;IACV,cAAc;IACd,UAAU;IACV,SAAS;IACT,UAAU;IACV,UAAU;CACX,CAAC;AACF;;;;GAIG;AACI,MAAM,YAAY,GAAG,CAAC,IAAc,EAAE,EAAY,EAAQ,EAAE;IACjE,YAAY,CAAC,OAAO,CAAC,CAA2B,GAAM,EAAE,EAAE;QACxD,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAJW,QAAA,YAAY,gBAIvB;AAEF;;;;GAIG;AACI,MAAM,mBAAmB,GAAG,CAAC,QAAkB,EAAW,EAAE,CAAC,CAClE,QAAQ,CAAC,MAAM,qBAA4B,IAAI,QAAQ,CAAC,MAAM,mBAA0B,CACzF,CAAC;AAFW,QAAA,mBAAmB,uBAE9B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface InternalBucketOptions {
|
|
2
|
+
/**
|
|
3
|
+
* 令牌桶空闲回收,判定周期数
|
|
4
|
+
*/
|
|
5
|
+
idlePeriod: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 基础令牌桶
|
|
9
|
+
* 桶内剩余可用令牌,不会增加
|
|
10
|
+
*/
|
|
11
|
+
export declare class BasicBucket {
|
|
12
|
+
protected total: number;
|
|
13
|
+
protected partition: number;
|
|
14
|
+
private overflow;
|
|
15
|
+
protected remains: number;
|
|
16
|
+
protected capacity: number;
|
|
17
|
+
constructor(total: number, partition: number, overflow?: boolean);
|
|
18
|
+
get partitionTokens(): number;
|
|
19
|
+
get remainingTokens(): number;
|
|
20
|
+
setPartition(partition: number): void;
|
|
21
|
+
consume(tokens: number, preroll: boolean): boolean;
|
|
22
|
+
drain(): number;
|
|
23
|
+
private recalculate;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 内部令牌桶
|
|
27
|
+
* 桶内剩余可用令牌,由内部新增
|
|
28
|
+
*/
|
|
29
|
+
export declare class InternalBucket extends BasicBucket {
|
|
30
|
+
private duration;
|
|
31
|
+
private options;
|
|
32
|
+
private isAccessed;
|
|
33
|
+
private idlePeriods;
|
|
34
|
+
private period;
|
|
35
|
+
private timer;
|
|
36
|
+
private sleepTime?;
|
|
37
|
+
constructor(total: number, partition: number, overflow: boolean | undefined, duration: number, options: InternalBucketOptions);
|
|
38
|
+
get currentPeriod(): number;
|
|
39
|
+
consume(tokens: number, preroll: boolean): boolean;
|
|
40
|
+
private onWakUp;
|
|
41
|
+
private wake;
|
|
42
|
+
private sleep;
|
|
43
|
+
private onTimeout;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* 外部令牌桶
|
|
47
|
+
* 桶内剩余可用令牌,由外部调整
|
|
48
|
+
*/
|
|
49
|
+
export declare class ExternalBucket extends BasicBucket {
|
|
50
|
+
update(value: number): void;
|
|
51
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExternalBucket = exports.InternalBucket = exports.BasicBucket = void 0;
|
|
4
|
+
const process_1 = require("process");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
/**
|
|
7
|
+
* 基础令牌桶
|
|
8
|
+
* 桶内剩余可用令牌,不会增加
|
|
9
|
+
*/
|
|
10
|
+
class BasicBucket {
|
|
11
|
+
constructor(total, partition, overflow = false) {
|
|
12
|
+
this.total = total;
|
|
13
|
+
this.partition = partition;
|
|
14
|
+
this.overflow = overflow;
|
|
15
|
+
this.capacity = ~~(this.total / this.partition);
|
|
16
|
+
this.remains = this.capacity;
|
|
17
|
+
}
|
|
18
|
+
get partitionTokens() {
|
|
19
|
+
return this.capacity;
|
|
20
|
+
}
|
|
21
|
+
get remainingTokens() {
|
|
22
|
+
return this.remains;
|
|
23
|
+
}
|
|
24
|
+
setPartition(partition) {
|
|
25
|
+
this.recalculate(partition);
|
|
26
|
+
this.partition = partition;
|
|
27
|
+
this.capacity = ~~(this.total / this.partition);
|
|
28
|
+
}
|
|
29
|
+
consume(tokens, preroll) {
|
|
30
|
+
if (!(this.remains >= tokens)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (!preroll) {
|
|
34
|
+
this.remains -= tokens;
|
|
35
|
+
/*
|
|
36
|
+
* note:
|
|
37
|
+
* 由于 `tokens` 可能为负值,
|
|
38
|
+
* 导致计算出的 `remains` 超过总值 `capacity`
|
|
39
|
+
*/
|
|
40
|
+
if (!this.overflow && this.remains > this.capacity) {
|
|
41
|
+
this.remains = this.capacity;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
drain() {
|
|
47
|
+
const { remains } = this;
|
|
48
|
+
this.remains = 0;
|
|
49
|
+
return remains;
|
|
50
|
+
}
|
|
51
|
+
recalculate(partition) {
|
|
52
|
+
let remains = ~~(this.total / partition) - (this.capacity - this.remains);
|
|
53
|
+
if (remains < 0) {
|
|
54
|
+
remains = 0;
|
|
55
|
+
}
|
|
56
|
+
this.remains = remains;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.BasicBucket = BasicBucket;
|
|
60
|
+
/**
|
|
61
|
+
* 内部令牌桶
|
|
62
|
+
* 桶内剩余可用令牌,由内部新增
|
|
63
|
+
*/
|
|
64
|
+
class InternalBucket extends BasicBucket {
|
|
65
|
+
constructor(total, partition, overflow = false, duration, options) {
|
|
66
|
+
super(total, partition, overflow);
|
|
67
|
+
this.duration = duration;
|
|
68
|
+
this.options = options;
|
|
69
|
+
this.isAccessed = false;
|
|
70
|
+
this.idlePeriods = 0;
|
|
71
|
+
this.period = 0;
|
|
72
|
+
this.onWakUp(false);
|
|
73
|
+
}
|
|
74
|
+
get currentPeriod() {
|
|
75
|
+
return this.period;
|
|
76
|
+
}
|
|
77
|
+
consume(tokens, preroll) {
|
|
78
|
+
this.isAccessed = true;
|
|
79
|
+
this.wake();
|
|
80
|
+
return super.consume(tokens, preroll);
|
|
81
|
+
}
|
|
82
|
+
// #region Wake-sleep
|
|
83
|
+
onWakUp(immediate) {
|
|
84
|
+
if (immediate) {
|
|
85
|
+
this.onTimeout();
|
|
86
|
+
}
|
|
87
|
+
this.timer = setInterval(() => this.onTimeout.bind(this), this.duration).unref();
|
|
88
|
+
}
|
|
89
|
+
wake() {
|
|
90
|
+
if (this.timer === undefined) {
|
|
91
|
+
if (this.sleepTime === undefined) {
|
|
92
|
+
(0, utils_1.UNREACHABLE)();
|
|
93
|
+
}
|
|
94
|
+
const elapsedTime = Math.floor(((0, process_1.uptime)() - this.sleepTime) * utils_1.kSeconds);
|
|
95
|
+
this.period += Math.floor(elapsedTime / this.duration);
|
|
96
|
+
const interval = elapsedTime % this.duration;
|
|
97
|
+
if (interval === 0) {
|
|
98
|
+
this.onWakUp(false);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
this.timer = setTimeout(this.onWakUp.bind(this, true), interval).unref();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
sleep() {
|
|
106
|
+
if (this.timer !== undefined) {
|
|
107
|
+
clearInterval(this.timer);
|
|
108
|
+
this.timer = undefined;
|
|
109
|
+
}
|
|
110
|
+
this.sleepTime = (0, process_1.uptime)();
|
|
111
|
+
this.idlePeriods = 0;
|
|
112
|
+
this.isAccessed = false;
|
|
113
|
+
}
|
|
114
|
+
// #endregion
|
|
115
|
+
onTimeout() {
|
|
116
|
+
this.period += 1;
|
|
117
|
+
this.remains = this.capacity;
|
|
118
|
+
if (this.isAccessed) {
|
|
119
|
+
this.idlePeriods = 0;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this.idlePeriods += 1;
|
|
123
|
+
}
|
|
124
|
+
this.isAccessed = false;
|
|
125
|
+
/*
|
|
126
|
+
* 为了降低消耗,当超过 `this.options.idlePeriod` 周期没有访问时,
|
|
127
|
+
* 自动进入休眠状态(停止一切定时器)
|
|
128
|
+
*
|
|
129
|
+
* note:
|
|
130
|
+
* 如外部不再强引用(WeakMap 为弱引用)当前对象,当进入休眠状态后,当前对象会被自动回收
|
|
131
|
+
*/
|
|
132
|
+
if (this.idlePeriods > this.options.idlePeriod) {
|
|
133
|
+
this.sleep();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.InternalBucket = InternalBucket;
|
|
138
|
+
/**
|
|
139
|
+
* 外部令牌桶
|
|
140
|
+
* 桶内剩余可用令牌,由外部调整
|
|
141
|
+
*/
|
|
142
|
+
class ExternalBucket extends BasicBucket {
|
|
143
|
+
update(value) {
|
|
144
|
+
let remains = ~~((this.total - value) / this.partition);
|
|
145
|
+
if (remains < 0) {
|
|
146
|
+
remains = 0;
|
|
147
|
+
}
|
|
148
|
+
this.remains = remains;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.ExternalBucket = ExternalBucket;
|
|
152
|
+
//# sourceMappingURL=bucket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bucket.js","sourceRoot":"","sources":["../../src/limiter/bucket.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAEjC,oCAAiD;AASjD;;;GAGG;AACH,MAAa,WAAW;IAItB,YAAsB,KAAa,EAAY,SAAiB,EAAU,WAAW,KAAK;QAApE,UAAK,GAAL,KAAK,CAAQ;QAAY,cAAS,GAAT,SAAS,CAAQ;QAAU,aAAQ,GAAR,QAAQ,CAAQ;QACxF,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,YAAY,CAAC,SAAiB;QAC5B,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAC5B,IAAI,CAAC,SA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,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AARD,wCAQC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { GlobalOptions } from "../global";
|
|
2
|
+
import { LoggerOptions } from "../logging";
|
|
3
|
+
import { Metadata } from "../metadata";
|
|
4
|
+
import { PluginList, PluginType } from "../plugins";
|
|
5
|
+
import { LocalRegistryOptions } from "../registry";
|
|
6
|
+
import { SkeletonClass } from "../skeleton";
|
|
7
|
+
import { RequireKeys } from "../utils";
|
|
8
|
+
import { Quota, RatelimitOptions } from "./ratelimit";
|
|
9
|
+
declare type LimiterPluginList = Pick<PluginList, PluginType.LocalRegistry | PluginType.NamingService | PluginType.RatelimitService | PluginType.TrafficShaping | PluginType.TraceLogging | PluginType.StatReporter>;
|
|
10
|
+
export declare type OptionalLimiterPluginList = RequireKeys<Partial<LimiterPluginList>, PluginType.NamingService>;
|
|
11
|
+
export declare type LimiterOptions = GlobalOptions & RatelimitOptions & LoggerOptions & LocalRegistryOptions;
|
|
12
|
+
export interface AcquireResponse {
|
|
13
|
+
/**
|
|
14
|
+
* 唯一 ID
|
|
15
|
+
* 用于优化下次查询性能
|
|
16
|
+
*/
|
|
17
|
+
readonly id?: string;
|
|
18
|
+
/**
|
|
19
|
+
* 配额
|
|
20
|
+
*/
|
|
21
|
+
readonly quotas: Quota[];
|
|
22
|
+
}
|
|
23
|
+
declare const kRatelimit: unique symbol;
|
|
24
|
+
declare const kRegistry: unique symbol;
|
|
25
|
+
declare const kCurrentInstances: unique symbol;
|
|
26
|
+
declare const KMaxInstances: unique symbol;
|
|
27
|
+
export declare class Limiter extends SkeletonClass<LimiterPluginList> {
|
|
28
|
+
/**
|
|
29
|
+
* note:
|
|
30
|
+
* 由于类包含专用标识符时,`super` 调用必须是构造函数中的第一个语句。
|
|
31
|
+
* 所以这里采用 `Symbol` 来实现 __私有静态属性__
|
|
32
|
+
*/
|
|
33
|
+
private static [kCurrentInstances];
|
|
34
|
+
private static [KMaxInstances];
|
|
35
|
+
/**
|
|
36
|
+
* 当前可实例化的最大次数
|
|
37
|
+
*/
|
|
38
|
+
static get maxInstances(): number;
|
|
39
|
+
/**
|
|
40
|
+
* 设置可实例化的最大次数
|
|
41
|
+
* @param n 最大次数
|
|
42
|
+
*/
|
|
43
|
+
static setMaxInstances(n: number): void;
|
|
44
|
+
private readonly [kRatelimit];
|
|
45
|
+
private readonly [kRegistry];
|
|
46
|
+
/**
|
|
47
|
+
* Create Limiter
|
|
48
|
+
* @param plugins 插件
|
|
49
|
+
* @param options 配置参数(可选)
|
|
50
|
+
*/
|
|
51
|
+
constructor(plugins: OptionalLimiterPluginList, options?: Partial<LimiterOptions>);
|
|
52
|
+
/**
|
|
53
|
+
* 销毁(释放)所占资源
|
|
54
|
+
*
|
|
55
|
+
* @description
|
|
56
|
+
* dispose order:
|
|
57
|
+
* Ratelimit -> Registry -> [plguins]
|
|
58
|
+
*
|
|
59
|
+
* @param sync 是否同步释放(可选)
|
|
60
|
+
*/
|
|
61
|
+
dispose(sync?: boolean): void;
|
|
62
|
+
/**
|
|
63
|
+
* 通过条件获取配额分配对象
|
|
64
|
+
* @param namespace 命名空间
|
|
65
|
+
* @param service 服务名
|
|
66
|
+
* @param amount 请求的配额数
|
|
67
|
+
* @param cluster 集群名(可选)
|
|
68
|
+
* @param labels 标签集合(可选)
|
|
69
|
+
* @param id 唯一 ID(可选)
|
|
70
|
+
*/
|
|
71
|
+
acquire(namespace: string, service: string, amount: number, cluster?: string, labels?: Metadata, id?: string): Promise<AcquireResponse>;
|
|
72
|
+
}
|
|
73
|
+
export {};
|