Browse Source

Merge branch 'master' into v3.0

master
Savorboard 4 years ago
parent
commit
9c3c6a9fb7
7 changed files with 24 additions and 16 deletions
  1. +2
    -1
      .github/ISSUE_TEMPLATE
  2. +1
    -1
      README.md
  3. +2
    -2
      docs/content/user-guide/zh/cap/messaging.md
  4. +1
    -1
      docs/content/user-guide/zh/transports/kafka.md
  5. +2
    -2
      docs/content/user-guide/zh/transports/rabbitmq.md
  6. +13
    -8
      src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs
  7. +3
    -1
      src/DotNetCore.CAP.Dashboard/IDashboardAuthorizationFilter.cs

+ 2
- 1
.github/ISSUE_TEMPLATE View File

@@ -3,7 +3,7 @@ Thank you for reporting an issue.


1. It's RECOMMENDED to submit PR for typo or tiny bug fix. 1. It's RECOMMENDED to submit PR for typo or tiny bug fix.
2. If this's a FEATURE request, please provide: details, pseudo codes if necessary. 2. If this's a FEATURE request, please provide: details, pseudo codes if necessary.
3. If this's a BUG, please provide: course repetition, error log and configuration. Fill in as much of the template below as you're able.
3. If this's a BUG, please provide: course repetition, error log and configuration.


感谢您向我们反馈问题。 感谢您向我们反馈问题。


@@ -12,4 +12,4 @@ Thank you for reporting an issue.
3. 如果是一个新需求,请提供:详细需求描述。 3. 如果是一个新需求,请提供:详细需求描述。
4. 如果是一个 BUG,请提供:复现步骤,错误日志以及相关配置。 4. 如果是一个 BUG,请提供:复现步骤,错误日志以及相关配置。
5. 如果可能,请使用【英文】来提交,英文 issue 会被优先处理。 5. 如果可能,请使用【英文】来提交,英文 issue 会被优先处理。
-->

+ 1
- 1
README.md View File

@@ -253,7 +253,7 @@ services.AddCap(x =>
}); });
``` ```


The default dashboard address is :[http://localhost:xxx/cap](http://localhost:xxx/cap) , you can also change the `cap` suffix to others with `d.MatchPath` configuration options.
The default dashboard address is :[http://localhost:xxx/cap](http://localhost:xxx/cap), you can also configure the `/cap` suffix with `x.UseDashboard(opt =>{ opt.MatchPath="/mycap"; })`.


![dashboard](http://images2017.cnblogs.com/blog/250417/201710/250417-20171004220827302-189215107.png) ![dashboard](http://images2017.cnblogs.com/blog/250417/201710/250417-20171004220827302-189215107.png)




+ 2
- 2
docs/content/user-guide/zh/cap/messaging.md View File

@@ -32,6 +32,6 @@ CAP 接收到消息之后会将消息进行 Persistent(持久化), 有关


## 消息数据清理 ## 消息数据清理


数据库消息表中具有一个 ExpiresAt 字段表示消息的过期时间,当消息发送成功或者消费成功后,CAP会将消息状态为 Successed 的 ExpiresAt 设置为 1小时 后过期,会将消息状态为 Failed 的 ExpiresAt 设置为 15天 后过期。
数据库消息表中具有一个 ExpiresAt 字段表示消息的过期时间,当消息发送成功或者消费成功后,CAP会将消息状态为 Successed 的 ExpiresAt 设置为 1 后过期,会将消息状态为 Failed 的 ExpiresAt 设置为 15天 后过期。


CAP 默认情况下会每隔一个小时将消息表的数据进行清理删除,避免数据量过多导致性能的降低。清理规则为 ExpiresAt 不为空并且小于当前时间的数据。 也就是说状态为Failed的消息(正常情况他们已经被重试了 50 次),如果你15天没有人工介入处理,同样会被清理掉。
CAP 默认情况下会每隔一个小时将消息表的数据进行清理删除,避免数据量过多导致性能的降低。清理规则为 ExpiresAt 不为空并且小于当前时间的数据。 也就是说状态为Failed的消息(正常情况他们已经被重试了 50 次),如果你15天没有人工介入处理,同样会被清理掉。

+ 1
- 1
docs/content/user-guide/zh/transports/kafka.md View File

@@ -14,7 +14,7 @@ Install-Package DotNetCore.CAP.Kafka


``` ```


然后,你可以在 `Startup.cs` 的 `ConfigureServices` 方法中添加基于内存的配置项。
然后,你可以在 `Startup.cs` 的 `ConfigureServices` 方法中添加基于 Kafka 的配置项。


```csharp ```csharp




+ 2
- 2
docs/content/user-guide/zh/transports/rabbitmq.md View File

@@ -14,7 +14,7 @@ Install-Package DotNetCore.CAP.RabbitMQ


``` ```


然后,你可以在 `Startup.cs` 的 `ConfigureServices` 方法中添加基于内存的配置项。
然后,你可以在 `Startup.cs` 的 `ConfigureServices` 方法中添加基于 RabbitMQ 的配置项。


```csharp ```csharp


@@ -65,4 +65,4 @@ services.AddCap(x =>
}); });
}); });


```
```

+ 13
- 8
src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs View File

@@ -97,12 +97,13 @@ namespace DotNetCore.CAP
_routes = routes ?? throw new ArgumentNullException(nameof(routes)); _routes = routes ?? throw new ArgumentNullException(nameof(routes));
} }


public Task Invoke(HttpContext context)
public async Task Invoke(HttpContext context)
{ {
if (!context.Request.Path.StartsWithSegments(_options.PathMatch, if (!context.Request.Path.StartsWithSegments(_options.PathMatch,
out var matchedPath, out var remainingPath)) out var matchedPath, out var remainingPath))
{ {
return _next(context);
await _next(context);
return;
} }


// Update the path // Update the path
@@ -118,23 +119,27 @@ namespace DotNetCore.CAP


if (findResult == null) if (findResult == null)
{ {
return _next.Invoke(context);
await _next.Invoke(context);
return;
} }


if (_options.Authorization.Any(filter => !filter.Authorize(dashboardContext)))
foreach (var authorizationFilter in _options.Authorization)
{ {
var authenticateResult = await authorizationFilter.AuthorizeAsync(dashboardContext);
if (authenticateResult) continue;

var isAuthenticated = context.User?.Identity?.IsAuthenticated; var isAuthenticated = context.User?.Identity?.IsAuthenticated;


context.Response.StatusCode = isAuthenticated == true context.Response.StatusCode = isAuthenticated == true
? (int) HttpStatusCode.Forbidden
: (int) HttpStatusCode.Unauthorized;
? (int)HttpStatusCode.Forbidden
: (int)HttpStatusCode.Unauthorized;


return Task.CompletedTask;
return;
} }


dashboardContext.UriMatch = findResult.Item2; dashboardContext.UriMatch = findResult.Item2;


return findResult.Item1.Dispatch(dashboardContext);
await findResult.Item1.Dispatch(dashboardContext);
} }
finally finally
{ {


+ 3
- 1
src/DotNetCore.CAP.Dashboard/IDashboardAuthorizationFilter.cs View File

@@ -1,10 +1,12 @@
// Copyright (c) .NET Core Community. All rights reserved. // Copyright (c) .NET Core Community. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information. // Licensed under the MIT License. See License.txt in the project root for license information.


using System.Threading.Tasks;

namespace DotNetCore.CAP.Dashboard namespace DotNetCore.CAP.Dashboard
{ {
public interface IDashboardAuthorizationFilter public interface IDashboardAuthorizationFilter
{ {
bool Authorize(DashboardContext context);
Task<bool> AuthorizeAsync(DashboardContext context);
} }
} }

Loading…
Cancel
Save