优化工单商铺数量限制

This commit is contained in:
chfei committed 2026-10-19 19:58:23 +08:00
1 parent f6eef23f96
commit 324ca0c6e7
3 files changed
+33 -12

No files matched your search

@@ -90,7 +90,7 @@ namespace LaunchDarkly.EventSource
this._configuration.HttpRequestModifier?.Invoke(request);
using (var response = await _httpClient.SendAsync(request,
using (var response = await _httpClient.SendAsync(request,
HttpCompletionOption.ResponseHeadersRead,
cancellationToken).ConfigureAwait(false))
{
@@ -40,9 +40,8 @@ public sealed class EventSourceTicketRealtimeService
TicketApiService.ValidateOptions(options);
StopCore();
var uri = BuildEventsUri(options);
var source = new EventSource(uri);
var config = BuildEventsUri(options);
var source = new EventSource(config);
source.Opened += OnOpened;
source.Closed += OnClosed;
source.MessageReceived += OnMessageReceived;
@@ -77,7 +76,6 @@ public sealed class EventSourceTicketRealtimeService
{
try
{
NLogger.Instance.Info("工单服务连接成");
await source.StartAsync();
lock (_sync)
{
@@ -182,22 +180,45 @@ public sealed class EventSourceTicketRealtimeService
new TicketRealtimeStateChangedEventArgs(state, message));
}
private static Uri BuildEventsUri(TicketClientOptions options)
//private static Uri BuildEventsUri(TicketClientOptions options)
//{
// var appIds = options.AppIds
// .Where(a => !string.IsNullOrWhiteSpace(a))
// .Distinct(StringComparer.Ordinal)
// .Select(a => "appId=" + Uri.EscapeDataString(a.Trim()));
// var query = new[]
// {
// "purchaseAccount=" + Uri.EscapeDataString(options.UserName)
// }.Concat(appIds);
// return new Uri(
// TicketApiService.ServerUrl
// + EventsPath
// + "?"
// + string.Join("&", query),
// UriKind.Absolute);
//}
private static Configuration BuildEventsUri(TicketClientOptions options)
{
var appIds = options.AppIds
.Where(a => !string.IsNullOrWhiteSpace(a))
.Distinct(StringComparer.Ordinal)
.Select(a => "appId=" + Uri.EscapeDataString(a.Trim()));
.Select(a => Uri.EscapeDataString(a.Trim()));
var query = new[]
{
"purchaseAccount=" + Uri.EscapeDataString(options.UserName)
}.Concat(appIds);
return new Uri(
};
var uri = new Uri(
TicketApiService.ServerUrl
+ EventsPath
+ "?"
+ string.Join("&", query),
UriKind.Absolute);
ConfigurationBuilder builder = Configuration.Builder(uri);
builder.RequestHeader("X-AppIds", $"[\"{string.Join("\",\"", appIds)}\"]");
builder._responseStartTimeout = TimeSpan.FromSeconds(30);
return builder.Build();
}
}
@@ -372,8 +372,8 @@ public sealed class TicketApiService
.ToList();
if (normalized.Count == 0)
throw new ArgumentException("appIds 至少需要一个 APPID。", nameof(appIds));
if (normalized.Count > 500)
throw new ArgumentException("appIds 最多支持 50 个 APPID。", nameof(appIds));
//if (normalized.Count > 5000)
// throw new ArgumentException("appIds 最多支持 50 个 APPID。", nameof(appIds));
foreach (var appId in normalized)
ValidateAppId(appId);
return normalized;