-
Notifications
You must be signed in to change notification settings - Fork 175
Refactor service configuration by updating LoadBalanced annotation usage and enhancing error handling in ApiExceptionHandler #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Narendra0504
wants to merge
2
commits into
hoangtien2k3:main
Choose a base branch
from
Narendra0504:2026-01-28-un8o
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Binary file not shown.
This file contains hidden or 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
This file contains hidden or 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
13 changes: 6 additions & 7 deletions
13
discovery-service/src/main/resources/application.properties
This file contains hidden or 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 |
|---|---|---|
| @@ -1,11 +1,10 @@ | ||
| # default port for eureka server | ||
| server.port=8761 | ||
| # default port for consul server | ||
| server.port=8500 | ||
|
|
||
| spring.application.name=DISCOVERY-SERVICE | ||
|
|
||
| eureka.instance.hostname=localhost | ||
| eureka.client.register-with-eureka=false | ||
| eureka.client.fetch-registry=false | ||
| spring.cloud.consul.host=localhost | ||
| spring.cloud.consul.port=8500 | ||
|
|
||
| # Eureka server url | ||
| eureka.client.serviceUrl.defaultZone=${EUREKA_URI:http://localhost:8761/eureka} | ||
| spring.cloud.consul.discovery.register=true | ||
| spring.cloud.consul.discovery.health-check-interval=10s | ||
This file contains hidden or 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
81 changes: 57 additions & 24 deletions
81
...ite-service/src/main/java/com/hoangtien2k3qx1/favouriteservice/config/Swagger2Config.java
This file contains hidden or 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 |
|---|---|---|
| @@ -1,36 +1,69 @@ | ||
| package com.hoangtien2k3qx1.favouriteservice.config; | ||
|
|
||
| import io.swagger.v3.oas.models.Components; | ||
| import io.swagger.v3.oas.models.OpenAPI; | ||
| import io.swagger.v3.oas.models.info.Contact; | ||
| import io.swagger.v3.oas.models.info.Info; | ||
| import io.swagger.v3.oas.models.info.License; | ||
| import io.swagger.v3.oas.models.servers.Server; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.web.servlet.config.annotation.EnableWebMvc; | ||
| import springfox.documentation.builders.ApiInfoBuilder; | ||
| import springfox.documentation.builders.PathSelectors; | ||
| import springfox.documentation.builders.RequestHandlerSelectors; | ||
| import springfox.documentation.service.ApiInfo; | ||
| import springfox.documentation.service.Contact; | ||
| import springfox.documentation.spi.DocumentationType; | ||
| import springfox.documentation.spring.web.plugins.Docket; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Configuration | ||
| @EnableWebMvc | ||
| public class Swagger2Config { | ||
|
|
||
| @Value("${server.port:8080}") | ||
| private String serverPort; | ||
|
|
||
| @Value("${spring.application.name:favourite-service}") | ||
| private String applicationName; | ||
|
|
||
| @Bean | ||
| public Docket api() { | ||
| return new Docket(DocumentationType.SWAGGER_2).select() | ||
| .apis(RequestHandlerSelectors.any()) | ||
| .paths(PathSelectors.any()) | ||
| .build() | ||
| .apiInfo(apiEndPointsInfo()); | ||
| public OpenAPI customOpenAPI() { | ||
| return new OpenAPI() | ||
| .info(apiInfo()) | ||
| .servers(getServers()); | ||
| } | ||
|
|
||
| private ApiInfo apiEndPointsInfo() { | ||
| return new ApiInfoBuilder() | ||
| .title("FAVORITE-SERVICE API") | ||
| .description("API Documentation's FAVORITE-SERVICE") | ||
| .contact(new Contact("hoangtien2k3", "https://hoangtien2k3qx1.github.io/", "hoangtien2k3qx1@gmail.com")) | ||
| .license("Apache 2.0") | ||
| .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") | ||
| private Info apiInfo() { | ||
| return new Info() | ||
| .title("FAVORITE SERVICE API") | ||
| .description(""" | ||
| ## Favorite Service API Documentation | ||
|
|
||
| This service handles all favorite-related operations including: | ||
| - Managing user favorites | ||
| - Tracking favorite items | ||
| - Favorite lists and collections | ||
|
|
||
| ### Features | ||
| - Add/remove items to favorites | ||
| - Organize favorites into lists | ||
| - Share favorite collections | ||
| - Integration with product and user services | ||
| """) | ||
| .version("1.0.0") | ||
| .build(); | ||
| .contact(new Contact() | ||
| .name("hoangtien2k3") | ||
| .url("https://hoangtien2k3qx1.github.io/") | ||
| .email("hoangtien2k3qx1@gmail.com")) | ||
| .license(new License() | ||
| .name("Apache 2.0") | ||
| .url("http://www.apache.org/licenses/LICENSE-2.0.html")); | ||
| } | ||
|
|
||
| private List<Server> getServers() { | ||
| Server localServer = new Server() | ||
| .url("http://localhost:" + serverPort) | ||
| .description("Local development server"); | ||
|
|
||
| Server productionServer = new Server() | ||
| .url("https://api.yourdomain.com/favourite-service") | ||
| .description("Production server"); | ||
|
|
||
| return List.of(localServer, productionServer); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
70 changes: 70 additions & 0 deletions
70
inventory-service/src/main/java/com/hoangtien2k3/inventoryservice/config/OpenApiConfig.java
This file contains hidden or 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,70 @@ | ||
| package com.hoangtien2k3.inventoryservice.config; | ||
|
|
||
| import io.swagger.v3.oas.models.Components; | ||
| import io.swagger.v3.oas.models.OpenAPI; | ||
| import io.swagger.v3.oas.models.info.Contact; | ||
| import io.swagger.v3.oas.models.info.Info; | ||
| import io.swagger.v3.oas.models.info.License; | ||
| import io.swagger.v3.oas.models.servers.Server; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Configuration | ||
| public class OpenApiConfig { | ||
|
|
||
| @Value("${server.port:8080}") | ||
| private String serverPort; | ||
|
|
||
| @Value("${spring.application.name:inventory-service}") | ||
| private String applicationName; | ||
|
|
||
| @Bean | ||
| public OpenAPI customOpenAPI() { | ||
| return new OpenAPI() | ||
| .info(apiInfo()) | ||
| .servers(getServers()); | ||
| } | ||
|
|
||
| private Info apiInfo() { | ||
| return new Info() | ||
| .title("INVENTORY SERVICE API") | ||
| .description(""" | ||
| ## Inventory Service API Documentation | ||
|
|
||
| This service handles all inventory-related operations including: | ||
| - Product inventory management | ||
| - Stock level tracking | ||
| - Inventory updates and synchronization | ||
| - Product availability checks | ||
|
|
||
| ### Features | ||
| - Real-time inventory tracking | ||
| - Multi-warehouse support | ||
| - Stock alerts and notifications | ||
| - Integration with order and product services | ||
| """) | ||
| .version("1.0.0") | ||
| .contact(new Contact() | ||
| .name("hoangtien2k3") | ||
| .url("https://hoangtien2k3qx1.github.io/") | ||
| .email("hoangtien2k3qx1@gmail.com")) | ||
| .license(new License() | ||
| .name("Apache 2.0") | ||
| .url("http://www.apache.org/licenses/LICENSE-2.0.html")); | ||
| } | ||
|
|
||
| private List<Server> getServers() { | ||
| Server localServer = new Server() | ||
| .url("http://localhost:" + serverPort) | ||
| .description("Local development server"); | ||
|
|
||
| Server productionServer = new Server() | ||
| .url("https://api.yourdomain.com/inventory-service") | ||
| .description("Production server"); | ||
|
|
||
| return List.of(localServer, productionServer); | ||
| } | ||
| } |
36 changes: 0 additions & 36 deletions
36
inventory-service/src/main/java/com/hoangtien2k3/inventoryservice/config/Swagger2Config.java
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
media-service/src/main/java/com/hoangtien2k3/media/config/Hoangtien2k3Config.java
This file contains hidden or 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,15 @@ | ||
| package com.hoangtien2k3.media.config; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.context.annotation.Configuration; | ||
|
|
||
| @Configuration | ||
| public class Hoangtien2k3Config { | ||
|
|
||
| @Value("${app.public-url:http://localhost:8080}") | ||
| private String publicUrl; | ||
|
|
||
| public String publicUrl() { | ||
| return publicUrl; | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.