Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions mcp-client/src/main/java/core/mcpclient/config/BedrockConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.springframework.context.annotation.Profile;
import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeAsyncClient;
import software.amazon.awssdk.services.bedrockruntime.BedrockRuntimeClient;

import java.time.Duration;
Expand Down Expand Up @@ -50,6 +51,26 @@ public BedrockRuntimeClient bedrockRuntimeClient() {
return client;
}

@Bean
public BedrockRuntimeAsyncClient bedrockRuntimeAsyncClient() {
log.info("🤔 Creating BedrockRuntimeAsyncClient");
log.info("📝 Region: {}", awsConnectionProperties.getRegion());

Duration timeout = awsConnectionProperties.getTimeout();
log.info("📝 Timeout: {}", timeout);

BedrockRuntimeAsyncClient client = BedrockRuntimeAsyncClient.builder()
.region(Region.of(awsConnectionProperties.getRegion()))
.credentialsProvider(DefaultCredentialsProvider.builder().build())
.overrideConfiguration(config -> config
.apiCallTimeout(timeout)
.apiCallAttemptTimeout(timeout))
.build();

log.info("✅ BedrockRuntimeAsyncClient created\n");
return client;
}
Comment on lines +54 to +72
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

코드 중복을 줄이기 위한 리팩토링을 고려해보세요.

bedrockRuntimeClient()bedrockRuntimeAsyncClient() 메서드 간에 로직이 거의 동일합니다. 공통 설정 로직을 헬퍼 메서드로 추출하여 유지보수성을 개선할 수 있습니다.

예시 리팩토링:

private <T> T createBedrockClient(
        java.util.function.Function<software.amazon.awssdk.core.client.config.ClientOverrideConfiguration.Builder, 
        software.amazon.awssdk.core.client.config.ClientOverrideConfiguration.Builder> configurer,
        java.util.function.Supplier<T> clientBuilder,
        String clientType) {
    log.info("🤔 Creating {}", clientType);
    log.info("📝 Region: {}", awsConnectionProperties.getRegion());
    
    Duration timeout = awsConnectionProperties.getTimeout();
    log.info("📝 Timeout: {}", timeout);
    
    log.info("✅ {} created\n", clientType);
    return clientBuilder.get();
}

하지만 현재 구조에서는 빌더 API의 차이로 인해 완벽한 추상화가 어려울 수 있으므로, 현재 상태를 유지하는 것도 합리적인 선택입니다.

🤖 Prompt for AI Agents
In mcp-client/src/main/java/core/mcpclient/config/BedrockConfig.java around
lines 54 to 72, the bedrockRuntimeClient() and bedrockRuntimeAsyncClient()
methods duplicate region/timeout logging and overrideConfiguration setup;
extract that shared logic into a small private helper (e.g.,
prepareCommonBedrockConfig or configureCommonBuilder) that logs region and
timeout, obtains the Duration, and returns or applies the common
ClientOverrideConfiguration/credentials/region settings so each bean method just
calls the helper and then calls the specific builder.build(); update both
methods to use the helper to remove duplication while preserving existing
behavior and logging.


@Bean
public BedrockChatOptions bedrockChatOptions() {
log.info("🤔 Creating BedrockChatOptions");
Expand Down