When we need to run a task after certain period of time, at a given time, on intervals etc, we need to use task scheduling system that is responsible for running tasks like; sending emails, push notifications, closing accounts at midnight, clearing tables etc.
In this story, we will build basic event scheduler that can schedule event to run after certain period of time using database as a persisting layer that will give us some understanding how event scheduling system might work. The basic working mechanism is that;
Whenever we need to schedule the event, the scheduled job is added…
Containerizing development environment has it’s own benefits like having the same dependencies as the deployment machine which solves most of the “works on my machine but not on deployment server” problems. In this story, I will explain how I was able to make debugging and live reload possible for go-gin development and It will be similar for other development environment as well.
I was searching for debug capability as well as code reload facility in go docker container for a project but couldn’t find one that fits my needs. I tried several methods like using compile daemon and delve (go…
One of the major point in SOLID principle is Dependency Injection where dependencies are injected into one another making them more flexible for development. We can implement dependency injection ourselves and manually instantiate objects but what a headache it will be managing the dependencies — Creating and Passing Objects from one to another.
Go-Fx solves this major problem by providing us a dependency injection container that will create the dependency graph for us and inject the dependencies that we want easily.
Let’s start by injecting simple dependencies like; string and logger. For this we will create custom types
In computation theory, the Finite State Machine (FSM) is those machines that can have a finite number of states at a given time. These machines are used in our daily life such as; vending machines, elevators, traffic lights, etc. Not only in hardware these machines are used in the software also.
They are the process to model stateful, reactive systems i.e in behavior-driven development. FSM based programming is a powerful tool to model complicated state transitions, it could significantly simplify our programs.
For a functional programming standpoint, FSM is a function that takes in four parameters; initial state, transition function…
Chart.JS is a popular java script charting library. Various kinds of Charts can be built with it but when I was searching for building Pyramid Chart (Stacked Bar Chart), I couldn’t find any tutorials that shows how to build the chart I wanted using
chart.js so, this story shows how I built the pyramid chart.
TL;DR: Use negative values for one data set and then customize tool tips and x-axis ticks to show positive numbers although they are negative numbers.
Server-Sent Events (SSE) can be used to send data from server to the client in uni directional manner that will be useful for use cases such as; logging, live feed etc. In this story, we will be using server sent events for receiving logging information from the server and display it in client.
For this, we will require a publish-subscribe system where any request to stream end point subscribes to event and on any event all the subscribers subscribed to event will get notified.
To build broadcasting system, we will be using channels for go routines communication. With react, we…
In this story, we are trying to create a simple console chat application that is built using go lang and grpc. This article assumes that you have some knowledge about grpc and how to compile your protobuf files. If you don’t know how to compile
protobuf files for go. You can learn the basics about it here.
With any grpc application, we need to define schema for how we are planning to send the data. To do that, we need to answer some questions like;
When we need to work with variables at run time using information that didn’t exist when the program was written or we might need to create variables at run time for test cases in these situations we might need to use reflection. Reflection will become your go-to tool when ever you are working with generic designs.
In a nutshell, Reflections allows to examine, modify and create variables, structs, and functions at program run time.
In this tutorial, we are planning to build our own GET request to struct parser to understand about how reflections can be used in go lang.