fix Policy Rules
This commit is contained in:
parent
a772b67205
commit
9a56eea6cf
@ -1,5 +1,5 @@
|
||||
//
|
||||
// IdentityStore.swift
|
||||
// PolicyRuleStore.swift
|
||||
// punchnet
|
||||
// 1. 需要增加规则基于轮训更新的逻辑
|
||||
// Created by 安礼成 on 2026/2/5.
|
||||
@ -7,7 +7,7 @@
|
||||
import Foundation
|
||||
import NIO
|
||||
|
||||
actor IdentityStore {
|
||||
actor PolicyRuleStore {
|
||||
|
||||
// 处理权限的请求问题
|
||||
nonisolated private let cooldown: Duration = .seconds(5)
|
||||
@ -9,7 +9,7 @@ import Foundation
|
||||
|
||||
actor PolicyService {
|
||||
// 处理权限控制
|
||||
private let identifyStore: IdentityStore
|
||||
private let policyRuleStore: PolicyRuleStore
|
||||
nonisolated private let snapshotPublisher: SnapshotPublisher<IdentitySnapshot>
|
||||
|
||||
// Flow流会话管理, 过期时间为: 180秒
|
||||
@ -22,7 +22,7 @@ actor PolicyService {
|
||||
self.identityId = identityId
|
||||
// 权限控制
|
||||
let snapshotPublisher = SnapshotPublisher(initial: IdentitySnapshot.empty())
|
||||
self.identifyStore = IdentityStore(publisher: snapshotPublisher)
|
||||
self.policyRuleStore = PolicyRuleStore(publisher: snapshotPublisher)
|
||||
self.snapshotPublisher = snapshotPublisher
|
||||
}
|
||||
|
||||
@ -40,11 +40,11 @@ actor PolicyService {
|
||||
}
|
||||
|
||||
func makePolicyRequest(srcIdentityID: UInt32) async -> Data? {
|
||||
return await self.identifyStore.makePolicyRequest(srcIdentityId: srcIdentityID, dstIdentityId: self.identityId)
|
||||
return await self.policyRuleStore.makePolicyRequest(srcIdentityId: srcIdentityID, dstIdentityId: self.identityId)
|
||||
}
|
||||
|
||||
func updatePolicy(superServiceProxy: SDLSuperServiceProxy) async {
|
||||
let requests = await self.identifyStore.makeBatchPolicyRequests(dstIdentityID: self.identityId)
|
||||
let requests = await self.policyRuleStore.makeBatchPolicyRequests(dstIdentityID: self.identityId)
|
||||
for request in requests {
|
||||
await superServiceProxy.send(type: .policyRequest, data: request)
|
||||
}
|
||||
@ -56,12 +56,12 @@ actor PolicyService {
|
||||
return
|
||||
}
|
||||
|
||||
await self.identifyStore.applyPolicyResponse(policyResponse)
|
||||
await self.policyRuleStore.applyPolicyResponse(policyResponse)
|
||||
}
|
||||
|
||||
func clear() async {
|
||||
self.flowSessionManager.clear()
|
||||
await self.identifyStore.clear()
|
||||
await self.policyRuleStore.clear()
|
||||
}
|
||||
|
||||
deinit {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user