Posts

Showing posts from 2021

Git Squash: Keep Clean of Your Git Commit History

Image
  I magine, you are assigned to write a new feature of the main product. How do you start? You copy the source code, start coding for feature, write, test, write, fix bugs selfly explored, optimize code, fix typos or such minor task,s and time to time you have to commit your changes so that you don’t lose the valuable work you have done for the feature. So, we can guess, you may have commits of test code, some type fixing commit, commit of missing comments etc. At last, you have completed your feature! Wow! Gre a t work! But wait! You want to have a look at your commit history and applied: git log - -oneline Facepalm situation! You got all your commits including minor changes, typos, bug fixing, code-comment all types of commits in separate commits! How the hell shall I clean my messy commit history? Feels awkward, right? No worries buddy! Git has given us the power to present them nicely, combined them into a single commit. This way, you can group your commits so that you don’t have

Spring Boot Scheduler for Distributed System: Using shedlock

Image
  When we want to execute something on a routine/scheduled basis, we need something which can automatically do such an operation if our app is running on the server. To achieve that, we can follow one of many ways. But I prefer Spring scheduler to do my scheduled job for its user-friendly use cases.   So, for spring boot, it is very easy to set up a scheduler method. Let's configure. Please note that, in this writing, I will only mention the vital portion/code snippet for brevity. You will find the whole code linked to GitHub end of this writing. So, what we need for this? So far we don't need anything rather than basic libraries for spring boot app development. Let's configure a Scheduler class: Schedular.java: @Component @Log4j2 @EnableScheduling public class Schedular { @Scheduled(initialDelayString = "${initial.delay}", fixedDelayString = "${fixed.delay}") public void scheduledJob() { log.info("*** my schedular