Resolve all 46 low-severity architecture review findings
This commit is contained in:
@@ -675,9 +675,16 @@ public class RealOpcUaClient : IOpcUaClient
|
||||
List<DataShard> touched,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
foreach (var (index, nodeId, startNode) in resolved)
|
||||
// Plan once for this chunk while the apply gate keeps shard occupancy stable.
|
||||
var placement = MonitoredItemShardPlanner.Plan(
|
||||
_dataShards.Select(s => s.ItemCount).ToArray(), ItemsPerShard, resolved.Count);
|
||||
for (var itemIndex = 0; itemIndex < resolved.Count; itemIndex++)
|
||||
{
|
||||
var shard = await PlaceOnDataShardAsync(cancellationToken);
|
||||
var (index, nodeId, startNode) = resolved[itemIndex];
|
||||
var shardIndex = placement[itemIndex];
|
||||
var shard = shardIndex < _dataShards.Count
|
||||
? _dataShards[shardIndex]
|
||||
: await CreateDataShardAsync(cancellationToken);
|
||||
var handle = Guid.NewGuid().ToString();
|
||||
var monitoredItem = new MonitoredItem(shard.Subscription.DefaultItem)
|
||||
{
|
||||
@@ -760,20 +767,6 @@ public class RealOpcUaClient : IOpcUaClient
|
||||
created.Count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the shard this item belongs on per
|
||||
/// <see cref="MonitoredItemShardPlanner"/> — first shard with free capacity, else a
|
||||
/// freshly created one. Callers must hold <see cref="_applyGate"/>.
|
||||
/// </summary>
|
||||
private async Task<DataShard> PlaceOnDataShardAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var index = MonitoredItemShardPlanner.Plan(
|
||||
_dataShards.Select(s => s.ItemCount).ToList(), ItemsPerShard, 1)[0];
|
||||
return index < _dataShards.Count
|
||||
? _dataShards[index]
|
||||
: await CreateDataShardAsync(cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Drops a monitored item that failed to create from the shard it was placed on.
|
||||
/// Callers must hold <see cref="_applyGate"/>. No ApplyChanges is issued: the server
|
||||
|
||||
Reference in New Issue
Block a user