本文整理汇总了TypeScript中@restorecommerce/service-config.service-config函数的典型用法代码示例。如果您正苦于以下问题:TypeScript service-config函数的具体用法?TypeScript service-config怎么用?TypeScript service-config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了service-config函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: before
before(async function setup() {
cfg = sconfig(process.cwd() + '/test');
const logger = new chassis.Logger(cfg.get('logger'));
events = new Events(cfg.get('events:kafka'), logger);
await events.start();
const topics = cfg.get('events:kafka:topics');
testTopic = events.topic(cfg.get('events:kafka:topics:test.resource:topic'));
commandTopic = events.topic(cfg.get('events:kafka:topics:command:topic'));
// subscribe all response events
for (let eventName of cfg.get('events:kafka:topics:command:events')) {
await commandTopic.on(eventName, eventListener);
}
server = new Server(cfg.get('server'), logger);
db = await database.get(cfg.get('database:arango'), logger);
await db.truncate();
const config = cfg.get();
delete config.database.nedb; // not supported in default implementation
const cis = new CommandInterface(server, config, logger, events);
await server.bind('commandinterface', cis);
await server.start();
const client = new Client(cfg.get('client:commandinterface'), logger);
service = await client.connect();
});
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:29,代码来源:command_test.ts
示例2: Promise
return new Promise((resolve, reject) => {
readConfig(baseDir, logger, (err, cfg) => {
if (err)
reject(err);
config = cfg;
resolve(cfg);
});
});
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:8,代码来源:index.ts
示例3: throwErrorOnMissingConfig
async function throwErrorOnMissingConfig() {
await config.load(process.cwd() + '/test');
cfg = await config.get();
const logger = new Logger(cfg.get('logger'));
cfg = sconfig(process.cwd() + '/test', logger);
cfg.set('server:services', undefined);
(() => {
server = new Server(cfg.get('server'));
}).should.throw('missing services configuration');
});
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:10,代码来源:microservice_test.ts
示例4: testStoredOffsetValue
describe('offsetStore', () => {
let events: Events;
const topicName = 'test';
let topic: Topic;
let offsetStore: OffsetStore;
const eventName = 'testCreated';
const testMessage = { value: 'testValue', count: 1 };
const cfg = sconfig(process.cwd() + '/test');
const logger = new Logger(cfg.get('logger'));
beforeEach(async function start() {
events = new Events(cfg.get('events:kafka'), logger);
await events.start();
});
afterEach(async function stop() {
await offsetStore.stop();
await events.stop();
});
it('should emit an event and verify the stored offset value from redis',
async function testStoredOffsetValue() {
this.timeout(10000);
offsetStore = new OffsetStore(events, cfg, logger);
topic = await (events.topic(topicName));
const listener = function listener(message, context) {
testMessage.value.should.equal(message.value);
testMessage.count.should.equal(message.count);
};
// get the current offsetValue for 'test' topic before emitting message
const currentOffset = await topic.$offset(-1);
// emit message to kafka
await topic.on(eventName, listener);
await topic.emit(eventName, testMessage);
const newOffset = await new Promise((resolve, reject) => {
setTimeout(async () => {
const offsetValue = await offsetStore.getOffset(topicName);
resolve(offsetValue);
}, 8000);
});
should.exist(newOffset);
Number(newOffset).should.equal(currentOffset + 1);
});
it('should consume a previously emitted message from Kafka',
async function testConsumeListener() {
this.timeout(4000);
// emit testMessage to kafka
topic = await events.topic(topicName);
await topic.emit(eventName, testMessage);
// start offsetTracker subscribing to previous offset value read
// from redis and consume the above message
offsetStore = new OffsetStore(events, cfg, logger);
const listener = async function listener(message, context) {
testMessage.value.should.equal(message.value);
testMessage.count.should.equal(message.count);
};
// get the current offsetValue for 'test' topic before emitting message
let startingOffset = await offsetStore.getOffset(topicName);
await topic.on(eventName, listener, { startingOffset });
// wait for 2sec so that message is consumed and
// test is not ended immediately
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, 2000);
});
});
});
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:72,代码来源:kafka_offsetstore_test.ts
注:本文中的@restorecommerce/service-config.service-config函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论