Skip to content

Commit

Permalink
feat: websocket page添加提供扩展 TencentBlueKing#4470
Browse files Browse the repository at this point in the history
  • Loading branch information
fitzcao committed Jun 24, 2021
1 parent bf9c4bd commit e1f0c10
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.tencent.devops.common.websocket.dispatch.WebSocketDispatcher
import com.tencent.devops.process.websocket.listener.PipelineWebSocketListener
import com.tencent.devops.process.websocket.page.DefaultDetailPageBuild
import com.tencent.devops.process.websocket.page.DefaultHistoryPageBuild
import com.tencent.devops.process.websocket.page.DefaultStatusPageBuild
import com.tencent.devops.process.websocket.page.DetailPageBuild
import org.springframework.amqp.core.Binding
import org.springframework.amqp.core.BindingBuilder
Expand Down Expand Up @@ -114,4 +115,8 @@ class PipelineWebSocketConfiguration {
@ConditionalOnMissingBean(name = ["detailPage"])
fun detailPage() = DefaultDetailPageBuild()

@Bean
@ConditionalOnMissingBean(name = ["statusPage"])
fun statusPage() = DefaultStatusPageBuild()

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.tencent.devops.process.websocket.page

import com.tencent.devops.common.websocket.pojo.BuildPageInfo

class DefaultStatusPageBuild: StatusPageBuild() {
override fun extStatusPage(buildPageInfo: BuildPageInfo): String? {
return null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ package com.tencent.devops.process.websocket.page
import com.tencent.devops.common.websocket.page.IPath
import com.tencent.devops.common.websocket.pojo.BuildPageInfo

class StatusPageBuild : IPath {
override fun buildPage(buildPageInfo: BuildPageInfo): String = "/console/pipeline/${buildPageInfo.projectId}/list"
abstract class StatusPageBuild : IPath {
override fun buildPage(buildPageInfo: BuildPageInfo): String {
val defaultPage = "/console/pipeline/${buildPageInfo.projectId}/list"
if (!extStatusPage(buildPageInfo).isNullOrEmpty()) {
return extStatusPage(buildPageInfo)!!
}
return defaultPage
}

abstract fun extStatusPage(buildPageInfo: BuildPageInfo): String?
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class PipelineWebsocketService @Autowired constructor(
val redisOperation: RedisOperation,
val objectMapper: ObjectMapper,
val historyPageBuild: HistoryPageBuild,
val detailPageBuild: DetailPageBuild
val detailPageBuild: DetailPageBuild,
val statusPageBuild: StatusPageBuild
) {
fun buildDetailMessage(
buildId: String,
Expand Down Expand Up @@ -128,7 +129,7 @@ class PipelineWebsocketService @Autowired constructor(
pipelineId: String,
userId: String
): StatusWebsocketPush {
val page = StatusPageBuild().buildPage(
val page = statusPageBuild.buildPage(
buildPageInfo = BuildPageInfo(
buildId = buildId,
pipelineId = pipelineId,
Expand Down

0 comments on commit e1f0c10

Please sign in to comment.