Nginx and Load Balancing

In this article we will look into setting up a load balancer using Nginx. Nginx is an open source web server and reverse proxy that is quite frequently used for load balancing. We will also use simple-web, which is a simple web server that outputs IP address of source and destination, which makes it easier for … Continue reading Nginx and Load Balancing

Advertisement

Hidden gems in List Pattern

In this blog post, we will explore few hidden gems in list patterns , which was introduced with C# 11. List Pattern allows us to check patterns in arrays or list. Assign Variable You can assign variables using pattern, provided the pattern matches. For example, var arr = new [] {1,2,3,4,5}; if(arr is [_,2,var third,..] match) { … Continue reading Hidden gems in List Pattern

Install Extensions in Postgres Docker container

Recently I wanted use the Fluent migrator for seeding my postgres database, which was running as a docker container. I basically had a table User, which had a primary key of type UUID that needs to be auto-generated. My migration code looked as follows. Create.Table(User.TABLE_NAME) .WithColumn("id").AsGuid().NotNullable().WithDefaultValue(SystemMethods.NewGuid).PrimaryKey() .WithColumn("username").AsString().NotNullable() .WithColumn("password").AsString().NotNullable(); The above code would essentially turn out as the following postgres sql. … Continue reading Install Extensions in Postgres Docker container

Create Mongo Replicaset using Docker Compose

In this blog post, we will attempt to create MongoDb replicaset using docker compose. A replica set in mongodb is a group of mongod instances which maintains the same set of data. This enables applications to work despite one of the db servers going down. At every instance, there wil be only and only ONE primary node. Rest of the … Continue reading Create Mongo Replicaset using Docker Compose

Seed Postgres Database with FluentMigrator

In this blog post, we will address how to seed your Postgres Database when using FluentMigrator. In the example context, we have a Postges Database running on a docker container, and have a Web Api connecting to the database using Dapper. Dapper is a micro-orm, and while it is pretty good in what is does, … Continue reading Seed Postgres Database with FluentMigrator

Implementing Saga 002 : Message Broker

In the earlier part of this series, we created the building blocks of our microservice - the individual services. To recollect, we build 3 services, namely, Order Service, Inventory Service, and Payment Service. In this part, we will continue building our example Saga implementation. In previous post, we had created endpoints in Order Service to create an … Continue reading Implementing Saga 002 : Message Broker

Implementing Saga 001 : Building Services

In this series of post, we will build an example for Saga Pattern. We will be using the Choreography Pattern for the example. If you are interested to read more on Saga, please check out my article on Introduction to Saga Pattern. This example would use RabbitMq as the message broker. To demonstrate the pattern, let us consider the … Continue reading Implementing Saga 001 : Building Services

Compare JSON Arrays

How do you compare two similar JSON array set ? I bet that is a scenario you might have across atleast once in your developer life. Let us say you have following two sets of JSONs. Json Set 1 [ { "SourceLocation":"England", "DestinationLocation":"Spain", "DeliveryDate":"9/12" }, { "SourceLocation":"England", "DestinationLocation":"Germany", "DeliveryDate":"9/12" } ] Json Set 2 [ … Continue reading Compare JSON Arrays

The required modifier : Understand the limitations

C# 11 introduced the required modifier, which indicates that the applied peroperties and fields should be initialized by all available constructors or using object initializer. We learned more about the modifier in our earlier post. In this post, we take a look into a limitation of the functionality. Consider the following code. publicclassFoo { public required string Name {get;set;} public … Continue reading The required modifier : Understand the limitations

K-Sum – A generalized solution

In this blog post, we will attempt to address the 4-Sum problem from Leet code using the generic approach of K-Sum. Let us state the official definition of the problem. Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: 0 <= a, b, … Continue reading K-Sum – A generalized solution