Streams, Pipes and gRPC

.NET 7 introduces new methods for Stream type: ReadExactly(...), ReadAtLeast(...) and their async counterparts allow the developers to await 'enough' data to be present for further processing input streams.

At the time of writing this post .NET 7 is still in preview bits. Which means there is still a chance that these methods will not be released.

Why do we have it?

At first these methods may seem a surplus, as developers have been using streams for many years, so why would we need them? There are several workloads in software stack that fits perfectly with this concept. Or rather say payloads instead of workloads.

Find out more


Palindrome as an Interview Question

Palindrome often comes up as an interview question. In this post I will investigate 3 implementations and their relative performance.

What is a palindrome? Wikipedia says A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward, such as madam or racecar.

It is quite common to ask an interview candidate to implement a function to check if a given string is a palindrome. In this blog post I will show 4 different implementations. While these implementations might not handle all use cases identically, they satisfy a set of testcases to make sure they all work correctly based on a common interpretation.

Simple

Find out more


Rate Limiting Streaming gRPC Calls

In this post I investigate implementing rate limiting with .NET 7 for gRPC streaming messages. In my previous post I looked into how to apply rate limiting on gRPC requests (unary or streaming).

When we apply the ASP.NET Core rate limiting middleware to gRPC services, we can limit the rate of incoming requests. However, if the request is a long running (client stream, server streaming or duplex) we cannot limit the rate of messages sent.

In this post I create a sample rate limiter for ASP.NET Core gRPC streaming services. The limiter is built on top of .NET 7's rate limiting API.

When would I need to rate limit the incoming messages? For example clients sending long running requests with streaming data can rate limited per endpoint or per resource accessed.

Find out more


ASP.NET Core Rate Limiting with gRPC

ASP.NET Core with .NET 7 adds an interesting new feature: rate limiting. In this post, I will look into how to apply rate limiting for gRPC services with ASP.NET Core.

At the time of writing this post, the code samples are based on .NET 7 RC2.

Rate Limiting with ASP.NET Core WebApi

We can find multiple demos on applying Rate Limiting on minimal APIs. However, it is less frequently demo-ed on how to apply rate limiting on controllers. Fortunately, the documentation details this scenario. Let me quickly recap.

Find out more


GitHub Actions Template for .NET NuGet packages

This post outlines the template workflows I use for GitHub Actions to build, test and deploy .NET nuget packages.

It consists of two workflows, CI and CD. As these are templates, each repo will require some level of customization, but the structure remains relatively similar. Each step is denoted the with the current up-to-date version of the action available at the time of writing this post.

Continuous Integration

Continuous Integration (CI) is responsible for builds when new Pull Requests are opened, new commits are pushed, or master gets updated (for example a Pull Request is merged). CI is triggered on push or by workflow_dispatch which means a manual trigger.

Find out more