Skip to content

Commit

Permalink
feat:蓝盾本地开发实现 TencentBlueKing#9576
Browse files Browse the repository at this point in the history
  • Loading branch information
fcfang123 committed Oct 18, 2023
1 parent 2622ec6 commit 262aeec
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
tasks.register("multiBootJar") {
System.getProperty("devops.multi.from")?.let { multiModuleStr ->
val multiModuleList = multiModuleStr.split(",").toMutableList()
allprojects.filter {
rootProject.subprojects.filter {
isSpecifiedModulePath(it.path, multiModuleList)
}.forEach { subProject -> addDependencies(subProject.path) }
dependsOn("copyToRelease")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class Client @Autowired constructor(
private const val connectTimeoutSeconds = 5L
private const val CACHE_SIZE = 1000L
private val longTimeOptions = Request.Options(10L, TimeUnit.SECONDS, 30L, TimeUnit.MINUTES, true)
private val accessoriesServiceList = listOf("experience")
private const val accessoriesName = "accessories"
}

private val beanCaches: LoadingCache<KClass<*>, *> = Caffeine.newBuilder()
Expand Down Expand Up @@ -279,6 +281,42 @@ class Client @Autowired constructor(
).url()
}

private fun findServiceName(clz: KClass<*>): String {
// 单体结构,不分微服务的方式
if (!assemblyServiceName.isNullOrBlank()) {
return assemblyServiceName
}
var serviceName = interfaces.getOrPut(clz) {
val serviceInterface = AnnotationUtils.findAnnotation(clz.java, ServiceInterface::class.java)
if (serviceInterface != null && serviceInterface.value.isNotBlank()) {
serviceInterface.value
} else {
val packageName = clz.qualifiedName.toString()
val regex = Regex("""com.tencent.devops.([a-z]+).api.([a-zA-Z]+)""")
val matches = regex.find(packageName)
?: throw ErrorCodeException(
errorCode = SERVICE_COULD_NOT_BE_ANALYZED,
params = arrayOf(packageName)
)
matches.groupValues[1]
}
}
// 得加一个标识,如果为集成的,才这么操作
if (isAccessoriesService(serviceName)) {
logger.info("findServiceName:serviceName({})", serviceName)
serviceName = accessoriesName
}
return if (serviceSuffix.isNullOrBlank() || KubernetesUtils.inContainer()) {
serviceName
} else {
"$serviceName$serviceSuffix"
}
}

private fun isAccessoriesService(serviceName: String): Boolean {
return accessoriesServiceList.contains(serviceName)
}

private fun buildGatewayUrl(path: String, gatewayType: GatewayType = GatewayType.IDC): String {

return if (path.startsWith("http://") || path.startsWith("https://")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.zaxxer.hikari.HikariDataSource
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.autoconfigure.AutoConfigureBefore
import org.springframework.boot.autoconfigure.AutoConfigureOrder
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
import org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration
import org.springframework.context.annotation.Bean
Expand Down

0 comments on commit 262aeec

Please sign in to comment.