adjust command

This commit is contained in:
rootdarkarchon
2022-10-20 11:46:07 +02:00
parent 1516ab73c7
commit 25772dade8
3 changed files with 11 additions and 19 deletions

View File

@@ -57,7 +57,7 @@ public class Startup
Names = { MethodName.Default },
RetryPolicy = new RetryPolicy
{
MaxAttempts = 100,
MaxAttempts = 1000,
InitialBackoff = TimeSpan.FromSeconds(1),
MaxBackoff = TimeSpan.FromSeconds(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>
{
MetricsAPI.CounterInitializedConnections,
@@ -113,7 +107,7 @@ public class Startup
c.Address = new Uri(mareConfig.GetValue<string>("ServiceAddress"));
}).ConfigureChannel(c =>
{
c.ServiceConfig = new ServiceConfig { MethodConfigs = { identMethodConfig } };
c.ServiceConfig = new ServiceConfig { MethodConfigs = { defaultMethodConfig } };
c.HttpHandler = new SocketsHttpHandler()
{
EnableMultipleHttp2Connections = true

View File

@@ -148,8 +148,8 @@ internal class DiscordBot : IHostedService
{
EmbedBuilder eb = new();
IUser optionalUser = (IUser?)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? 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;
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();
await using var db = scope.ServiceProvider.GetRequiredService<MareDbContext>();
@@ -192,9 +192,9 @@ internal class DiscordBot : IHostedService
else
{
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)
{
@@ -690,7 +690,7 @@ internal class DiscordBot : IHostedService
var userInfo = new SlashCommandBuilder();
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.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);
try

View File

@@ -72,14 +72,14 @@ public abstract class GrpcBaseService : IHostedService, IDisposable
{
try
{
await CheckFaultStateAndResend().ConfigureAwait(false);
await CheckFaultStateAndRestore().ConfigureAwait(false);
}
catch { SetGrpcFaulty(); }
await Task.Delay(250).ConfigureAwait(false);
}
}
private async Task CheckFaultStateAndResend()
private async Task CheckFaultStateAndRestore()
{
if (GrpcIsFaulty)
{
@@ -96,8 +96,6 @@ public abstract class GrpcBaseService : IHostedService, IDisposable
{
var result = await toExecute.ConfigureAwait(false);
await CheckFaultStateAndResend().ConfigureAwait(false);
return result;
}
catch
@@ -113,7 +111,7 @@ public abstract class GrpcBaseService : IHostedService, IDisposable
try
{
await toExecute.ConfigureAwait(false);
await CheckFaultStateAndResend().ConfigureAwait(false);
await CheckFaultStateAndRestore().ConfigureAwait(false);
}
catch
{