Releases: vipwan/Biwen.QuickApi
Releases · vipwan/Biwen.QuickApi
2.0.0 released
Full Changelog: 1.6.1...2.0.0
1.6.3 released
nuget upgrade
Full Changelog: 1.6.2...1.6.3
1.6.2 released
- 提供
IQuickEndpoint
minimal api 扩展支持 - 优化验证器和绑定器实现
- nuget upgrade
- 重命名 BaseQuickApi 方法
BeforeAsync
.AfterAsync
定义HelloEndpoint:
[ProducesResponseType<ProblemDetails>(400)]
[ProducesResponseType<string>(200)]
public class HelloEndpoint : IQuickEndpoint
{
/// <summary>
/// 参数绑定可以实现IReqBinder<T>自定义绑定,也可以使用AsParameters在MinimalApi中默认的绑定
/// </summary>
public class HelloRequest : BaseRequest<HelloRequest>//, IReqBinder<HelloRequest>
{
[FromRoute]
public string? Hello { get; set; }
[Length(5, 12)]
[FromQuery]
public string? Key { get; set; }
}
public static Delegate Handler => ([AsParameters] HelloRequest request) =>
{
//直接返回Content
return Results.Content($"{request.Hello}. {request.Key}");
};
public static Verb Verbs => Verb.GET | Verb.POST;
}
Map HelloEndpoint:
app.MapGroup("endpoints", x =>
{
//~/endpoints/hello/hello?key=world
x.MapMethods<HelloEndpoint>("hello/{hello}");
});
Full Changelog: 1.6.1...1.6.2
1.6.1 released
- 重构BaseQuickApi支持直接返回
IResult
和TypedResult
,不再限制Rsp的BaseResponse
约束 - 移除对源生成器支持 , QuickApi当前不支持AOT特性
- 移除对AliasAs特性支持,如果需要请直接使用
JsonPropertyNameAttribute
- 其他若干代码优化
IQuickEndpoint
提供对MinimalApi扩展支持- fix
IReqBinder
空绑定问题
1.5.2.1 released
- 优化调度服务和元数据存储实现 定义了
MetadataStore
类 IScheduler
调度器抽象化- 添加本地锁功能
LocalLock
用以保证特定情况下的任务调度单次执行
public class DemoTask(ILogger<DemoTask> logger, ILocalLock @lock) : IScheduleTask
{
public async Task ExecuteAsync()
{
var timeout = TimeSpan.FromMilliseconds(30_000);
//使用ILocalLock进行锁定,防止重复执行
var (locker, _) = await @lock.TryAcquireLockAsync("ONLY_ONE_ScheduleTask_OF_DemoTask", timeout, timeout);
if (locker is null)
{
return;//当前锁定,则不执行!
}
using (locker)
{
await Task.Delay(31_000);
logger.LogInformation("Demo memory store Schedule Done!"); //todo something:
}
}
}
提供OnlyOneRunningScheduleTask
[ScheduleTask(Constants.CronEveryMinute, IsStartOnInit = true)]
public class OnlyOneTask(ILogger<OnlyOneTask> logger) : OnlyOneRunningScheduleTask
{
public override Task OnAbort()
{
logger.LogWarning($"[{DateTime.Now}]任务被打断.因为有一个相同的任务正在执行!");
return Task.CompletedTask;
}
public override async Task ExecuteAsync()
{
var now = DateTime.Now;
//模拟一个耗时2分钟的任务
await Task.Delay(TimeSpan.FromMinutes(2));
logger.LogInformation($"[{now}] ~ {DateTime.Now} 执行一个耗时两分钟的任务!");
}
}
1.5.1 released
- 提供任务调度功能 #18
- 修复一些已知BUG
- 提供配置文件的内置Store
- 提供Schedule执行事件的订阅
更多帮助:
https://github.com/vipwan/Biwen.QuickApi/tree/master/Biwen.QuickApi/Scheduling
1.4.3.2 released
提供事件发布订阅功能 #17
[QuickApi("event")]
public class EventApi : BaseQuickApi<MyEvent>
{
public override async ValueTask<IResultResponse> ExecuteAsync(MyEvent request)
{
//publish
await PublishAsync(request);
return IResultResponse.Content("send event");
}
}
订阅者支持订阅多个事件:
[EventSubscriber(IsAsync = true,Order =0, ThrowIfError =false)]
public class MyEventHandler4 : IEventSubscriber<MyEvent>, IEventSubscriber<MyEvent2>
{
private readonly ILogger<MyEventHandler4> _logger;
public MyEventHandler4(ILogger<MyEventHandler4> logger)
{
_logger = logger;
}
public Task HandleAsync(MyEvent @event, CancellationToken ct)
{
_logger.LogInformation($"muti msg 1 : {@event.Message}");
return Task.CompletedTask;
}
public Task HandleAsync(MyEvent2 @event, CancellationToken ct)
{
_logger.LogInformation($"muti msg 2 : {@event.Message}");
return Task.CompletedTask;
}
}
1.4.2.2 released
- 修复swagger example中存在的问题
- 更新nuget包
- POST空绑定抛出异常
app.UseBiwenQuickApis();
extension- move base interfaces to Biwen.QuickApi.Abstractions namespace
1.4.1 released
ExecuteAsync()
from Task<Rsp>
to ValueTask<Rsp>
1.4.0 released
升级到NSwag14以及兼容NET8