add observability repo method
This commit is contained in:
1 parent
e036c6077e
commit
48ca64ec6f
2 files changed
+10
No files matched your search
@@ -72,4 +72,5 @@ export interface IJobsRepository {
|
||||
// ********************
|
||||
findPage(pagination: JobPageQuery): Promise<JobPage>;
|
||||
findAll(): Promise<Job[]>;
|
||||
countDueBacklog(now: number): Promise<number>; // Scaling signal
|
||||
}
|
||||
@@ -301,6 +301,15 @@ class MongoJobsRepository implements IJobsRepository {
|
||||
const docs = await JobModel.find().lean<JobDocument[]>();
|
||||
return docs.map(this.toEntity);
|
||||
};
|
||||
|
||||
countDueBacklog = async (now: number) => {
|
||||
return JobModel.countDocuments({
|
||||
type: "check",
|
||||
isActive: true,
|
||||
nextScheduledAt: { $lte: now },
|
||||
$or: [{ lockedUntil: null }, { lockedUntil: { $lt: now } }], // free or expired lock
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export default MongoJobsRepository;
|
||||
Reference in new issue
Block a user