Create runtime variables and remove MessagePack.
This commit is contained in:
+50
-15
@@ -1,4 +1,6 @@
|
||||
using MessagePack;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text.Json;
|
||||
using Models.Model.Backend;
|
||||
using Models.Model.External;
|
||||
using NetMQ;
|
||||
using NetMQ.Sockets;
|
||||
@@ -32,7 +34,7 @@ public static class Commands
|
||||
|
||||
Console.WriteLine(SendAndRecieveStringMessage(communicationObject));
|
||||
}
|
||||
|
||||
|
||||
public static void Vacuum()
|
||||
{
|
||||
CommunicationObject communicationObject = new();
|
||||
@@ -48,6 +50,18 @@ public static class Commands
|
||||
|
||||
Console.WriteLine(SendAndRecieveStringMessage(communicationObject));
|
||||
}
|
||||
|
||||
public static void SetRuntimeVariable(RuntimeVariable runtimeVariable, string value)
|
||||
{
|
||||
CommunicationObject communicationObject = new()
|
||||
{
|
||||
Command = CommunicationCommand.ChangeRuntimeVariable,
|
||||
Variable = runtimeVariable.ToString(),
|
||||
VariableValue = value
|
||||
};
|
||||
|
||||
SendAndRecieveStringMessage(communicationObject);
|
||||
}
|
||||
|
||||
public static void GetHelp()
|
||||
{
|
||||
@@ -59,32 +73,53 @@ public static class Commands
|
||||
Console.WriteLine(" g - manual garbage collect on the server");
|
||||
Console.WriteLine(" r - manual reindex the databases");
|
||||
Console.WriteLine(" v - manual vacuum the databases");
|
||||
Console.WriteLine(" R - change runtime variable");
|
||||
Console.WriteLine(" lR - list runtime variables");
|
||||
Console.WriteLine(" help - shows this help");
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
private static string SendAndRecieveStringMessage(CommunicationObject communicationObject)
|
||||
public static void PrintRuntimeVariables()
|
||||
{
|
||||
byte[] bytes = MessagePackSerializer.Serialize(communicationObject);
|
||||
|
||||
using RequestSocket client = new();
|
||||
client.Connect("tcp://127.0.0.1:5556");
|
||||
client.SendFrame(bytes);
|
||||
byte[] msg = client.ReceiveFrameBytes();
|
||||
client.Close();
|
||||
return MessagePackSerializer.Deserialize<string>(msg, MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4BlockArray));
|
||||
Console.WriteLine("Runtime variables:");
|
||||
Console.WriteLine($"{RuntimeVariable.ScannerTimeout.ToString()} - Sets the timeout in milliseconds for the scanner");
|
||||
Console.WriteLine($"{RuntimeVariable.ContentFilter.ToString()} - Sets the timeout in milliseconds for the content filter");
|
||||
Console.WriteLine($"{RuntimeVariable.DbContent.ToString()} - Sets the wait time in milliseconds for the content database if the queue is empty");
|
||||
Console.WriteLine($"{RuntimeVariable.DbDiscarded.ToString()} - Sets the wait time in milliseconds for the discarded database if the queue is empty");
|
||||
}
|
||||
|
||||
private static ScanningStatus GetProgress(CommunicationObject communicationObject)
|
||||
[RequiresDynamicCode("Calls System.Text.Json.JsonSerializer.SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions)")]
|
||||
[RequiresUnreferencedCode("Calls System.Text.Json.JsonSerializer.SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions)")]
|
||||
private static string? SendAndRecieveStringMessage(CommunicationObject communicationObject)
|
||||
{
|
||||
byte[] bytes = MessagePackSerializer.Serialize(communicationObject);
|
||||
//byte[] bytes = MessagePackSerializer.Serialize(communicationObject, ContractlessStandardResolver.Options);
|
||||
|
||||
byte[] lol = JsonSerializer.SerializeToUtf8Bytes(communicationObject);
|
||||
|
||||
using RequestSocket client = new();
|
||||
client.Connect("tcp://127.0.0.1:5556");
|
||||
client.SendFrame(bytes);
|
||||
client.SendFrame(lol);
|
||||
byte[] msg = client.ReceiveFrameBytes();
|
||||
client.Close();
|
||||
|
||||
return MessagePackSerializer.Deserialize<ScanningStatus>(msg, MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4BlockArray));
|
||||
return JsonSerializer.Deserialize<string>(msg);
|
||||
}
|
||||
|
||||
[RequiresUnreferencedCode("Calls System.Text.Json.JsonSerializer.SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions)")]
|
||||
[RequiresDynamicCode("Calls System.Text.Json.JsonSerializer.SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions)")]
|
||||
private static ScanningStatus GetProgress(CommunicationObject communicationObject)
|
||||
{
|
||||
//byte[] bytes = MessagePackSerializer.Serialize(communicationObject, ContractlessStandardResolver.Options);
|
||||
|
||||
byte[] lol = JsonSerializer.SerializeToUtf8Bytes(communicationObject);
|
||||
|
||||
|
||||
using RequestSocket client = new();
|
||||
client.Connect("tcp://127.0.0.1:5556");
|
||||
client.SendFrame(lol);
|
||||
byte[] msg = client.ReceiveFrameBytes();
|
||||
client.Close();
|
||||
|
||||
return JsonSerializer.Deserialize<ScanningStatus>(msg);
|
||||
}
|
||||
}
|
||||
+4
-11
@@ -5,14 +5,13 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<PublishAot>true</PublishAot>
|
||||
<Platform>x64</Platform>
|
||||
|
||||
<!--<Platform>x64</Platform>
|
||||
<Optimize>true</Optimize>
|
||||
<!--<PublishAot>true</PublishAot>-->
|
||||
<PublishAot>true</PublishAot>
|
||||
<PublishTrimmed>true</PublishTrimmed>
|
||||
<TrimMode>link</TrimMode>
|
||||
<TrimmerRemoveSymbols>true</TrimmerRemoveSymbols>
|
||||
<TrimmerRemoveSymbols>true</TrimmerRemoveSymbols>-->
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -20,12 +19,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MessagePack" Version="3.0.238-rc.1" />
|
||||
<PackageReference Include="MessagePack.Annotations" Version="3.0.238-rc.1" />
|
||||
<PackageReference Include="MessagePackAnalyzer" Version="3.0.238-rc.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="NetMQ" Version="4.0.1.13" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Manager;
|
||||
using Models.Model.Backend;
|
||||
|
||||
bool stop = false;
|
||||
|
||||
@@ -36,6 +37,43 @@ do
|
||||
Commands.ReIndex();
|
||||
}
|
||||
|
||||
else if (string.Equals(input, "R"))
|
||||
{
|
||||
string? variable = Console.ReadLine();
|
||||
string? value = Console.ReadLine();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(variable) || string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
Console.WriteLine("Please enter a value.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (variable == RuntimeVariable.ScannerTimeout.ToString())
|
||||
{
|
||||
Commands.SetRuntimeVariable(RuntimeVariable.ScannerTimeout, value);
|
||||
}
|
||||
|
||||
else if (variable == RuntimeVariable.ContentFilter.ToString())
|
||||
{
|
||||
Commands.SetRuntimeVariable(RuntimeVariable.ContentFilter, value);
|
||||
}
|
||||
|
||||
else if (variable == RuntimeVariable.DbDiscarded.ToString())
|
||||
{
|
||||
Commands.SetRuntimeVariable(RuntimeVariable.DbDiscarded, value);
|
||||
}
|
||||
|
||||
else if (variable == RuntimeVariable.DbContent.ToString())
|
||||
{
|
||||
Commands.SetRuntimeVariable(RuntimeVariable.DbContent, value);
|
||||
}
|
||||
}
|
||||
|
||||
else if (string.Equals(input, "lR"))
|
||||
{
|
||||
Commands.PrintRuntimeVariables();
|
||||
}
|
||||
|
||||
else if (string.Equals(input, "help"))
|
||||
{
|
||||
Commands.GetHelp();
|
||||
|
||||
Reference in New Issue
Block a user