规范并补充日志内容
This commit is contained in:
@@ -9,9 +9,9 @@ using SHH.Contracts.Grpc; // 引用 Proto 生成的命名空间
|
||||
namespace SHH.CameraService
|
||||
{
|
||||
/// <summary>
|
||||
/// gRPC 指令接收后台服务
|
||||
/// gRpc 指令接收后台服务
|
||||
/// 职责:
|
||||
/// 1. 维护与 AiVideo 的 gRPC 长连接。
|
||||
/// 1. 维护与 AiVideo 的 gRpc 长连接。
|
||||
/// 2. 完成节点逻辑注册。
|
||||
/// 3. 监听 Server Streaming 指令流并移交给 Dispatcher。
|
||||
/// </summary>
|
||||
@@ -33,7 +33,7 @@ namespace SHH.CameraService
|
||||
var gRpcLog = Log.ForContext("SourceContext", LogModules.gRpc);
|
||||
|
||||
// 预留系统启动缓冲时间,确保数据库和 SDK 已就绪
|
||||
gRpcLog.Information("[gRPC] 指令接收服务启动,等待环境预热...");
|
||||
gRpcLog.Information("[gRpc] 指令接收服务启动,等待环境预热...");
|
||||
await Task.Delay(3000, stoppingToken);
|
||||
|
||||
while (!stoppingToken.IsCancellationRequested)
|
||||
@@ -48,7 +48,7 @@ namespace SHH.CameraService
|
||||
var client = new GatewayProvider.GatewayProviderClient(channel);
|
||||
|
||||
// --- 第一步:发起节点逻辑注册 (Unary) ---
|
||||
gRpcLog.Information("[gRPC] 正在发起逻辑注册: {Url}", targetUrl);
|
||||
gRpcLog.Information("[gRpc] 正在发起逻辑注册: {Url}", targetUrl);
|
||||
var regResp = await client.RegisterInstanceAsync(new RegisterRequest
|
||||
{
|
||||
InstanceId = _config.AppId,
|
||||
@@ -59,7 +59,7 @@ namespace SHH.CameraService
|
||||
|
||||
if (regResp.Success)
|
||||
{
|
||||
gRpcLog.Information("[gRPC] 注册成功, 正在建立双向指令通道...");
|
||||
gRpcLog.Information("[gRpc] 注册成功, 正在建立双向指令通道...");
|
||||
|
||||
// --- 第二步:开启 Server Streaming 指令流 ---
|
||||
using var call = client.OpenCommandChannel(new CommandStreamRequest
|
||||
@@ -86,14 +86,14 @@ namespace SHH.CameraService
|
||||
}
|
||||
catch (RpcException ex)
|
||||
{
|
||||
gRpcLog.Debug("[gRPC] RPC 异常 (Status: {Code}): {Msg}", ex.StatusCode, ex.Message);
|
||||
gRpcLog.Debug("[gRpc] RPC 异常 (Status: {Code}): {Msg}", ex.StatusCode, ex.Message);
|
||||
|
||||
// 链路异常,进入重连等待阶段
|
||||
await Task.Delay(5000, stoppingToken);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
gRpcLog.Debug("[gRPC] 非预期链路异常: {Msg},5秒后尝试重连", ex.Message);
|
||||
gRpcLog.Debug("[gRpc] 非预期链路异常: {Msg},5秒后尝试重连", ex.Message);
|
||||
await Task.Delay(5000, stoppingToken);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user