优化工单商铺数量限制
This commit is contained in:
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);
|
this._configuration.HttpRequestModifier?.Invoke(request);
|
||||||
|
|
||||||
using (var response = await _httpClient.SendAsync(request,
|
using (var response = await _httpClient.SendAsync(request,
|
||||||
HttpCompletionOption.ResponseHeadersRead,
|
HttpCompletionOption.ResponseHeadersRead,
|
||||||
cancellationToken).ConfigureAwait(false))
|
cancellationToken).ConfigureAwait(false))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,9 +40,8 @@ public sealed class EventSourceTicketRealtimeService
|
|||||||
|
|
||||||
TicketApiService.ValidateOptions(options);
|
TicketApiService.ValidateOptions(options);
|
||||||
StopCore();
|
StopCore();
|
||||||
|
var config = BuildEventsUri(options);
|
||||||
var uri = BuildEventsUri(options);
|
var source = new EventSource(config);
|
||||||
var source = new EventSource(uri);
|
|
||||||
source.Opened += OnOpened;
|
source.Opened += OnOpened;
|
||||||
source.Closed += OnClosed;
|
source.Closed += OnClosed;
|
||||||
source.MessageReceived += OnMessageReceived;
|
source.MessageReceived += OnMessageReceived;
|
||||||
@@ -77,7 +76,6 @@ public sealed class EventSourceTicketRealtimeService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
NLogger.Instance.Info("工单服务连接成");
|
|
||||||
await source.StartAsync();
|
await source.StartAsync();
|
||||||
lock (_sync)
|
lock (_sync)
|
||||||
{
|
{
|
||||||
@@ -182,22 +180,45 @@ public sealed class EventSourceTicketRealtimeService
|
|||||||
new TicketRealtimeStateChangedEventArgs(state, message));
|
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
|
var appIds = options.AppIds
|
||||||
.Where(a => !string.IsNullOrWhiteSpace(a))
|
.Where(a => !string.IsNullOrWhiteSpace(a))
|
||||||
.Distinct(StringComparer.Ordinal)
|
.Distinct(StringComparer.Ordinal)
|
||||||
.Select(a => "appId=" + Uri.EscapeDataString(a.Trim()));
|
.Select(a => Uri.EscapeDataString(a.Trim()));
|
||||||
var query = new[]
|
var query = new[]
|
||||||
{
|
{
|
||||||
"purchaseAccount=" + Uri.EscapeDataString(options.UserName)
|
"purchaseAccount=" + Uri.EscapeDataString(options.UserName)
|
||||||
}.Concat(appIds);
|
};
|
||||||
|
var uri = new Uri(
|
||||||
return new Uri(
|
|
||||||
TicketApiService.ServerUrl
|
TicketApiService.ServerUrl
|
||||||
+ EventsPath
|
+ EventsPath
|
||||||
+ "?"
|
+ "?"
|
||||||
+ string.Join("&", query),
|
+ string.Join("&", query),
|
||||||
UriKind.Absolute);
|
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();
|
.ToList();
|
||||||
if (normalized.Count == 0)
|
if (normalized.Count == 0)
|
||||||
throw new ArgumentException("appIds 至少需要一个 APPID。", nameof(appIds));
|
throw new ArgumentException("appIds 至少需要一个 APPID。", nameof(appIds));
|
||||||
if (normalized.Count > 500)
|
//if (normalized.Count > 5000)
|
||||||
throw new ArgumentException("appIds 最多支持 50 个 APPID。", nameof(appIds));
|
// throw new ArgumentException("appIds 最多支持 50 个 APPID。", nameof(appIds));
|
||||||
foreach (var appId in normalized)
|
foreach (var appId in normalized)
|
||||||
ValidateAppId(appId);
|
ValidateAppId(appId);
|
||||||
return normalized;
|
return normalized;
|
||||||
|
|||||||
Reference in new issue
Block a user