当前位置:网站首页>Cap version 6.1 Release Notice

Cap version 6.1 Release Notice

2022-06-10 15:25:00 Savorboard

Preface

today , We are pleased to announce CAP Release 6.1 Version official , In this version, we mainly focus on the several BUG Fixed and added some small features .

that , Next, let's take a specific look .

The overview

Maybe some of you don't know CAP What is it? , A brief introduction to the old ways .

CAP Is an open source project solution to solve the problem of distributed transactions in microservices or distributed systems (https://github.com/dotnetcore/CAP) It can also be used as EventBus Use , The project was born in 2016 year , Currently in Github There has been more than 5500+ Star and 70+ contributor , And in NuGet super 250 10000 Downloads , And it has been applied in the and projects of more and more companies .

If you want to be right CAP Learn more about , Please check our Official documents .

This time at CAP 6.1 In this version, we mainly bring the following new features :

  • Optimized snowflake algorithm
  • Dashboard Support customization Authorization Policy
  • Azure Service Bus Add support for deferred messages
  • Support to configure the expiration and deletion time of failure messages
  • BUG Repair
    • Repair Dashbaord Enable Challenge Verification sequence problem
    • Repair RabbitMQ When the network jitters, the health check error occurs occasionally
    • Repair MySQL 8.0 When retrying query SQL Date format error
    • Repair Redis Streams Problems with idempotence checking when reading or creating streams

Optimized snowflake algorithm

In the past, we used the standard snowflake algorithm , There will be a clock sensitive problem .

because ID The generation is always bound to the timestamp of the current operating system ( It makes use of the monotonicity of time )), So if the clock of the operating system goes back , Generated ID Will repeat , Generally, people will not manually dial back the clock , But the server will have occasional " Clock drift " The phenomenon . That is to say, in the case of multi node deployment , If the time of some servers is not accurate, duplicate keys will be generated and errors will be reported when writing messages to the database .

In this version , Unbind the time from the operating system timestamp , The generator only gets the current timestamp of the system at initialization , As the initial timestamp , But then it is no longer synchronized with the system timestamp . The increment after it , It is only driven by the increment of serial number . For example, the current value of the serial number is 4095, Next request to come in , Serial number +1 overflow 12 Bitspace , The serial number is reset to zero , The overflow carry is added to the timestamp , So that the timestamp +1.

After this version is updated , Generated Id There may be a large difference from the previous version , Just pay attention , It doesn't matter .

thank @Allen-dududu Submitted for PR!

Dashboard Support customization Authorization Policy

In this version , our Dashboard A new configuration item named AuthorizationPolicy Configuration item for , Used in scenarios where you want to use, for example, role-based authorization verification in the authorization process .

Usage is as follows , Mainly the annotated part .

services.AddAuthorization((options =>
{
   // only if you want to apply role filter to CAP Dashboard user 
   options.AddPolicy("PolicyCap", policy => policy.RequireRole("admin.events"));
}))
.AddAuthentication(options =>
{
   options.DefaultScheme =  CookieAuthenticationDefaults.AuthenticationScheme;
   options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie()
.AddOpenIdConnect(options =>
{
   options.Authority = "https://demo.identityserver.io/";
   options.ClientId = "interactive.confidential";
   options.ClientSecret = "secret";
   options.ResponseType = "code";
   options.UsePkce = true;

   options.Scope.Clear();
   options.Scope.Add("openid");
   options.Scope.Add("profile");
});

services.AddCap(cap =>
{
    cap.UseDashboard(d =>
    {
        d.UseChallengeOnAuth = true;
        d.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
        d.UseAuth = true;
        // only if you want to apply policy authorization filter to CAP Dashboard user
        d.AuthorizationPolicy = "PolicyCap";
    });
    // ***
}

thank @albertopm19 Submitted for PR!

Azure Service Bus Add support for deferred messages

stay Azure Service Bus Zhongyuan provides support for delayed message sending , That is to use its ScheduledEnqueueTimeUtc Property settings . In this version, the CAP Specify the header message during sending to take advantage of this feature .

Examples are as follows :

[HttpPost("publish")]
public async Task Publish()
{
    await _publisher.PublishAsync("demo-publish", string.Empty, new Dictionary<string, string?>
    {
        [AzureServiceBusHeaders.ScheduledEnqueueTimeUtc] = DateTimeOffset.UtcNow.AddSeconds(60).ToString(),
    });
}

thank @webinex Submitted for PR!

By the way , Some students also mentioned that RabbitMQ Support for deferred messages in , We do not support it , First, it needs to configure plug-ins to be non-native , Second, I hope you can use the scheduler (Quartz,Hangfire) Wait to do this , Professional things are left to professional components .

Support to configure the expiration and deletion time of failure messages

We have added a new configuration item FailedMessageExpiredAfter Used to configure the expiration time of failed messages , After the expiration time , The message will be deleted . The previous one is the value written dead 15 God , Now you can use this configuration item to configure .

thank @dima-zhemkov Submitted for PR!

BUG Repair

In this version , We have made some discoveries BUG Repair , Here are the repaired content items .

  • Repair Dashbaord Enable Challenge Verification sequence problem .
  • Repair RabbitMQ When the network jitters, the health check error occurs occasionally .
  • Repair MySQL 8.0 When retrying query SQL Date format error
  • Repair Redis Streams Problems with idempotence checking when reading or creating streams

summary

above , It is the support and changes we have made in this version , Thank you for your support , We're happy to be able to help . I hope you can give me positive feedback when you encounter problems in the process of using it , help CAP Get better and better .

If you like the project , You can click Star Give us support .

GitHub stars

If you think this article is helpful to you , Thank you for 【 recommend 】.


This paper addresses :http://www.cnblogs.com/savorboard/p/cap-6-1.html
The author blog :Savorboard
The original authorization of this article is : A signature - Noncommercial use - No derivatives , agreement Plain text | agreement Legal text

原网站

版权声明
本文为[Savorboard]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206101515172926.html