✨ Add billing
This commit is contained in:
25
DysonNetwork.Insight/Startup/ScheduledJobsConfiguration.cs
Normal file
25
DysonNetwork.Insight/Startup/ScheduledJobsConfiguration.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Quartz;
|
||||
|
||||
namespace DysonNetwork.Insight.Startup;
|
||||
|
||||
public static class ScheduledJobsConfiguration
|
||||
{
|
||||
public static IServiceCollection AddAppScheduledJobs(this IServiceCollection services)
|
||||
{
|
||||
services.AddQuartz(q =>
|
||||
{
|
||||
var tokenBillingJob = new JobKey("TokenBilling");
|
||||
q.AddJob<TokenBillingJob>(opts => opts.WithIdentity(tokenBillingJob));
|
||||
q.AddTrigger(opts => opts
|
||||
.ForJob(tokenBillingJob)
|
||||
.WithIdentity("TokenBillingTrigger")
|
||||
.WithSimpleSchedule(o => o
|
||||
.WithIntervalInMinutes(5)
|
||||
.RepeatForever())
|
||||
);
|
||||
});
|
||||
services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,14 @@ public static class ServiceCollectionExtensions
|
||||
services.AddSingleton<ThoughtProvider>();
|
||||
services.AddScoped<ThoughtService>();
|
||||
|
||||
// Add gRPC clients for ThoughtService
|
||||
services.AddGrpcClient<Shared.Proto.PaymentService.PaymentServiceClient>(o => o.Address = new Uri("https://_grpc.pass"))
|
||||
.ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler()
|
||||
{ ServerCertificateCustomValidationCallback = (_, _, _, _) => true });
|
||||
services.AddGrpcClient<Shared.Proto.WalletService.WalletServiceClient>(o => o.Address = new Uri("https://_grpc.pass"))
|
||||
.ConfigurePrimaryHttpMessageHandler(_ => new HttpClientHandler()
|
||||
{ ServerCertificateCustomValidationCallback = (_, _, _, _) => true });
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
|
||||
12
DysonNetwork.Insight/Startup/TokenBillingJob.cs
Normal file
12
DysonNetwork.Insight/Startup/TokenBillingJob.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using DysonNetwork.Insight.Thought;
|
||||
using Quartz;
|
||||
|
||||
namespace DysonNetwork.Insight.Startup;
|
||||
|
||||
public class TokenBillingJob(ThoughtService thoughtService, ILogger<TokenBillingJob> logger) : IJob
|
||||
{
|
||||
public async Task Execute(IJobExecutionContext context)
|
||||
{
|
||||
await thoughtService.SettleThoughtBills(logger);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user