-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
config-server/src/main/resources/config/limits-service.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
17 changes: 17 additions & 0 deletions
17
...vice/src/main/java/com/jatin/springcloud/demo/limitsservice/LimitsServiceApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...e/src/main/java/com/jatin/springcloud/demo/limitsservice/controller/LimitsController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
...service/src/main/java/com/jatin/springcloud/demo/limitsservice/service/LimitsService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |