Skip to content

v5.35 Release

Choose a tag to compare

@github-actions github-actions released this 05 Mar 06:07
· 911 commits to main since this release

❇️ Help Keep FastEndpoints Free & Open-Source ❇️

Due to the current unfortunate state of FOSS, please consider becoming a sponsor and help us beat the odds to keep the project alive and free for everyone.


New 🎉

Bypass endpoint caching for integration tests

You can now easily test endpoints that have caching enabled, by using a client configured to automatically bypass caching like so:

var antiCacheClient = App.CreateClient(new() { BypassCaching = true });
Mark properties as "bind required"

You can now make the request binder automatically add a validation failure when binding from route params, query params, and form fields by decorating the dto properties if the binding source doesn't provide a value:

sealed class MyRequest
{
    [QueryParam(IsRequired = true)]
    public bool Correct { get; set; }

    [RouteParam(IsRequired = true)]
    public int Count { get; set; }

    [FormField(IsRequired = true)]
    public Guid Id { get; set; }
}
Generic command support for job queues

Closed generic commands can now be registered like so:

app.Services.RegisterGenericCommand<QueueCommand<OrderCreatedEvent>, QueueCommandHandler<OrderCreatedEvent>>();

and then be queued as jobs like so:

await new QueueEventCommand<OrderCreatedEvent>()
{ 
  ...
}.QueueJobAsync();

Note: Open generic commands are not supported for job queueing.

Inter-Process-Communication via Unix-Domain-Sockets

The FastEndpoints.Messaging.Remote library can now do inter-process-communication via unix sockets when everything is running on the same machine by doing the following:

//server setup
bld.WebHost.ConfigureKestrel(k => k.ListenInterProcess("ORDERS_MICRO_SERVICE"));

//client setup
app.MapRemote("ORDERS_MICRO_SERVICE", c => c.Register<CreateOrderCommand>());

When a service is lifted out to a remote machine, all that needs to be done is to update the connection settings like so:

//server
bld.WebHost.ConfigureKestrel(k => k.ListenAnyIP(80, o => o.Protocols = HttpProtocols.Http2);

//client
app.MapRemote("http://orders.my-app.com", c => c.Register<CreateOrderCommand>());
Optionally save command type on job storage record

A new optional/addon interface IHasCommandType has been introduced if you need to persist the full type name of the command that is associated with the job storage record. Simply implement the new interface on your job storage record and the system will automatically populate the property value before being persisted.

Improvements 🚀

RPC Event Subscriber parallel execution

Event subscribers used to execute the event handlers in sequence when a batch of event storage records were fetched from the storage provider.
The handlers will now be executed in parallel just like how parallel execution happens in job queues.

RPC Event Hub startup sequence

The rpc event hub was using a thread sleep pattern during startup to restore subscriber IDs via the storage provider, resulting in a sequential initialization.
It has been refactored to use an IHostedService together with retry logic for a proper async and parallel initialization, resulting in decreased startup time.

RPC Event Hub event distribution

Previously if a hub was not registered before events were broadcasted, or if event serialization fails due to user error, those exceptions would have been swallowed in some cases.
The internals of the hub has been refactored to surface those exceptions when appropriate.

Workaround for NSwag quirk with byte array responses

NSwag has a quirk that it will render an incorrect schema if the user does something like the following:

b => b.Produces<byte[]>(200, "image/png");

In order to get the correct schema generated, we've had to do the following:

b => b.Produces<IFormFile>(200, "image/png");

You now have the ability to do either of the above, and it will generate the correct schema.

Fixes 🪲

Job result is null when job execution failure occurs

The result property of job records that was passed into the OnHandlerExecutionFailureAsync() method of the storage provider was null due to an oversight, which has been corrected.

Parallel 'VersionSet' creation issue

If VersionSets are created by multiple SUTs at the same time when doing integration testing, a non-concurrent dictionary modification exception was being thrown.
The internal dictionary used to keep track of the version sets has been changed to a concurrent dictionary which solves the issue.

Breaking Changes (Minor) ⚠️

'IEventHubStorageProvider' contract change

In order to improve database write performance, the IEventHubStorageProvider.StoreEventAsync(TStorageRecord r, CancellationToken ct) method signature has been changed to the following:

ValueTask StoreEventsAsync(IEnumerable<TStorageRecord> r, CancellationToken ct);

Previously, records were persisted one at a time. Now, the records are supplied in batches allowing you to take advantage of batched inserts and/or transactions improving database write performance and consistency.

NOTE: You should make sure either none or all of the supplied records are persisted to disk in order to avoid duplicate events being published due to the built-in retry mechanism.

'IEvent.Broadcast()' extension method is no longer cancellable

The BroadCast() method is now a fire-n-forget method and no longer accepts a CancellationToken, which simplifies event publication.