当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript bottleneck.schedule函数代码示例

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


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

示例1: cancelOrder

  public async cancelOrder(orderId: string) {
    const fn = () => this.exchangeConnection.cancelOrder(orderId)
    const res = await this.bottleneck.schedule(fn)

    const debug = { name: 'cancelOrder', req: { orderId }, res }
    logger.debug(JSON.stringify(debug))

    return res
  }
开发者ID:magic8bot,项目名称:magic8bot,代码行数:9,代码来源:exchange.wrapper.ts

示例2: fetchTicker

  public async fetchTicker(symbol: string) {
    const fn = () => this.exchangeConnection.fetchTicker(symbol)
    const res = await this.bottleneck.schedule(fn)

    const debug = { name: 'fetchTicker', req: { symbol }, res }
    logger.debug(JSON.stringify(debug))

    return res
  }
开发者ID:magic8bot,项目名称:magic8bot,代码行数:9,代码来源:exchange.wrapper.ts

示例3: checkOrder

  public async checkOrder(orderId: string): Promise<OrderWithTrades> {
    const fn = () => this.exchangeConnection.fetchOrder(orderId)
    const res: any = await this.bottleneck.schedule(fn)

    const debug = { name: 'checkOrder', req: { orderId }, res }
    logger.debug(JSON.stringify(debug))

    return res
  }
开发者ID:magic8bot,项目名称:magic8bot,代码行数:9,代码来源:exchange.wrapper.ts

示例4: createOrder

  public async createOrder(symbol: string, type: string, side: string, amount: number, price: number): Promise<Order> {
    const fn = () => this.exchangeConnection.createOrder(symbol, type, side, amount, price)
    const res = await this.bottleneck.schedule(fn)

    const debug = { name: 'createOrder', req: { symbol, type, side, amount, price }, res }
    logger.debug(JSON.stringify(debug))

    return res
  }
开发者ID:magic8bot,项目名称:magic8bot,代码行数:9,代码来源:exchange.wrapper.ts

示例5: fetchBalance

  public async fetchBalance() {
    const fn = () => this.exchangeConnection.fetchBalance()
    const res = await this.bottleneck.schedule(fn)

    const debug = { name: 'fetchBalance', req: {}, res }
    logger.debug(JSON.stringify(debug))

    return res
  }
开发者ID:magic8bot,项目名称:magic8bot,代码行数:9,代码来源:exchange.wrapper.ts

示例6: fetchTrades

  public async fetchTrades(symbol: string, start: number) {
    const params = this.adapter.mapTradeParams(start)
    const fn = () => this.exchangeConnection.fetchTrades(symbol, undefined, undefined, params)
    const res = await this.bottleneck.schedule(fn)

    // const debug = { name: 'fetchTrades', req: { symbol, params }, res: res.length }
    // logger.debug(JSON.stringify(debug))

    return res
  }
开发者ID:magic8bot,项目名称:magic8bot,代码行数:10,代码来源:exchange.wrapper.ts

示例7: Bottleneck

let limiter = new Bottleneck(5, 1000, 10, Bottleneck.strategy.LEAK, true);

limiter.submit(withCb, 1, () => {}, (err, result) => {
    let s: string = result;
});

limiter.submitPriority(4, withCb, 1, () => {}, (err, result) => {
    let s: string = result;
});

function withPromise(foo: number, bar: () => void): PromiseLike<string> {
    return Promise.resolve("foo");
}

let foo: Promise<string> = limiter.schedule(withPromise, 1, () => {});
let foo2: Promise<string> = limiter.schedulePriority(4, withPromise, 1, () => {});


let cluster = new Bottleneck.Cluster(5, 1000, 10, Bottleneck.strategy.LEAK, true);

cluster.key("foo").submit(withCb, 1, () => {}, (err, result) => {
    let s: string = result;
});

cluster.key("bar").submitPriority(4, withCb, 1, () => {}, (err, result) => {
    let s: string = result;
});

foo = cluster.key("pizza").schedule(withPromise, 1, () => {});
foo2 = cluster.key("pie").schedulePriority(4, withPromise, 1, () => {});
开发者ID:LauraSchneider,项目名称:personal-website,代码行数:30,代码来源:test.ts


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