Optimize push notification saving by introducing the flush buffer

This commit is contained in:
2025-08-14 15:31:33 +08:00
parent b037ecad79
commit b04b17c8ae
6 changed files with 52 additions and 26 deletions

View File

@@ -1,3 +1,4 @@
using DysonNetwork.Pusher.Notification;
using Quartz;
namespace DysonNetwork.Pusher.Startup;
@@ -14,6 +15,13 @@ public static class ScheduledJobsConfiguration
.ForJob(appDatabaseRecyclingJob)
.WithIdentity("AppDatabaseRecyclingTrigger")
.WithCronSchedule("0 0 0 * * ?"));
var notificationFlushJob = new JobKey("NotificationFlush");
q.AddJob<NotificationFlushJob>(opts => opts.WithIdentity(notificationFlushJob));
q.AddTrigger(opts => opts
.ForJob(notificationFlushJob)
.WithIdentity("NotificationFlushTrigger")
.WithSimpleSchedule(a => a.WithIntervalInSeconds(60).RepeatForever()));
});
services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);