1
1
import pRetry from "p-retry" ;
2
- import pQueue from "p-queue" ;
2
+ // import pQueue from "p-queue";
3
3
import { PerformanceMonitor } from "../utils/performance" ;
4
4
import {
5
5
ErrorHandler ,
@@ -23,7 +23,7 @@ interface ReservoirServiceConfig {
23
23
export class ReservoirService {
24
24
private cacheManager ?: MemoryCacheManager ;
25
25
private rateLimiter ?: RateLimiter ;
26
- private queue : pQueue ;
26
+ // private queue: pQueue;
27
27
private maxRetries : number ;
28
28
private batchSize : number ;
29
29
private performanceMonitor : PerformanceMonitor ;
@@ -32,7 +32,8 @@ export class ReservoirService {
32
32
constructor ( config : ReservoirServiceConfig = { } ) {
33
33
this . cacheManager = config . cacheManager ;
34
34
this . rateLimiter = config . rateLimiter ;
35
- this . queue = new pQueue ( { concurrency : config . maxConcurrent || 5 } ) ;
35
+
36
+ // this.queue = new pQueue({ concurrency: config.maxConcurrent || 5 });
36
37
this . maxRetries = config . maxRetries || 3 ;
37
38
this . batchSize = config . batchSize || 20 ;
38
39
this . performanceMonitor = PerformanceMonitor . getInstance ( ) ;
@@ -73,39 +74,35 @@ export class ReservoirService {
73
74
const reservoirApiKey = runtime . getSetting ( "RESERVOIR_API_KEY" ) ;
74
75
75
76
// Make the request with retries
76
- const result = await this . queue . add (
77
- ( ) =>
78
- pRetry (
79
- async ( ) => {
80
- const response = await fetch (
81
- `https://api.reservoir.tools${ endpoint } ?${ new URLSearchParams (
82
- params
83
- ) . toString ( ) } `,
84
- {
85
- headers : {
86
- "x-api-key" : reservoirApiKey ,
87
- } ,
88
- }
89
- ) ;
90
-
91
- if ( ! response . ok ) {
92
- throw new Error (
93
- `Reservoir API error: ${ response . status } `
94
- ) ;
95
- }
96
-
97
- return response . json ( ) ;
98
- } ,
77
+ const result = await pRetry (
78
+ async ( ) => {
79
+ const response = await fetch (
80
+ `https://api.reservoir.tools${ endpoint } ?${ new URLSearchParams (
81
+ params
82
+ ) . toString ( ) } `,
99
83
{
100
- retries : this . maxRetries ,
101
- onFailedAttempt : ( error ) => {
102
- console . error (
103
- `Attempt ${ error . attemptNumber } failed. ${ error . retriesLeft } retries left.`
104
- ) ;
84
+ headers : {
85
+ "x-api-key" : reservoirApiKey ,
105
86
} ,
106
87
}
107
- ) ,
108
- { priority }
88
+ ) ;
89
+
90
+ if ( ! response . ok ) {
91
+ throw new Error (
92
+ `Reservoir API error: ${ response . status } `
93
+ ) ;
94
+ }
95
+
96
+ return response . json ( ) ;
97
+ } ,
98
+ {
99
+ retries : this . maxRetries ,
100
+ onFailedAttempt : ( error ) => {
101
+ console . error (
102
+ `Attempt ${ error . attemptNumber } failed. ${ error . retriesLeft } retries left.`
103
+ ) ;
104
+ } ,
105
+ }
109
106
) ;
110
107
111
108
// Cache the result
0 commit comments