fix external trtc region config
This commit is contained in:
parent
f735b0a9a3
commit
41305adb9d
@ -40,6 +40,7 @@ red-circle:
|
||||
secretId: ${LIKEI_TRTC_SECRET_ID}
|
||||
secretKey: ${LIKEI_TRTC_SECRET_KEY}
|
||||
endpoint: ${LIKEI_TRTC_ENDPOINT}
|
||||
region: ${LIKEI_TRTC_REGION:ap-singapore}
|
||||
sdkAppId: ${LIKEI_TRTC_SDK_APP_ID}
|
||||
tencet-im:
|
||||
appId: ${LIKEI_IM_APP_ID}
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
package com.red.circle.external.infra.config;
|
||||
|
||||
import com.red.circle.component.instant.msg.InstantMessageProperties;
|
||||
import com.red.circle.component.instant.msg.tencet.props.TrtcTencetProperties;
|
||||
import com.red.circle.component.instant.msg.tencet.service.endpoint.api.trtc.HyTrtcClient;
|
||||
import com.tencentcloudapi.common.Credential;
|
||||
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||
import com.tencentcloudapi.common.profile.HttpProfile;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@Configuration
|
||||
public class TencentTrtcClientRegionConfiguration {
|
||||
|
||||
private static final String DEFAULT_TRTC_REGION = "ap-singapore";
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public HyTrtcClient regionAwareHyTrtcClient(
|
||||
InstantMessageProperties instantMessageProperties,
|
||||
@Value("${red-circle.instant-message.tencet-trtc.region:" + DEFAULT_TRTC_REGION + "}")
|
||||
String region) {
|
||||
TrtcTencetProperties trtcProperties = instantMessageProperties.getTencetTrtc();
|
||||
Credential credential = new Credential(
|
||||
trtcProperties.getSecretId(),
|
||||
trtcProperties.getSecretKey()
|
||||
);
|
||||
HttpProfile httpProfile = new HttpProfile();
|
||||
httpProfile.setEndpoint(trtcProperties.getEndpoint());
|
||||
ClientProfile clientProfile = new ClientProfile();
|
||||
clientProfile.setHttpProfile(httpProfile);
|
||||
String resolvedRegion = StringUtils.hasText(region) ? region.trim() : DEFAULT_TRTC_REGION;
|
||||
return new HyTrtcClient(credential, resolvedRegion, clientProfile);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user