113 lines
4.1 KiB
C#
113 lines
4.1 KiB
C#
#nullable enable
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ShrinkContext
|
|
{
|
|
public enum ShrinkFiberDiagnosticStatus
|
|
{
|
|
Inactive = 0,
|
|
Waiting = 1,
|
|
Loading = 2,
|
|
Active = 3,
|
|
Unloading = 4,
|
|
Failed = 5,
|
|
Retired = 6,
|
|
}
|
|
|
|
/// <summary>单个依赖键在快照时刻的解析、提交与潜在提供者。</summary>
|
|
public sealed class ShrinkDependencyDiagnostic
|
|
{
|
|
public ShrinkDependencyDiagnostic(string key, string realm, long? currentProviderUid,
|
|
long? committedProviderUid, IReadOnlyList<long> potentialProviderUids)
|
|
{
|
|
Key = key;
|
|
Realm = realm;
|
|
CurrentProviderUid = currentProviderUid;
|
|
CommittedProviderUid = committedProviderUid;
|
|
PotentialProviderUids = potentialProviderUids;
|
|
}
|
|
|
|
public string Key { get; }
|
|
public string Realm { get; }
|
|
public long? CurrentProviderUid { get; }
|
|
public long? CommittedProviderUid { get; }
|
|
public IReadOnlyList<long> PotentialProviderUids { get; }
|
|
public bool IsSatisfied => CurrentProviderUid.HasValue;
|
|
}
|
|
|
|
/// <summary>一个 fiber 的稳定只读诊断投影,不暴露可变运行时对象。</summary>
|
|
public sealed class ShrinkFiberDiagnostic
|
|
{
|
|
public ShrinkFiberDiagnostic(long uid, string name, ShrinkFiberDiagnosticStatus status,
|
|
ShrinkFiberState lifecycleState, bool retired, bool inTransition,
|
|
IReadOnlyList<string> inject, IReadOnlyList<string> provide,
|
|
IReadOnlyList<long> targetProviderUids,
|
|
IReadOnlyList<ShrinkDependencyDiagnostic> dependencies,
|
|
IReadOnlyList<string> interceptKeys,
|
|
string? errorType, string? errorMessage)
|
|
{
|
|
Uid = uid;
|
|
Name = name;
|
|
Status = status;
|
|
LifecycleState = lifecycleState;
|
|
Retired = retired;
|
|
InTransition = inTransition;
|
|
Inject = inject;
|
|
Provide = provide;
|
|
TargetProviderUids = targetProviderUids;
|
|
Dependencies = dependencies;
|
|
InterceptKeys = interceptKeys;
|
|
ErrorType = errorType;
|
|
ErrorMessage = errorMessage;
|
|
}
|
|
|
|
public long Uid { get; }
|
|
public string Name { get; }
|
|
public ShrinkFiberDiagnosticStatus Status { get; }
|
|
public ShrinkFiberState LifecycleState { get; }
|
|
public bool Retired { get; }
|
|
public bool InTransition { get; }
|
|
public IReadOnlyList<string> Inject { get; }
|
|
public IReadOnlyList<string> Provide { get; }
|
|
public IReadOnlyList<long> TargetProviderUids { get; }
|
|
public IReadOnlyList<ShrinkDependencyDiagnostic> Dependencies { get; }
|
|
public IReadOnlyList<string> InterceptKeys { get; }
|
|
public string? ErrorType { get; }
|
|
public string? ErrorMessage { get; }
|
|
}
|
|
|
|
public sealed class ShrinkNotificationDiagnostic
|
|
{
|
|
public ShrinkNotificationDiagnostic(long dispatchCount, long candidateVisitCount,
|
|
int lastCandidateCount, int indexedKeyCount)
|
|
{
|
|
DispatchCount = dispatchCount;
|
|
CandidateVisitCount = candidateVisitCount;
|
|
LastCandidateCount = lastCandidateCount;
|
|
IndexedKeyCount = indexedKeyCount;
|
|
}
|
|
|
|
public long DispatchCount { get; }
|
|
public long CandidateVisitCount { get; }
|
|
public int LastCandidateCount { get; }
|
|
public int IndexedKeyCount { get; }
|
|
}
|
|
|
|
/// <summary>运行时整体快照:fiber、绑定与 notify 索引状态。</summary>
|
|
public sealed class ShrinkContextRuntimeDiagnostic
|
|
{
|
|
public ShrinkContextRuntimeDiagnostic(IReadOnlyList<ShrinkFiberDiagnostic> fibers,
|
|
int bindingCount, ShrinkNotificationDiagnostic notifications)
|
|
{
|
|
Fibers = fibers;
|
|
BindingCount = bindingCount;
|
|
Notifications = notifications;
|
|
}
|
|
|
|
public IReadOnlyList<ShrinkFiberDiagnostic> Fibers { get; }
|
|
public int BindingCount { get; }
|
|
public ShrinkNotificationDiagnostic Notifications { get; }
|
|
}
|
|
}
|