Skip to content

Commit

Permalink
update limits service
Browse files Browse the repository at this point in the history
  • Loading branch information
jatingala committed Jun 12, 2022
1 parent ec5899f commit 596add7
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 0 deletions.
17 changes: 17 additions & 0 deletions config-server/src/main/resources/config/limits-service.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -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);
}

}
6 changes: 6 additions & 0 deletions limits-service/src/main/resources/bootstrap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spring:
application:
name: limits-service
cloud:
config:
uri: http://localhost:8000
8 changes: 8 additions & 0 deletions limits-service/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</configuration>

0 comments on commit 596add7

Please sign in to comment.