Minimal API vs Standard API
The ArconQ SDK provides two options for building applications: Minimal API and Standard API. Minimal API is a new feature in .NET 6 that allows users to create simple applications without the need for additional configuration. Minimal API utilizes a function-based approach for defining endpoints, eliminating the need for controllers, routing, and other complex structures. On the other hand, the Standard API is the traditional approach to developing .NET applications, which includes additional features and tools such as controllers and routers to create more complex applications.
Differences in solutions
Minimal API is better for developing simple applications or prototypes because it allows you to create applications quickly and easily without having to write a lot of code. Minimal API achieves it by using simple and concise designs that allow you to create applications in a more integrated and consistent way and is ideal for rapid prototyping and for creating applications that don't require complex configuration.Standard API is better for developing more complex applications that require more control over configuration and available functionality. It offers more powerful tools and functionality that allow you to customize your application. The Standard API allows you to configure and modify more elements of your application, such as middleware, routing, dependency injection and more. It gives the developer full control over every aspect of the application and allows him to customize it according to his needs.
How it works
In the Minimal API, to start the ArconQ application, call the StartAsync method, which takes arguments in the form of an array of character strings. Then you need to register the required services, such as services and message handlers, using the AddScoped, AddMessageHandler and AddScheduledJob methods. You can also configure the schedule on which the scheduled tasks will be executed using the SetCronSchedule method.Example application code in Minimal API:
await ArconQApp.StartAsync(args,
services =>
{
services.AddScoped<IMyService, MyService>();
services.AddMessageHandler<MyMessageHandler, MyMessage>().WithRoutingId("CustomRoutingId");
services.AddScheduledJob<MyScheduledJob>().WithIntervalSchedule(10, IntervalType.Seconds);
});
In the Standard API, create a WebApplication class object using the CreateBuilder method, and then configure the services using the AddArconQ method. Next, register the required services, such as services and message handling procedures, using the AddScoped, AddMessageHandler and AddScheduledJob methods. You can also configure the schedule on which the scheduled tasks will be executed, using the SetCronSchedule method. Finally, call the UseArconQ and MapArconQ methods to register the application endpoints and run the application using the RunAsync method.
Example application code in Standard API:
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureArconQ(builder.Configuration);
builder.Services.AddArconQ(builder.Configuration);
builder.Services.AddScoped<IMyService, MyService>();
builder.Services.AddMessageHandler<MyMessageHandler, MyMessage>().WithRoutingId("CustomRoutingId");
builder.Services.AddScheduledJob<MyScheduledJob>().WithIntervalSchedule(10, IntervalType.Seconds);
var app = builder.Build();
app.UseArconQ();
app.MapArconQ();
await app.RunAsync();