Posted on: November 6, 2022 Posted by: rahulgite Comments: 3,255

12-factor app design principles

The Twelve Factors I. Codebase One codebase tracked in revision control, many deploys II. Dependencies Explicitly declare and isolate dependencies III. Config Store config in the environment IV. Backing services Treat backing services as attached resources V. Build, release, run Strictly separate build and run stages VI. Processes Execute the app as one or more stateless processes VII. Port binding Export services via port binding VIII. Concurrency Scale out via the process model IX. Disposability Maximize robustness with fast startup and graceful shutdown X. Dev/prod parity Keep development, staging, and production as similar as possible…

Loading

Posted on: July 8, 2022 Posted by: rahulgite Comments: 3,417

Getting started with Android Development

Download Android Studio Stable Release: https://developer.android.com/studio Once it is downloaded and installed open SDK Manager Installed the below packages for any recent android version from the SDK platform tab (NOTE: Click on show package details to expand inner packages) Below are Tools for SDK Tools We are ready with the environment for android development.

Loading

Posted on: March 29, 2022 Posted by: rahulgite Comments: 3,320

Kotlin

GitHub – https://github.com/rahulgite/Kotlin Why a New JVM Language? Wordy and full of boilerplate Requires tedious getters and setters Difficult to avoid null pointer exceptions Lacks many modern programming features Why Kotlin? 100% compatible with Java. Eliminates most null pointer exceptions. The syntax is clean and easy to read. Modern features like smart casting. The easiest way to get a taste of Kotlin on https://play.kotlinlang.org/ Create Kotlin Project in Intellij New Project Select Gradle with below framework options Select Java Select Kotlin JVM Next Enter Project Name and Finish. The project will get built and you…

Loading

Posted on: January 28, 2022 Posted by: rahulgite Comments: 714

Angular Best Practices

Angular Best Practices Use ES6 features like let, const, arrow function Use trackby along with ngFor Use lazy loading Use index.ts file for shorter import use datatype, Avoid ‘any’ type Create own Data type using Interface Avoid memory leak by unsubscribing the observable also we can use Rxjs operator  like takeUntil() Should use Async pipe Avoid logics in the template Use Environment variable for multiple server or API call configurations Use module structure Focus on small and reusable components Declaring a variable with ‘const’ if the value is not changing Use smart and dumb Components strategies Using…

Loading

Posted on: January 28, 2022 Posted by: rahulgite Comments: 9

AWS – Basics

AWS – Amazon Web Services #AWS Amazon Web Services (AWS) is the world’s most comprehensive and broadly adopted cloud platform, offering over 200 fully-featured services from data centers globally Its Global cloud platform Infrastructure as service: provide servers, we don’t need to backup and power supply of servers. Platform as a service: We can get Java, ruby, PHP.etc., so you don’t need to manage binaries. Software as a service: We can get email sending capabilities like SES(Simple Email Service), SQS(Simple Queue Service), and lots of storage options like EBS(Elastic block store), S3 Simple storage service.…

Loading

Posted on: January 10, 2022 Posted by: rahulgite Comments: 479

Micro Front-End Architecture

What is Mirco Front-Ends? Micro front-end is just code for a portion/component of the web page. And web page hosting that component is called host page. We also have a micro front-end framework that sits between micro frontends and host page, that manages loading and unloading of micro front-ends. Advantages of Micro Front-ends Team Scalability :  Here more people will be able to work on a given webpage. Because MFEs are versioned independently deployed. So, each one of those is its own project and then theMFE would go off onto s3(Simple Storage Service) and then…

Loading

Posted on: December 29, 2021 Posted by: rahulgite Comments: 454

Google Cloud Platform

Setup GCP Go to https://cloud.google.com/ SignIn Once you are in. Click on the Console link in the top right corner. You will be provided with a checklist, click on Go to the checklist. Billing Account: set your bank account( 2 INR will be used from your account for verification purposes.) Project: Create Project to get started with google cloud Once Everything is set, you will be provided with a dashboard, it has cards that show useful information. Install GCP on the PC Visit https://cloud.google.com/sdk/docs/install I have well-documented information for all OS-based installations. Once it is…

Loading

Posted on: December 24, 2021 Posted by: rahulgite Comments: 24

Unit Testing with Spring Boot

Create a new controller and hello service import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController { @GetMapping(“/hello”) public String helloWorld(){ return “Hello World”; } } JUnit 4 Code @RunWith(SpringRunner.class) @WebMvcTest(HelloWorldController.class) JUnit 5 Code @WebMvcTest(HelloWorldController.class)   Testing Simple Hello Controller import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.RequestBuilder; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import static org.junit.jupiter.api.Assertions.*; @WebMvcTest(HelloController.class) class HelloControllerTest { @Autowired private MockMvc mockMvc; @Test void helloWorld() throws Exception { // request GET /hello and application/json RequestBuilder requestBuilder = MockMvcRequestBuilders.get(“/hello”) .accept(MediaType.APPLICATION_JSON); MvcResult result=mockMvc.perform(requestBuilder).andReturn(); //verify controller assertEquals(“Hello World”,result.getResponse().getContentAsString()); } } Controller with status and…

Loading

Posted on: December 23, 2021 Posted by: rahulgite Comments: 27

Mockito

Class to test Junit package com.unittest.unittesting.business; import com.unittest.unittesting.data.DataService; public class BusinessImpl { private DataService service; public DataService getService() { return service; } public void setService(DataService service) { this.service = service; } public int calculateSum(int data[]){ int sum=0; for(int i:data){ sum+=i; } return sum; } public int calculateSumByService(){ int data[]=service.retriveData(); int sum=0; for(int i:data){ sum+=i; } return sum; } } Basic Junit Test package com.unittest.unittesting.business; import com.unittest.unittesting.data.DataService; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; class BusinessImplTest { @Test void calculateSum() { BusinessImpl business=new BusinessImpl(); int actualResult=business.calculateSum(new int[] {1,2,3}); int expectedResult= 6; assertEquals(expectedResult,actualResult); } @Test void calculateSum_empty() { BusinessImpl…

Loading

Posted on: November 17, 2021 Posted by: rahulgite Comments: 2,001

GRPC Microservices Project Setup

Create Maven Project Add below dependencies in pom.xml ( Note: please change project name as per your project) <?xml version=”1.0″ encoding=”UTF-8″?> <project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>shopping-services</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <grpc.version>1.42.0</grpc.version> <protobuf.version>3.19.1</protobuf.version> <protoc.version>3.15.1</protoc.version> </properties> <dependencies> <!– https://mvnrepository.com/artifact/org.projectlombok/lombok –> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.22</version> <scope>provided</scope> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-netty-shaded</artifactId> <version>${grpc.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-protobuf</artifactId> <version>${grpc.version}</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-stub</artifactId> <version>${grpc.version}</version> </dependency> <dependency> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java-util</artifactId> <version>${protobuf.version}</version> </dependency> <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>annotations-api</artifactId> <version>6.0.53</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.2</version> <scope>test</scope> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.4.200</version> </dependency> </dependencies> <build> <extensions> <extension> <groupId>kr.motd.maven</groupId> <artifactId>os-maven-plugin</artifactId> <version>1.6.2</version> </extension> </extensions>…

Loading