• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript logger.info函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@restorecommerce/logger.info函数的典型用法代码示例。如果您正苦于以下问题:TypeScript info函数的具体用法?TypeScript info怎么用?TypeScript info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了info函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: reset

  /**
   * Reset system data related to a service. Default implementation truncates
   * a set of ArangoDB instances, using the chassis-srv database provider.
   */
  async reset(): Promise<any> {
    this.logger.info('reset process started');
    if (this.health.status !== ServingStatus.NOT_SERVING) {
      this.logger.warn('reset process starting while server is serving');
    }

    let errorMsg = null;
    try {
      const dbCfgs = this.config.database;
      const dbCfgNames = _.keys(dbCfgs);
      for (let i = 0; i < dbCfgNames.length; i += 1) {
        const dbCfgName = dbCfgNames[i];
        const dbCfg = dbCfgs[dbCfgName];
        const db = await database.get(dbCfg, this.logger);
        switch (dbCfg.provider) {
          case 'arango':
            await db.truncate();
            this.logger.info(`arangodb ${dbCfg.database} truncated`);
            break;
          default:
            this.logger.error(
              `unsupported database provider ${dbCfg.provider} in database config ${dbCfgName}`);
            break;
        }
      }
    } catch (err) {
      this.logger.error('Unexpected error while resetting the system', err.message);
      errorMsg = err.message;
    }

    const eventObject = {
      services: _.keys(this.service),
      payload: null
    };

    if (errorMsg) {
      eventObject.payload = this.encodeMsg({
        error: errorMsg
      });
    } else {
      eventObject.payload = this.encodeMsg({
        status: 'Reset concluded successfully'
      });
    }
    await this.commandTopic.emit('resetResponse', eventObject);

    this.logger.info('reset process ended');

    if (errorMsg) {
      return {
        error: errorMsg
      };
    }
    return {};
  }
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:59,代码来源:index.ts


示例2: startToReceiveRestoreMessages

  private startToReceiveRestoreMessages(restoreTopic: Topic,
    drainEvent: Function): any {
    const asyncQueue = async.queue((msg, done) => {
      setImmediate(() => drainEvent(msg, err => {
        if (err) {
          done(err);
        } else {
          done();
        }
      }));
    }, 1);

    asyncQueue.drain = () => {
      // commit state first, before resuming
      this.logger.verbose('Committing offsets upon async queue drain');
      new Promise((resolve, reject) => {
        restoreTopic.consumer.commit((err, data) => {
          if (err) {
            return reject(err);
          }
          resolve(data);
        });
      }).then(() => {
        this.logger.info('Offset committed successfully');
      }).catch((err) => { });
    };
    this.logger.info('Async queue draining started.');
    return asyncQueue;
  }
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:29,代码来源:index.ts


示例3: getOffset

 /**
  * get the offset value for the topic from redis
  * @param  {string} topic Topic name
  * @return {object}
  */
 async getOffset(topicName: string): Promise<number> {
   const redisKey = this.config.get('events:kafka:clientId') + ':' + topicName;
   const offsetValue = await new Promise<number>((resolve, reject) => {
     this.redisClient.get(redisKey, (err, response) => {
       if (err) {
         reject(err);
       }
       resolve(response);
     });
   });
   this.logger.info('The offset value retreived from redis for topic is:',
     { topicName, offsetValue });
   return offsetValue;
 }
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:19,代码来源:index.ts


示例4: constructor

  constructor(server: Server, config: any, logger: Logger, events: Events) {
    if (_.isNil(events)) {
      if (logger.error) {
        logger.error('No Kafka client was provided. Disabling all commands.');
        return;
      }
    }
    if (!_.has(config, 'server.services')) {
      throw new Error('missing config server.services');
    }

    this.config = config;
    this.logger = logger;

    if (!_.has(this.config, 'events')
      || !_.has(this.config.events, 'kafka')
      || !_.has(this.config.events.kafka, 'topics')
      || !_.has(this.config.events.kafka.topics, 'command')) {
      throw new Error('Commands topic configuration was not provided.');
    }

    this.kafkaEvents = events;

    // Health
    this.health = {
      status: ServingStatus.UNKNOWN,
    };
    this.service = {};
    const service = this.service;
    const health = this.health;
    _.forEach(config.server.services, (serviceCfg, serviceName) => {
      service[serviceName] = {
        bound: false,
        transport: {},
      };
    });
    server.on('bound', (serviceName) => {
      service[serviceName].bound = true;
      health.status = ServingStatus.NOT_SERVING;
    });
    server.on('serving', (transports) => {
      health.status = ServingStatus.SERVING;
      _.forEach(transports, (transport, transportName) => {
        _.forEach(service, (srv, serviceName) => {
          service[serviceName].transport[transportName] = ServingStatus.SERVING;
        });
      });
    });
    server.on('stopped', (transports) => {
      health.status = ServingStatus.NOT_SERVING;
      _.forEach(transports, (transport, transportName) => {
        _.forEach(service, (srv, serviceName) => {
          service[serviceName].transport[transportName] = ServingStatus.NOT_SERVING;
        });
      });
    });

    // list of available commands
    this.commands = {
      reset: this.reset,
      restore: this.restore,
      reconfigure: this.reconfigure,
      health_check: this.check,
      version: this.version
    };
    const topicCfg = config.events.kafka.topics.command;
    this.commandTopic = events.topic(topicCfg.topic);
    // check for buffer fields
    this.bufferedCollection = new Map<string, string>();
    if (this.config.fieldHandlers && this.config.fieldHandlers.bufferFields) {
      for (let bufferedCollection in this.config.fieldHandlers.bufferFields) {
        this.bufferedCollection.set(bufferedCollection,
          this.config.fieldHandlers.bufferFields[bufferedCollection]);
      }
      this.logger.info('Buffered collections are:', this.bufferedCollection);
    }
  }
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:77,代码来源:index.ts


示例5:

 }).then(() => {
   this.logger.info('Offset committed successfully');
 }).catch((err) => { });
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:3,代码来源:index.ts


示例6: reconfigure

 /**
  * Reconfigure service
  * @param call
  * @param context
  */
 reconfigure(): any {
   this.logger.info('reconfigure is not implemented');
   throw new errors.Unimplemented('reconfigure is not implemented');
 }
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:9,代码来源:index.ts



注:本文中的@restorecommerce/logger.info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript logger.warn函数代码示例发布时间:2022-05-28
下一篇:
TypeScript kafka-client.Topic类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap