726
727
constructor(
729
>
private readonly interval: number, /* in ms */
730
>
private readonly requestService: IRequestService,
731
>
private readonly logService: IUserDataSyncLogService,
732
>
) { }
733
734
request(url: string, options: IRequestOptions, token: CancellationToken): Promise<IRequestContext> {
736
this.reset();
737
}
739
>
options.url = url;
740
>
741
>
if (this.requests.length >= this.limit) {
742
this.logService.info('Too many requests', ...this.requests);
743
throw new UserDataSyncStoreError(`Too many requests. Only ${this.limit} requests allowed in ${this.interval / (1000 * 60)} minutes.`, url, UserDataSyncErrorCode.LocalTooManyRequests, undefined, undefined);
744
}
746
>
this.startTime = this.startTime || new Date();
747
>
this.requests.push(url);
748
>
749
>
return this.requestService.request(options, token);
750
>
}
751
752
private isExpired(): boolean {
753
>
return this.startTime !== undefined && new Date().getTime() - this.startTime.getTime() > this.interval;
userDataSyncStoreService.ts
754
>
}
755
756
private reset(): void {