Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
retry-agent.js36 linesDownload Raw Back to dispatcher
1'use strict'
2
3const Dispatcher = require('./dispatcher')
4const RetryHandler = require('../handler/retry-handler')
5
6class RetryAgent extends Dispatcher {
7  #agent = null
8  #options = null
9  constructor (agent, options = {}) {
10    super(options)
11    this.#agent = agent
12    this.#options = options
13  }
14
15  dispatch (opts, handler) {
16    const retry = new RetryHandler({
17      ...opts,
18      retryOptions: this.#options
19    }, {
20      dispatch: this.#agent.dispatch.bind(this.#agent),
21      handler
22    })
23    return this.#agent.dispatch(opts, retry)
24  }
25
26  close () {
27    return this.#agent.close()
28  }
29
30  destroy () {
31    return this.#agent.destroy()
32  }
33}
34
35module.exports = RetryAgent
36 
codekingpro/portable-devtools · Team Ai