adjust command
This commit is contained in:
@@ -57,7 +57,7 @@ public class Startup
|
|||||||
Names = { MethodName.Default },
|
Names = { MethodName.Default },
|
||||||
RetryPolicy = new RetryPolicy
|
RetryPolicy = new RetryPolicy
|
||||||
{
|
{
|
||||||
MaxAttempts = 100,
|
MaxAttempts = 1000,
|
||||||
InitialBackoff = TimeSpan.FromSeconds(1),
|
InitialBackoff = TimeSpan.FromSeconds(1),
|
||||||
MaxBackoff = TimeSpan.FromSeconds(5),
|
MaxBackoff = TimeSpan.FromSeconds(5),
|
||||||
BackoffMultiplier = 1.5,
|
BackoffMultiplier = 1.5,
|
||||||
@@ -65,12 +65,6 @@ public class Startup
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var identMethodConfig = new MethodConfig
|
|
||||||
{
|
|
||||||
Names = { MethodName.Default },
|
|
||||||
RetryPolicy = null
|
|
||||||
};
|
|
||||||
|
|
||||||
services.AddSingleton(new MareMetrics(new List<string>
|
services.AddSingleton(new MareMetrics(new List<string>
|
||||||
{
|
{
|
||||||
MetricsAPI.CounterInitializedConnections,
|
MetricsAPI.CounterInitializedConnections,
|
||||||
@@ -113,7 +107,7 @@ public class Startup
|
|||||||
c.Address = new Uri(mareConfig.GetValue<string>("ServiceAddress"));
|
c.Address = new Uri(mareConfig.GetValue<string>("ServiceAddress"));
|
||||||
}).ConfigureChannel(c =>
|
}).ConfigureChannel(c =>
|
||||||
{
|
{
|
||||||
c.ServiceConfig = new ServiceConfig { MethodConfigs = { identMethodConfig } };
|
c.ServiceConfig = new ServiceConfig { MethodConfigs = { defaultMethodConfig } };
|
||||||
c.HttpHandler = new SocketsHttpHandler()
|
c.HttpHandler = new SocketsHttpHandler()
|
||||||
{
|
{
|
||||||
EnableMultipleHttp2Connections = true
|
EnableMultipleHttp2Connections = true
|
||||||
|
|||||||
@@ -148,8 +148,8 @@ internal class DiscordBot : IHostedService
|
|||||||
{
|
{
|
||||||
EmbedBuilder eb = new();
|
EmbedBuilder eb = new();
|
||||||
|
|
||||||
IUser optionalUser = (IUser?)arg.Data.Options.FirstOrDefault(f => f.Name == "discord_user")?.Value ?? null;
|
string? optionalUser = (string?)arg.Data.Options.FirstOrDefault(f => f.Name == "discord_user")?.Value ?? null;
|
||||||
string uid = (string?)arg.Data.Options.FirstOrDefault(f => f.Name == "uid")?.Value ?? null;
|
string? uid = (string?)arg.Data.Options.FirstOrDefault(f => f.Name == "uid")?.Value ?? null;
|
||||||
|
|
||||||
eb = await HandleUserInfo(eb, arg.User.Id, optionalUser, uid);
|
eb = await HandleUserInfo(eb, arg.User.Id, optionalUser, uid);
|
||||||
|
|
||||||
@@ -167,7 +167,7 @@ internal class DiscordBot : IHostedService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<EmbedBuilder> HandleUserInfo(EmbedBuilder eb, ulong id, IUser? optionalUser, string? uid)
|
private async Task<EmbedBuilder> HandleUserInfo(EmbedBuilder eb, ulong id, string? optionalUser, string? uid)
|
||||||
{
|
{
|
||||||
using var scope = services.CreateScope();
|
using var scope = services.CreateScope();
|
||||||
await using var db = scope.ServiceProvider.GetRequiredService<MareDbContext>();
|
await using var db = scope.ServiceProvider.GetRequiredService<MareDbContext>();
|
||||||
@@ -192,9 +192,9 @@ internal class DiscordBot : IHostedService
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
LodeStoneAuth userInDb = null;
|
LodeStoneAuth userInDb = null;
|
||||||
if (optionalUser != null)
|
if (optionalUser != null && ulong.TryParse(optionalUser, out ulong optionalUserId))
|
||||||
{
|
{
|
||||||
userInDb = await db.LodeStoneAuth.Include(u => u.User).SingleOrDefaultAsync(u => u.DiscordId == optionalUser.Id).ConfigureAwait(false);
|
userInDb = await db.LodeStoneAuth.Include(u => u.User).SingleOrDefaultAsync(u => u.DiscordId == optionalUserId).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else if (uid != null)
|
else if (uid != null)
|
||||||
{
|
{
|
||||||
@@ -690,7 +690,7 @@ internal class DiscordBot : IHostedService
|
|||||||
var userInfo = new SlashCommandBuilder();
|
var userInfo = new SlashCommandBuilder();
|
||||||
userInfo.WithName("userinfo");
|
userInfo.WithName("userinfo");
|
||||||
userInfo.WithDescription("Checks and returns your user information about your Mare account. The parameters are solely for admins, do not use them.");
|
userInfo.WithDescription("Checks and returns your user information about your Mare account. The parameters are solely for admins, do not use them.");
|
||||||
userInfo.AddOption("discord_user", ApplicationCommandOptionType.User, "Discord User", isRequired: false);
|
userInfo.AddOption("discord_user", ApplicationCommandOptionType.String, "Discord User", isRequired: false);
|
||||||
userInfo.AddOption("uid", ApplicationCommandOptionType.String, "UID", isRequired: false);
|
userInfo.AddOption("uid", ApplicationCommandOptionType.String, "UID", isRequired: false);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -72,14 +72,14 @@ public abstract class GrpcBaseService : IHostedService, IDisposable
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await CheckFaultStateAndResend().ConfigureAwait(false);
|
await CheckFaultStateAndRestore().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch { SetGrpcFaulty(); }
|
catch { SetGrpcFaulty(); }
|
||||||
await Task.Delay(250).ConfigureAwait(false);
|
await Task.Delay(250).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CheckFaultStateAndResend()
|
private async Task CheckFaultStateAndRestore()
|
||||||
{
|
{
|
||||||
if (GrpcIsFaulty)
|
if (GrpcIsFaulty)
|
||||||
{
|
{
|
||||||
@@ -96,8 +96,6 @@ public abstract class GrpcBaseService : IHostedService, IDisposable
|
|||||||
{
|
{
|
||||||
var result = await toExecute.ConfigureAwait(false);
|
var result = await toExecute.ConfigureAwait(false);
|
||||||
|
|
||||||
await CheckFaultStateAndResend().ConfigureAwait(false);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@@ -113,7 +111,7 @@ public abstract class GrpcBaseService : IHostedService, IDisposable
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
await toExecute.ConfigureAwait(false);
|
await toExecute.ConfigureAwait(false);
|
||||||
await CheckFaultStateAndResend().ConfigureAwait(false);
|
await CheckFaultStateAndRestore().ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user