Skip to content

Commit

Permalink
CommandInModel增加StartTime,指定命令开始执行的未来时间
Browse files Browse the repository at this point in the history
  • Loading branch information
猿人易 committed Sep 25, 2024
1 parent 0939876 commit 377232c
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion DH.NRemoting.Extensions/WebHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private static Uri GetRawUrl(Uri uri, Func<String, String> headers)
if (port > 0 && port != 80 && port != 443)
{
uriInfo.Port = port;
uri = new Uri(uriInfo.ToString());
uri = new Uri(uriInfo.ToString()!);
}

return uri;
Expand Down
2 changes: 1 addition & 1 deletion DH.NRemoting/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected virtual ICluster<String, ISocketClient> InitCluster()
}
finally
{
Cluster.Put(client);
Cluster.Return(client);
}
}

Expand Down
8 changes: 6 additions & 2 deletions DH.NRemoting/ClientPoolCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ public class ClientPoolCluster<T> : ICluster<String, T> where T : class

/// <summary>归还</summary>
/// <param name="value"></param>
public virtual Boolean Put(T value)
public virtual Boolean Return(T value)
{
if (value == null) return false;

return Pool.Put(value);
return Pool.Return(value);
}

/// <summary>Round-Robin 负载均衡</summary>
Expand Down Expand Up @@ -98,6 +98,10 @@ public MyPool(ClientPoolCluster<T> cluster)
}

protected override T OnCreate() => Host.CreateClient();

/// <summary>释放时,返回是否有效。无效对象将会被抛弃</summary>
/// <param name="value"></param>
protected override Boolean OnReturn(T value) => value != null && (value is not IDisposable2 ds || !ds.Disposed);
}

#region 日志
Expand Down
2 changes: 1 addition & 1 deletion DH.NRemoting/ClientSingleCluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public virtual T Get()

/// <summary>归还</summary>
/// <param name="value"></param>
public virtual Boolean Put(T value) => true;
public virtual Boolean Return(T value) => true;

/// <summary>Round-Robin 负载均衡</summary>
private Int32 _index = -1;
Expand Down
2 changes: 1 addition & 1 deletion DH.NRemoting/DH.NRemoting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="DH.NCore" Version="3.91.2024.923-beta0110" />
<PackageReference Include="DH.NCore" Version="3.91.2024.925-beta0627" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions DH.NRemoting/ICluster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface ICluster<TKey, TValue>

/// <summary>归还</summary>
/// <param name="value"></param>
Boolean Put(TValue value);
Boolean Return(TValue value);
}

/// <summary>集群助手</summary>
Expand All @@ -47,7 +47,7 @@ public static TResult Invoke<TKey, TValue, TResult>(this ICluster<TKey, TValue>
}
finally
{
cluster.Put(item);
cluster.Return(item);
}
}

Expand All @@ -67,7 +67,7 @@ public static async Task<TResult> InvokeAsync<TKey, TValue, TResult>(this IClust
}
finally
{
cluster.Put(item);
cluster.Return(item);
}
}
}
3 changes: 3 additions & 0 deletions DH.NRemoting/Models/CommandInModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public class CommandInModel
/// <summary>参数</summary>
public String? Argument { get; set; }

/// <summary>开始时间。多久之后开始执行,单位秒</summary>
public Int32 StartTime { get; set; }

/// <summary>有效期。多久之后指令过期,单位秒,未指定时表示不限制</summary>
public Int32 Expire { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion DH.NRemoting/WsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ protected virtual ICluster<String, WebSocket> InitCluster()
}
finally
{
Cluster.Put(client);
Cluster.Return(client);
}
}

Expand Down
10 changes: 5 additions & 5 deletions Samples/IoTZero/IoTZero.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DH.NCube.Core" Version="3.7.2024.921-beta0351" />
<PackageReference Include="DH.NIoT" Version="3.9.2024.9210003" />
<PackageReference Include="DH.NMQTT" Version="3.9.2024.9210003" />
<PackageReference Include="DH.NRedis" Version="3.91.2024.922-beta0349" />
<PackageReference Include="DH.NStardust.Extensions" Version="3.9.2024.9210003" />
<PackageReference Include="DH.NCube.Core" Version="3.91.2024.923-beta0331" />
<PackageReference Include="DH.NIoT" Version="3.91.2024.923-beta0343" />
<PackageReference Include="DH.NMQTT" Version="3.91.2024.923-beta0411" />
<PackageReference Include="DH.NRedis" Version="3.91.2024.923-beta0226" />
<PackageReference Include="DH.NStardust.Extensions" Version="3.91.2024.923-beta0321" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Samples/Zero.RpcServer/Zero.RpcServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DH.NCode" Version="3.9.2024.9210003" />
<PackageReference Include="DH.NRedis" Version="3.91.2024.922-beta0349" />
<PackageReference Include="DH.NStardust" Version="3.9.2024.9210003" />
<PackageReference Include="DH.NCode" Version="3.91.2024.924-beta1257" />
<PackageReference Include="DH.NRedis" Version="3.91.2024.923-beta0226" />
<PackageReference Include="DH.NStardust" Version="3.91.2024.923-beta0321" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions Samples/ZeroServer/ZeroServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DH.NCube.Core" Version="3.7.2024.921-beta0351" />
<PackageReference Include="DH.NRedis" Version="3.91.2024.922-beta0349" />
<PackageReference Include="DH.NStardust.Extensions" Version="3.9.2024.9210003" />
<PackageReference Include="DH.NCube.Core" Version="3.91.2024.923-beta0331" />
<PackageReference Include="DH.NRedis" Version="3.91.2024.923-beta0226" />
<PackageReference Include="DH.NStardust.Extensions" Version="3.91.2024.923-beta0321" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions XUnitTest/JsonEncoderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void EncodeRequest()
var len = reader.ReadInt32();
Assert.Equal(value.Total, len);
var buf = reader.ReadBytes(len);
Assert.Equal(value.ToHex(64), buf.ToHex(64));
Assert.Equal(value.ToHex(64), buf.ToHex(null, 0, 64));
}
}

Expand Down Expand Up @@ -129,7 +129,7 @@ public void EncodeResponse()
Assert.Equal(value.ToArray(), span);

var hex1 = value.ToHex(64);
var hex2 = span.ToHex(64);
var hex2 = span.ToHex();
Assert.Equal(hex1, hex2);
//Assert.Equal(value.Count, (Int32)pk.Slice(1 + name.Length, 4).ReadUInt32());
//Assert.Equal(value.ToHex(), pk.Slice(1 + name.Length + 4, value.Count).ToHex());
Expand Down

0 comments on commit 377232c

Please sign in to comment.