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
This commit is contained in:
ssddi456
2019-11-19 15:50:32 -08:00
committed by Pranav Senthilnathan
parent 0ed8c63f76
commit 13894c24ab
4 changed files with 107 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
// Type definitions for yog-ral 0.20
// Project: https://gitlab.baidu.com/fex/node-ral
// Definitions by: ssddi456 <https://github.com/ssddi456>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
export * from 'node-ral';
+24
View File
@@ -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"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+73
View File
@@ -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');