Skip to content

Instantly share code, notes, and snippets.

View skaveesh's full-sized avatar
❤😍😒🤦‍♂️😢🐱‍👤🤳🎶😎👍😁🤞🌹🎉

Samintha Kaveesh skaveesh

❤😍😒🤦‍♂️😢🐱‍👤🤳🎶😎👍😁🤞🌹🎉
View GitHub Profile
@skaveesh
skaveesh / tremolo_converter.user.js
Last active October 18, 2023 03:39
Diatonic (10H) to Tremolo (20H) Harmonica Convertor [Suzuki Winner Harmonica]
// ==UserScript==
// @name Tremolo converter
// @namespace https://gist.github.com/skaveesh/ab93df4414732e69ad1cb0204dcb20b1
// @version 0.1
// @description try to take over the world!
// @author Samintha Kaveesh
// @match https://www.harptabs.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=harptabs.com
// @grant none
// @run-at document-end
@skaveesh
skaveesh / application.yml
Last active January 3, 2021 04:35
How I Decoupled Circuit Breaker from the Code with AOP in Spring Boot for Better Code Maintenance
resilience4j.circuitbreaker:
configs:
default:
registerHealthIndicator: true
slidingWindowSize: 15
#Configures the size of the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed.
#15 seconds since slidingWindowType is TIME_BASED
minimumNumberOfCalls: 2
@skaveesh
skaveesh / SupplierUtil.java
Last active January 3, 2021 04:36
How I Decoupled Circuit Breaker from the Code with AOP in Spring Boot for Better Code Maintenance
//code is omitted for brevity
public final class SupplierUtil {
@FunctionalInterface
public interface SupplierWithException<T, E extends Exception> {
T get() throws Throwable;
}
public static <T, E extends Exception> Supplier<T> rethrowSupplier(SupplierWithException<T, E> supplier) {
@skaveesh
skaveesh / CircuitBreakerAOPConfig.java
Last active January 3, 2021 04:36
How I Decoupled Circuit Breaker from the Code with AOP in Spring Boot for Better Code Maintenance
//code is omitted for brevity
@Aspect
@Component
public class CircuitBreakerAOPConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(CircuitBreakerAOPConfig.class);
private final CircuitBreaker circuitBreaker;
@skaveesh
skaveesh / DownstreamServiceSample.java
Last active January 3, 2021 04:36
How I Decoupled Circuit Breaker from the Code with AOP in Spring Boot for Better Code Maintenance
//code is omitted for brevity
@Service
public class DownstreamService {
private final CircuitBreaker circuitBreaker;
/**
* Instantiates a new Res 4 j service.
*/
public DownstreamService(CircuitBreakerRegistry circuitBreakerRegistry) {
@skaveesh
skaveesh / EnableCircuitBreakerScan.java
Last active January 3, 2021 04:36
How I Decoupled Circuit Breaker from the Code with AOP in Spring Boot for Better Code Maintenance
//code is omitted for brevity
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface EnableCircuitBreakerScan { }
@skaveesh
skaveesh / AOPComponentSample.java
Last active January 3, 2021 04:36
How I Decoupled Circuit Breaker from the Code with AOP in Spring Boot for Better Code Maintenance
//code is omitted for brevity
@Aspect
@Component
public class CircuitBreakerAOPConfig {
@Around("@annotation(com.skaveesh.dcb.annotation.EnableCircuitBreakerScan)")
public Object around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
Object[] args = proceedingJoinPoint.getArgs();
@skaveesh
skaveesh / ApplicationResponseEntityExceptionHandler.java
Last active January 3, 2021 04:36
How I Decoupled Circuit Breaker from the Code with AOP in Spring Boot for Better Code Maintenance
//code is omitted for brevity
@RestControllerAdvice
@Component
public class ApplicationResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationResponseEntityExceptionHandler.class);
@ExceptionHandler(CircuitBreakerDownstreamCallException.class)
public ResponseEntity<Map<String, Object>> handleException(final Exception exception, final HttpServletRequest request) {
@skaveesh
skaveesh / Controller.java
Last active January 3, 2021 04:36
How I Decoupled Circuit Breaker from the Code with AOP in Spring Boot for Better Code Maintenance
//code is omitted for brevity
@RestController("/")
public class Controller {
//code is omitted for brevity
@GetMapping(value = "calltest", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Object> callTest(){
return new ResponseEntity<>(downstreamService.callTest(), HttpStatus.OK);
@skaveesh
skaveesh / DownstreamService.java
Last active January 3, 2021 04:37
How I Decoupled Circuit Breaker from the Code with AOP in Spring Boot for Better Code Maintenance
//code is omitted for brevity
@Service
public class DownstreamService {
//code is omitted for brevity
/**
* Response from this API call will not have a delay
*