diff --git a/config-server/src/main/resources/config/limits-service.yml b/config-server/src/main/resources/config/limits-service.yml new file mode 100644 index 0000000..67fff3c --- /dev/null +++ b/config-server/src/main/resources/config/limits-service.yml @@ -0,0 +1,17 @@ +eureka: + client: + serviceUrl: + defaultZone: http://localhost:8100/eureka/ + registerWithEureka: true + fetchRegistry: true + instance: + preferIpAddress: true + +management: + endpoints: + web: + exposure: + include: '*' + +server: + port: 8300 \ No newline at end of file diff --git a/limits-service/src/main/java/com/jatin/springcloud/demo/limitsservice/LimitsServiceApplication.java b/limits-service/src/main/java/com/jatin/springcloud/demo/limitsservice/LimitsServiceApplication.java new file mode 100644 index 0000000..2532bec --- /dev/null +++ b/limits-service/src/main/java/com/jatin/springcloud/demo/limitsservice/LimitsServiceApplication.java @@ -0,0 +1,17 @@ +package com.jatin.springcloud.demo.limitsservice; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.context.config.annotation.RefreshScope; +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; + +@RefreshScope +@EnableEurekaClient +@SpringBootApplication +public class LimitsServiceApplication { + + public static void main(String[] args) { + SpringApplication.run(LimitsServiceApplication.class, args); + } + +} diff --git a/limits-service/src/main/java/com/jatin/springcloud/demo/limitsservice/controller/LimitsController.java b/limits-service/src/main/java/com/jatin/springcloud/demo/limitsservice/controller/LimitsController.java new file mode 100644 index 0000000..cfb66cb --- /dev/null +++ b/limits-service/src/main/java/com/jatin/springcloud/demo/limitsservice/controller/LimitsController.java @@ -0,0 +1,27 @@ +package com.jatin.springcloud.demo.limitsservice.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import com.jatin.springcloud.demo.limitsservice.service.LimitsService; + +@RestController +public class LimitsController { + + @Autowired + private LimitsService limitsService; + + @GetMapping("/limit") + public long getLimit() { + return limitsService.getLimit(); + } + + @PostMapping("/limit") + public long updateLimit(@RequestBody long amount) { + return limitsService.updateLimit(amount); + } + +} diff --git a/limits-service/src/main/java/com/jatin/springcloud/demo/limitsservice/service/LimitsService.java b/limits-service/src/main/java/com/jatin/springcloud/demo/limitsservice/service/LimitsService.java new file mode 100644 index 0000000..8280a10 --- /dev/null +++ b/limits-service/src/main/java/com/jatin/springcloud/demo/limitsservice/service/LimitsService.java @@ -0,0 +1,20 @@ +package com.jatin.springcloud.demo.limitsservice.service; + +import java.util.concurrent.atomic.AtomicLong; + +import org.springframework.stereotype.Service; + +@Service +public class LimitsService { + + private AtomicLong limit = new AtomicLong(1_000_000); + + public long getLimit() { + return limit.get(); + } + + public long updateLimit(long amount) { + return limit.addAndGet(amount); + } + +} diff --git a/limits-service/src/main/resources/bootstrap.yml b/limits-service/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..af7f84e --- /dev/null +++ b/limits-service/src/main/resources/bootstrap.yml @@ -0,0 +1,6 @@ +spring: + application: + name: limits-service + cloud: + config: + uri: http://localhost:8000 diff --git a/limits-service/src/main/resources/logback.xml b/limits-service/src/main/resources/logback.xml new file mode 100644 index 0000000..5a5ce62 --- /dev/null +++ b/limits-service/src/main/resources/logback.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file