I released today first new Nuget package connected to my new project that I am working on for sometime: dynamically configurable, zero-downtime API, with low-code flows to write small pieces of logic - Hamster Wheel.
Two weeks ago I was running out of space on my main raid matrix on my server. Server was configured and assembled few years back, and at that time I had about 700GB of data there so having RAID 10 of 4 1TB disks (that account for about 1,7TB of actual space for data) was enough. Especially when you count in a price of 2TB (or 4TB) NVME M2 disk back then.
Lately I decided to try Podman Quadlets. It seemed to be really interesting way to achieve similar results as with Docker and Compose, but it have nicer integration with the system (i.e. ability to see container in Cockpit along with other systemd services, or triggering container by socket, so less frequently used containers won’t be running all the time).
Everything went fine except for unavailability of buildah package in Debian stable apt channel (or the version that were needed for podman at least). Quick search on the internet and I found the answer is to reference this specific package from the testing channel of apt.
What is the difference between monitoring and observability?
Monitoring is process of collecting live events from your application, traces, debug messages, warnings and exceptions. The same process may involve sending those events to some storage or application that analyze or visualize those messages. I.e. in asp.net core applications monitoring of application involves calling a ILogger and sending those logs or critical exceptions to AppInsights. Monitoring may also involve activity of development team members to active watch those logged messages for any potential errors or problems that may impact availability of production environment.
The single-responsibility principle - piece of software should have only one responsibility The open–closed principle - things should be open for extension but closed for modification The Liskov substitution principle - changing interface implementation should not brake software The interface segregation principle - it is better to have more specialized interfaces than single big one The dependency inversion principle - dependencies should be abstracted via interfaces Further read:
https://en.wikipedia.org/wiki/SOLID
Custom implementation is usually only necessary if default, reference equality is not enough. In example:
entities value based equality value equality of deserialized objects custom comparisons based on other criterias public class ImaginaryNumber : IEquatable<ImaginaryNumber> { public double RealNumber { get; set; } public double ImaginaryUnit { get; set; } public override bool Equals(object obj) { return Equals(obj as ImaginaryNumber); } public bool Equals(ImaginaryNumber other) { return other != null && RealNumber == other.RealNumber && ImaginaryUnit == other.ImaginaryUnit; } public override int GetHashCode() { return HashCode.Combine(RealNumber, ImaginaryUnit); } }
Controller type inherits from ControllerBase and have Views support ControllerBase type is better suited for APIs Further read:
https://learn.microsoft.com/en-us/aspnet/core/web-api/?view=aspnetcore-6.0
default application server for .net cross platform best performance and memory utilization may not have some advanced features of HTTP.sys on Windows may be used with proxy server or as internet facing server Further read:
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-6.0
To handle exceptions on Controller/Action level Exception Filters are used.
[TypeFilter(typeof(SampleExceptionFilter))] public class ExceptionController : Controller Exception Filters are implemented using IExceptionFilter with OnExcetion method override to handle exceptions.
Exception Filters can be applied to Controller and Action level.
Further read:
https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-7.0#exception-filters https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.filters.iexceptionfilter?view=aspnetcore-7.0
To add global exception handling in ASP.NET Core just use configuration method:
app.UseExceptionHandler
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/error-handling?view=aspnetcore-6.0#exception-handler-lambda
Pretty much everything. Default ASP.NET Core request handling pipeline is consisting of bunch of middlewares:
Authentication Authorization CORS HTTP Logging MVC Static Files other Whole list of built-in middlewares can be found here:
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-7.0#built-in-middleware There is possibility to write custom middleware too.
app.Use(async(context,next)=>{// Do work that can write to the Response.awaitnext.Invoke();// Do logging or other work that doesn't write to the Response.});
Pure OWIN Middleware:
This rather would be used to integrate with OWIN middlewares written in different language, so that ASP.NET Core implementation directly is not possible.
defines standard way for middleware to be used in a pipeline to handle requests and provide responses
ASP.NET Core applications can interoperate with OWIN-based applications, servers and middleware
Microsoft.AspNetCore.Owin package provides two adapter implementations:
ASP.NET Core to OWIN
OWIN to ASP.NET Core
This allows ASP.NET Core to be hosted on top of an OWIN compatible server/host or for other OWIN compatible components to be run on top of ASP.NET Core.
each node is expression (method call, equality comparison, binary operation etc.) representing a piece of code
you can compile expression tree and run code it represent
enables dynamic code generation at runtime
LINQ queries on DBs are implemented with Expression Trees
used in the dynamic language runtime (DLR)
anonymous lambda expression can be converted to ExpressionTree via compiler (i.e. x => x*2 can be represented as tree instead of delegate or anonymous lambda function)