mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
refactor: remove protobuf
This commit is contained in:
parent
f1685495eb
commit
4596d98670
31 changed files with 58 additions and 577 deletions
|
|
@ -22,28 +22,6 @@ public class PrivateController: PKControllerBase
|
|||
{
|
||||
public PrivateController(IServiceProvider svc) : base(svc) { }
|
||||
|
||||
[HttpGet("meta")]
|
||||
public async Task<ActionResult<JObject>> Meta()
|
||||
{
|
||||
var db = _redis.Connection.GetDatabase();
|
||||
var redisInfo = await db.HashGetAllAsync("pluralkit:shardstatus");
|
||||
var shards = redisInfo.Select(x => Proto.Unmarshal<ShardState>(x.Value)).OrderBy(x => x.ShardId);
|
||||
|
||||
var redisClusterInfo = await db.HashGetAllAsync("pluralkit:cluster_stats");
|
||||
var clusterInfo = redisClusterInfo.Select(x => JsonConvert.DeserializeObject<ClusterMetricInfo>(x.Value));
|
||||
|
||||
var guildCount = clusterInfo.Sum(x => x.GuildCount);
|
||||
var channelCount = clusterInfo.Sum(x => x.ChannelCount);
|
||||
|
||||
var stats = await _repo.GetStats();
|
||||
|
||||
var o = new JObject();
|
||||
o.Add("shards", shards.ToJson());
|
||||
o.Add("stats", stats.ToJson(guildCount, channelCount));
|
||||
|
||||
return Ok(o);
|
||||
}
|
||||
|
||||
[HttpPost("bulk_privacy/member")]
|
||||
public async Task<IActionResult> BulkMemberPrivacy([FromBody] JObject inner)
|
||||
{
|
||||
|
|
@ -158,31 +136,4 @@ public static class PrivateJsonExt
|
|||
o.Add("error", error);
|
||||
return o;
|
||||
}
|
||||
|
||||
public static JArray ToJson(this IEnumerable<ShardState> shards)
|
||||
{
|
||||
var o = new JArray();
|
||||
|
||||
foreach (var shard in shards)
|
||||
{
|
||||
var s = new JObject();
|
||||
s.Add("id", shard.ShardId);
|
||||
|
||||
if (!shard.Up)
|
||||
s.Add("status", "down");
|
||||
else
|
||||
s.Add("status", "up");
|
||||
|
||||
s.Add("ping", shard.Latency);
|
||||
s.Add("disconnection_count", shard.DisconnectionCount);
|
||||
s.Add("last_heartbeat", shard.LastHeartbeat.ToString());
|
||||
s.Add("last_connection", shard.LastConnection.ToString());
|
||||
if (shard.HasClusterId)
|
||||
s.Add("cluster_id", shard.ClusterId);
|
||||
|
||||
o.Add(s);
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
|
@ -28,15 +28,9 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Google.Protobuf" Version="3.29.1" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.68.1" PrivateAssets="all" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.11" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Protobuf Include="../proto/state.proto" GrpcServices="Client" Link="Protos/state.proto" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -2,18 +2,6 @@
|
|||
"version": 1,
|
||||
"dependencies": {
|
||||
"net8.0": {
|
||||
"Google.Protobuf": {
|
||||
"type": "Direct",
|
||||
"requested": "[3.29.1, )",
|
||||
"resolved": "3.29.1",
|
||||
"contentHash": "kDFLP72bPu4GwquVN7HtFnfqxhQs4CLbUEyOc/0yV48HB0Pxf7tDK7zIx6ifaQwGp+RSoLY1sz1CXqoAEAu+AQ=="
|
||||
},
|
||||
"Grpc.Tools": {
|
||||
"type": "Direct",
|
||||
"requested": "[2.68.1, )",
|
||||
"resolved": "2.68.1",
|
||||
"contentHash": "BZ96s7ijKAhJoRpIK+pqCeLaGaSwyc5/CAZFwgCcBuAnkU2naYvH0P6qnYCkl0pWDY/JBOnE2RvX9IvRX1Yc5Q=="
|
||||
},
|
||||
"Microsoft.AspNetCore.Mvc.NewtonsoftJson": {
|
||||
"type": "Direct",
|
||||
"requested": "[8.0.11, )",
|
||||
|
|
@ -830,7 +818,6 @@
|
|||
"Autofac.Extensions.DependencyInjection": "[10.0.0, )",
|
||||
"Dapper": "[2.1.35, )",
|
||||
"Dapper.Contrib": "[2.0.78, )",
|
||||
"Google.Protobuf": "[3.29.1, )",
|
||||
"Microsoft.Extensions.Caching.Memory": "[9.0.0, )",
|
||||
"Microsoft.Extensions.Configuration": "[9.0.0, )",
|
||||
"Microsoft.Extensions.Configuration.Binder": "[9.0.0, )",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue