chore: initial project import
This commit is contained in:
commit
26620707a0
347 files changed
+56172
No files matched your search
@@ -0,0 +1,65 @@
|
||||
using System.Text.Json;
|
||||
using Fleet.Core;
|
||||
using Fleet.Rpc;
|
||||
|
||||
namespace Fleet.Server;
|
||||
|
||||
public sealed record EnrollmentContext(string? RemoteIp, JsonElement? ProductMeta);
|
||||
|
||||
/// <summary>产品挂钩:节点注册成功之后调用。</summary>
|
||||
public interface IEnrollmentHook
|
||||
{
|
||||
ValueTask OnEnrolledAsync(NodeRecord node, EnrollmentContext context, CancellationToken ct);
|
||||
}
|
||||
|
||||
public enum NodeEventKind
|
||||
{
|
||||
Online,
|
||||
Offline,
|
||||
Hello,
|
||||
Heartbeat,
|
||||
}
|
||||
|
||||
public sealed record NodeEvent(NodeEventKind Kind, NodeRecord Node, long AtMs, HelloParams? Hello = null, JsonElement? Extra = null);
|
||||
|
||||
public interface INodeEventSink
|
||||
{
|
||||
ValueTask OnEventAsync(NodeEvent nodeEvent, CancellationToken ct);
|
||||
}
|
||||
|
||||
/// <summary>期望状态提供者:为每个节点计算期望状态的完整快照(天然幂等)。</summary>
|
||||
public interface IStateProvider
|
||||
{
|
||||
/// <summary>状态文档类型,例如 <c>task_set</c>。</summary>
|
||||
string Type { get; }
|
||||
|
||||
ValueTask<StateDocument?> GetAsync(NodeRecord node, CancellationToken ct);
|
||||
|
||||
/// <summary>节点应用之后回调,<c>rejected[]</c> 带结构化原因。</summary>
|
||||
ValueTask OnAppliedAsync(NodeRecord node, long version, StateSyncResult result, CancellationToken ct);
|
||||
}
|
||||
|
||||
public sealed record StateDocument(long Version, JsonElement Doc);
|
||||
|
||||
public enum InboxOutcome
|
||||
{
|
||||
Stored,
|
||||
Duplicate,
|
||||
Rejected,
|
||||
}
|
||||
|
||||
/// <summary>收件箱:持久化之后才返回 Stored,框架随后才回复 ACK。</summary>
|
||||
public interface IInbox
|
||||
{
|
||||
byte Channel { get; }
|
||||
|
||||
ValueTask<InboxOutcome> HandleAsync(NodeRecord node, Guid msgId, ReadOnlyMemory<byte> payload, CancellationToken ct);
|
||||
}
|
||||
|
||||
/// <summary>通知 Fleet:某个节点的期望状态变了,需要重新计算并推送。</summary>
|
||||
public interface IStateNotifier
|
||||
{
|
||||
void NotifyChanged(NodeId node);
|
||||
|
||||
void NotifyAllChanged();
|
||||
}
|
||||
Reference in new issue
Block a user