Add RateLimit

This commit is contained in:
Sergey Dolin
2023-06-13 13:21:22 +02:00
parent 465330b7e2
commit 4b8e745923
5 changed files with 108 additions and 0 deletions

View File

@@ -27,6 +27,8 @@ import {LoggerService} from '../services/logger.service';
import {OctokitIssue} from '../interfaces/issue';
import {retry} from '@octokit/plugin-retry';
import {IState} from '../interfaces/state/state';
import {IRateLimit} from '../interfaces/rate-limit';
import {RateLimit} from './rate-limit';
/***
* Handle processing of issues for staleness/closure.
@@ -636,6 +638,16 @@ export class IssuesProcessor {
}
}
async getRateLimit(): Promise<IRateLimit | undefined> {
const logger: Logger = new Logger();
try {
const rateLimitResult = await this.client.rest.rateLimit.get();
return new RateLimit(rateLimitResult.data.rate);
} catch (error) {
logger.error(`Error when getting rateLimit: ${error.message}`);
}
}
// handle all of the stale issue logic when we find a stale issue
private async _processStaleIssue(
issue: Issue,