ci/woodpecker/push/main-amd64-build Pipeline was successful
Namespaces, assemblies, solution, binaries, images, systemd units, config paths, environment variables, protocol methods and the Linux user are all renamed. Breaking: existing databases, node identities and installed units must be recreated.
29 lines
960 B
C#
29 lines
960 B
C#
using Fleet.Server;
|
|
using MoShiro.Backend.Application;
|
|
using MoShiro.Protocol;
|
|
|
|
namespace MoShiro.Backend.Gateway;
|
|
|
|
/// <summary>
|
|
/// RawChunk 收件箱(二进制通道 16):持久化之后才返回,Fleet 随后才回复 ACK,按 chunk_id 去重。
|
|
/// 永远不可能被接受的块(损坏、冒名、未知 Kind)也确认掉并记录原因,否则节点会无限重发。
|
|
/// </summary>
|
|
public sealed class RawChunkInbox : IInbox
|
|
{
|
|
private readonly IngestService _ingest;
|
|
|
|
public RawChunkInbox(IngestService ingest)
|
|
{
|
|
_ingest = ingest;
|
|
}
|
|
|
|
public byte Channel => MoShiroChannels.RawChunk;
|
|
|
|
public async ValueTask<InboxOutcome> HandleAsync(NodeRecord node, Guid msgId, ReadOnlyMemory<byte> payload, CancellationToken ct) =>
|
|
await _ingest.IngestAsync(node.Id, msgId, payload, ct) switch
|
|
{
|
|
IngestOutcome.Stored => InboxOutcome.Stored,
|
|
_ => InboxOutcome.Duplicate,
|
|
};
|
|
}
|