⚡ Optimize push notification saving by introducing the flush buffer
This commit is contained in:
@@ -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);
|
||||
|
||||
|
@@ -38,7 +38,7 @@ public static class ServiceCollectionExtensions
|
||||
options.MaxReceiveMessageSize = 16 * 1024 * 1024; // 16MB
|
||||
options.MaxSendMessageSize = 16 * 1024 * 1024; // 16MB
|
||||
});
|
||||
|
||||
|
||||
// Register gRPC reflection for service discovery
|
||||
services.AddGrpc();
|
||||
|
||||
@@ -127,6 +127,7 @@ public static class ServiceCollectionExtensions
|
||||
public static IServiceCollection AddAppFlushHandlers(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<FlushBufferService>();
|
||||
services.AddScoped<NotificationFlushHandler>();
|
||||
|
||||
return services;
|
||||
}
|
||||
@@ -139,13 +140,4 @@ public static class ServiceCollectionExtensions
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static void AddPushServices(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.Configure<ApnSettings>(configuration.GetSection("PushNotify:Apple"));
|
||||
services.AddHttpClient<ApnSender>();
|
||||
|
||||
services.Configure<FirebaseSettings>(configuration.GetSection("PushNotify:Firebase"));
|
||||
services.AddHttpClient<FirebaseSettings>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user