This commit is contained in:
Antinew 2025-07-30 22:36:27 +08:00
parent 1683aba0c5
commit e25b0ba048
5 changed files with 78 additions and 30 deletions

View File

@ -17,5 +17,8 @@
"Name": "Console" "Name": "Console"
} }
] ]
},
"itfx": {
"BaseAddress": "http://43.139.210.35:8888/"
} }
} }

View File

@ -1,30 +0,0 @@
{
"SkyWalking": {
"ServiceName": "PackagePlatform",
"Namespace": "",
"HeaderVersions": [
"sw8"
],
"Sampling": {
"SamplePer3Secs": -1,
"Percentage": -1.0
},
"Logging": {
"Level": "Information",
"FilePath": "logs\\skyapm-{Date}.log"
},
"Transport": {
"Interval": 3000,
"ProtocolVersion": "v8",
"QueueSize": 30000,
"BatchSize": 3000,
"gRPC": {
"Servers": "skywalking-skywalking-helm-oap.skywalking:11800",
"Timeout": 10000,
"ConnectTimeout": 10000,
"ReportTimeout": 600000,
"Authentication": ""
}
}
}
}

View File

@ -0,0 +1,32 @@
using InterfaceForward.Domain.Shared.Helpers;
namespace TrackCenter.Application.Track2InterfaceRelay;
public class InterfaceForwardService
{
private readonly IHttpClientFactory _httpClientFactory;
public InterfaceForwardService(IHttpClientFactory httpClientFactory)
{
_httpClientFactory = httpClientFactory;
}
public async Task<InterfaceRelayUnifyResultDto> BatchForwardThenPushToQueueAsync(
string upStreamCode,
string serviceProviderCode,
List<object> data,
string resSubscribeName,
string? attach = null,
bool isReturnMessage = false)
{
var client = _httpClientFactory.CreateClient("itfx");
var body = data.ToJson();
var content = new StringContent(body);
using var response = await client.PostAsync("InterfaceForward/BatchForwardThenPushToQueue", content);
var res = await response.Content.ReadAsStringAsync();
return res.ToObject<InterfaceRelayUnifyResultDto>()!;
}
}

View File

@ -0,0 +1,36 @@
namespace TrackCenter.Application.Track2InterfaceRelay;
[Serializable]
public class InterfaceRelayUnifyResultDto
{
public InterfaceRelayUnifyResultDto()
{
}
public InterfaceRelayUnifyResultDto(bool isSuccess, object data)
{
this.Code = isSuccess? 200.ToString(): 400.ToString();
this.Data = data;
this.Msg = isSuccess? "成功": "失败";
}
public string Code { get; set; }
public string Msg { get; set; }
public object Data { get; set; }
/// <summary>
/// 请求Id
/// </summary>
public Guid RequestId { get; set; }
/// <summary>
/// 原报文
/// </summary>
public string? OriginalMessage { get; set; }
/// <summary>
/// 附加数据
/// </summary>
public string? Attach { get; set; }
}

View File

@ -186,6 +186,13 @@ public class TrackCenterApplicationModule : FakeModule
o.ShutdownTimeout = TimeSpan.FromSeconds(10); o.ShutdownTimeout = TimeSpan.FromSeconds(10);
o.WorkerCount = 1; o.WorkerCount = 1;
}); });
context.Services.AddHttpClient("itfx", client =>
{
client.Timeout = TimeSpan.FromSeconds(20);
client.BaseAddress = new Uri(configuration["itfx:BaseAddress"]!);
});
} }
public override void PreConfigureServices(ServiceConfigurationContext context) public override void PreConfigureServices(ServiceConfigurationContext context)