mirror of
https://github.com/shadowsocks/ShadowsocksX-NG.git
synced 2026-11-22 13:34:00 +00:00
refactor(catalog): 激活拒绝结果自含 typed 原因
This commit is contained in:
@@ -220,8 +220,9 @@ struct ActivationEligibility: Equatable, Sendable {
|
||||
enum ActivationCommandOutcome: Equatable, Sendable {
|
||||
/// 成功;组展开时跳过的已知无效叶子数。
|
||||
case activated(skippedInvalid: Int)
|
||||
/// 原子拒绝(无 activation candidate / 目标失效);状态完全不动。
|
||||
case rejectedActivation
|
||||
/// 原子拒绝(无 activation candidate / 目标失效);携带 typed 点名原因,
|
||||
/// 状态完全不动。结果自含全部事实,调用方不必回读运行时发布事实拼原因。
|
||||
case rejectedActivation(ActivationFailure)
|
||||
}
|
||||
|
||||
/// 激活缝(issue #41):目录命令面经此发出激活意图。生产 adapter 为
|
||||
|
||||
@@ -7,8 +7,8 @@ extension ProxyRuntimeController {
|
||||
|
||||
/// 激活一个服务器或分组目标(目录 UI 工单复用入口):持久化目标;agent
|
||||
/// 意图开启时立即把新档推到运行时。激活原子失败时目标与运行时完全不动
|
||||
/// (D3),点名原因进 `lastActivationFailure` 并返回 `.rejectedActivation`;
|
||||
/// 意外错误 throws 并进入 `serviceFailed`。
|
||||
/// (D3),点名原因进 `lastActivationFailure` 并随 `.rejectedActivation`
|
||||
/// 自含返回;意外错误 throws 并进入 `serviceFailed`。
|
||||
@discardableResult
|
||||
func activate(_ target: NodeID) async throws -> ActivationCommandOutcome {
|
||||
let catalog = catalogSnapshotReader.catalogSnapshot
|
||||
@@ -31,7 +31,7 @@ extension ProxyRuntimeController {
|
||||
return .activated(skippedInvalid: configuration.skippedServers.count)
|
||||
} catch let failure as ActivationFailure {
|
||||
lastActivationFailure = failure
|
||||
return .rejectedActivation
|
||||
return .rejectedActivation(failure)
|
||||
} catch {
|
||||
state = .serviceFailed(.unknown)
|
||||
throw error
|
||||
|
||||
@@ -104,10 +104,10 @@ func expectThrowsAsync(
|
||||
|
||||
// MARK: - 目录工作流测试夹具(issue #49)
|
||||
|
||||
/// 中性激活替身:不关心激活语义的测试场景,激活命令原子拒绝。
|
||||
/// 中性激活替身:不关心激活语义的测试场景,激活命令原子拒绝(原因任意)。
|
||||
final class RejectingActivator: Activating {
|
||||
func activate(_ target: NodeID) async throws -> ActivationCommandOutcome {
|
||||
.rejectedActivation
|
||||
.rejectedActivation(.noActiveTarget)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -177,9 +177,9 @@ final class CatalogWorkflowPolicyTests: XCTestCase {
|
||||
|
||||
func testActivateRejectedOutcomeIsNotThrown() async throws {
|
||||
let serverID = try await importServer()
|
||||
activator.result = .rejectedActivation
|
||||
activator.result = .rejectedActivation(.targetNotFound(serverID))
|
||||
let outcome = try await workflow.activate(serverID)
|
||||
XCTAssertEqual(outcome, .rejectedActivation)
|
||||
XCTAssertEqual(outcome, .rejectedActivation(.targetNotFound(serverID)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ final class CatalogWorkflowHermeticAssemblyTests: XCTestCase {
|
||||
let groupID = try await workflow.createGroup(named: "组装组", into: nil)
|
||||
XCTAssertTrue(workflow.tree.containsNode(groupID))
|
||||
let activation = try await workflow.activate(groupID)
|
||||
XCTAssertEqual(activation, .rejectedActivation)
|
||||
XCTAssertEqual(activation, .rejectedActivation(.noActiveTarget))
|
||||
|
||||
// Legacy 导入走注入服务:报告、完成标记与凭据写入都落在注入的 fake 上;
|
||||
// 不经提交管线触发运行时收敛。
|
||||
|
||||
Reference in New Issue
Block a user