Some thoughts on using Event Sourcing

Search for a command to run...

No comments yet. Be the first to comment.
In Go, variables are passed by value, which means that when we pass variables as arguments to functions, Go makes a copy of those values for the function to use. However, the behaviour of Slice can be a bit confusing at first glance, especially if we...

As someone who's been using ChatGPT for a while now, I've been exploring how to maximise its benefits and integrate it into my daily life. I've been working on a side project to develop a Discord bot that interacts with ChatGPT, similar to the one pr...

The Go net/http package provides a robust set of functionality to allow us to deal with HTTP requests and responses. However, reading the response body is a common task that requires a bit of caution. In this blog, we will explore the pitfall I exper...

Today we are going to write our own custom json.Unmarshal() method. I find it very useful and can make our code more maintainable and readable if we can make good use of type alias and the json.Unmarshal method. Let's say we want to decode a JSON-enc...

Have you ever tried to maintain services between environments and got lost in all the variables? Or even broken things by accident? Today I'm going to give you some tips on how to speed up your workflow and make things easier. My focus will be mainly...

About a year ago, I started to work with event sourcing and built a system around it. It seemed quite new to me, but the more I learned, the easier it became. Basically, I've already worked with event sourcing pattern for my entire career as a software engineer even starting at school, however, I didn't realise it at that time.
As long as you have coding experience you should be able to work with version control systems such as Git, which is a good example of event sourcing pattern. Every commit you push to Git is stored as an event representing a change state that can be added, edited or removed from files or code. This is the core concept of event sourcing where you can source back all the events that have happened in the past. As a result of this, we can revert the changes that have been made in the code from git whenever needed - Just like a time machine isn’t it ;)
The sooner you master Git the quicker it makes your life easier. It had my back a few times in my career and saved a lot of time :) I highly recommend git to those who want to work as a developer and spend some time cultivating it. I digress a little bit here. Let's talk about when to use event sourcing. It’s not a silver bullet that allows you to solve any problem, it really does add complexity to your system, so make sure you think through the goal you want to achieve that can be solved by it before adopting it.
The first scenario where you might use event sourcing is when you want full audit trails in your system, like in payment or banking. This is also the main reason why I use it in my work. We have various records and transactions including financial, accounting and medical that need to be tracked and verified.
The second is reporting. With event sourcing you have much more insight into your data and you can report retrospectively. Just like data mining, where you extract meaningful information from a collection of data.
The third scenario is parallel processing. Each microservice communicates via event messages, so they are loosely coupled without interdependence. Suppose you are looking for a highly scalable solution, this could potentially satisfy horizontal scalability and resilience to system failures.
We have gone through some use cases can be resolved by event sourcing such as audit trails, reporting or parallel processing. Are there other problems that can be solved with event sourcing? Tell me what you think and I hope this blog inspires you to explore solutions for your use cases.