Skip to content

Releases: vipwan/Biwen.QuickApi

2.0.0 released

26 Sep 18:50
Compare
Choose a tag to compare

1.6.3 released

29 Aug 07:36
Compare
Choose a tag to compare

nuget upgrade

Full Changelog: 1.6.2...1.6.3

1.6.2 released

14 Jun 07:12
Compare
Choose a tag to compare
  1. 提供 IQuickEndpoint minimal api 扩展支持
  2. 优化验证器和绑定器实现
  3. nuget upgrade
  4. 重命名 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

22 May 14:04
Compare
Choose a tag to compare
  • 重构BaseQuickApi支持直接返回IResultTypedResult ,不再限制Rsp的BaseResponse约束
  • 移除对源生成器支持 , QuickApi当前不支持AOT特性
  • 移除对AliasAs特性支持,如果需要请直接使用JsonPropertyNameAttribute
  • 其他若干代码优化
  • IQuickEndpoint 提供对MinimalApi扩展支持
  • fix IReqBinder空绑定问题

1.5.2.1 released

15 May 17:57
Compare
Choose a tag to compare
  1. 优化调度服务和元数据存储实现 定义了MetadataStore
  2. IScheduler调度器抽象化
  3. 添加本地锁功能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

13 May 14:33
Compare
Choose a tag to compare
  1. 提供任务调度功能 #18
  2. 修复一些已知BUG
  3. 提供配置文件的内置Store
  4. 提供Schedule执行事件的订阅
    更多帮助:
    https://github.com/vipwan/Biwen.QuickApi/tree/master/Biwen.QuickApi/Scheduling

1.4.3.2 released

10 May 03:53
Compare
Choose a tag to compare

提供事件发布订阅功能 #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

21 Feb 06:48
Compare
Choose a tag to compare
  1. 修复swagger example中存在的问题
  2. 更新nuget包
  3. POST空绑定抛出异常
  4. app.UseBiwenQuickApis(); extension
  5. move base interfaces to Biwen.QuickApi.Abstractions namespace

1.4.1 released

08 Dec 07:38
Compare
Choose a tag to compare

ExecuteAsync() from Task<Rsp> to ValueTask<Rsp>

1.4.0 released

15 Nov 17:29
Compare
Choose a tag to compare

升级到NSwag14以及兼容NET8