From 13894c24ab9ddc2c58cef293d33bf4880b6dac80 Mon Sep 17 00:00:00 2001 From: ssddi456 Date: Wed, 20 Nov 2019 07:50:32 +0800 Subject: [PATCH] add yog-ral (#40410) * add yog-ral * Update index.d.ts * Update index.d.ts * Update index.d.ts * Update tslint.json * Update tslint.json * Update yog-ral-tests.ts * Update yog-ral-tests.ts --- types/yog-ral/index.d.ts | 7 ++++ types/yog-ral/tsconfig.json | 24 +++++++++++ types/yog-ral/tslint.json | 3 ++ types/yog-ral/yog-ral-tests.ts | 73 ++++++++++++++++++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 types/yog-ral/index.d.ts create mode 100644 types/yog-ral/tsconfig.json create mode 100644 types/yog-ral/tslint.json create mode 100644 types/yog-ral/yog-ral-tests.ts diff --git a/types/yog-ral/index.d.ts b/types/yog-ral/index.d.ts new file mode 100644 index 0000000000..c14e72743e --- /dev/null +++ b/types/yog-ral/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for yog-ral 0.20 +// Project: https://gitlab.baidu.com/fex/node-ral +// Definitions by: ssddi456 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +export * from 'node-ral'; diff --git a/types/yog-ral/tsconfig.json b/types/yog-ral/tsconfig.json new file mode 100644 index 0000000000..dc44644a91 --- /dev/null +++ b/types/yog-ral/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "yog-ral-tests.ts" + ] +} diff --git a/types/yog-ral/tslint.json b/types/yog-ral/tslint.json new file mode 100644 index 0000000000..8643075d49 --- /dev/null +++ b/types/yog-ral/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/yog-ral/yog-ral-tests.ts b/types/yog-ral/yog-ral-tests.ts new file mode 100644 index 0000000000..f41a8e9607 --- /dev/null +++ b/types/yog-ral/yog-ral-tests.ts @@ -0,0 +1,73 @@ +import * as yogRal from "yog-ral"; + +class FormConverter extends yogRal.Converter { + pack(config: yogRal.Service, data: {}) { + return new Buffer('123'); + } + unpack(config: yogRal.Service, data: {}) { + return {}; + } + getName() { + return 'form'; + } +} + +class HashringBalance extends yogRal.Balance { + getName() { + return 'hashring'; + } + fetchServer(balanceContext: yogRal.Balance.BalanceContextClass, conf: {}, prevBackend: yogRal.Server): yogRal.Server { + return { + host: '127.0.0.1', + port: 8888, + }; + } +} + +class HttpProtocol extends yogRal.Protocol { + getName() { + return 'http'; + } + _request(config: any, callback: (err: any, data: any) => any) { + callback(new Error(), '123'); + } +} + +class DefaultConfigNormalizer extends yogRal.ConfigNormalizer { + getName() { + return 'default'; + } + needUpdate() { + return false; + } + normalizeConfig(config: any) { + return config; + } +} + +const runner = yogRal.RAL('test', {}); +runner.on('data', () => { + // yeap +}); +runner.doRequest(); + +yogRal.RAL.init(); + +yogRal.RALPromise('test', {}).then; + +yogRal.Config.loadRawConf; +yogRal.Config.load; +yogRal.Config.normalizerManager; +yogRal.Config.normalize; +yogRal.Config.getContext; +yogRal.Config.getConf; +yogRal.Config.clearConf; +yogRal.Config.getConfNames; +yogRal.Config.getRawConf; +yogRal.Config.getUpdateNeededRawConf; +yogRal.Config.enableUpdate; +yogRal.Config.disableUpdate; +yogRal.Config.isAutoUpdateEnabled; + +const logger = yogRal.Logger('some'); +logger.debug('test');