diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/event/ArtifactEventProperties.kt b/src/backend/common/common-artifact/artifact-api/src/main/kotlin/com/tencent/bkrepo/common/artifact/properties/ArtifactEventProperties.kt similarity index 97% rename from src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/event/ArtifactEventProperties.kt rename to src/backend/common/common-artifact/artifact-api/src/main/kotlin/com/tencent/bkrepo/common/artifact/properties/ArtifactEventProperties.kt index d285305011..87bc214ed9 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/event/ArtifactEventProperties.kt +++ b/src/backend/common/common-artifact/artifact-api/src/main/kotlin/com/tencent/bkrepo/common/artifact/properties/ArtifactEventProperties.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.common.artifact.event +package com.tencent.bkrepo.common.artifact.properties import org.springframework.boot.context.properties.ConfigurationProperties import java.time.Duration diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/event/ArtifactEventConfiguration.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/event/ArtifactEventConfiguration.kt index b96d5dd072..ccbba9fe20 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/event/ArtifactEventConfiguration.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/event/ArtifactEventConfiguration.kt @@ -34,6 +34,7 @@ package com.tencent.bkrepo.common.artifact.event import com.tencent.bkrepo.common.artifact.event.listener.ArtifactDownloadListener import com.tencent.bkrepo.common.artifact.event.listener.ArtifactTransferListener import com.tencent.bkrepo.common.artifact.event.listener.ArtifactWebHookListener +import com.tencent.bkrepo.common.artifact.properties.ArtifactEventProperties import com.tencent.bkrepo.common.artifact.webhook.WebHookService import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.context.annotation.Configuration diff --git a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/event/listener/ArtifactDownloadListener.kt b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/event/listener/ArtifactDownloadListener.kt index c0b6b6240a..1268b7f2ef 100644 --- a/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/event/listener/ArtifactDownloadListener.kt +++ b/src/backend/common/common-artifact/artifact-service/src/main/kotlin/com/tencent/bkrepo/common/artifact/event/listener/ArtifactDownloadListener.kt @@ -33,7 +33,7 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder import com.tencent.bkrepo.common.api.constant.HttpHeaders import com.tencent.bkrepo.common.api.constant.StringPool import com.tencent.bkrepo.common.artifact.event.ArtifactDownloadedEvent -import com.tencent.bkrepo.common.artifact.event.ArtifactEventProperties +import com.tencent.bkrepo.common.artifact.properties.ArtifactEventProperties import com.tencent.bkrepo.common.artifact.event.node.NodeDownloadedEvent import com.tencent.bkrepo.common.artifact.event.node.NodeUpdateAccessDateEvent import com.tencent.bkrepo.common.artifact.repository.context.ArtifactClient diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/listener/EventAuditListener.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/listener/EventAuditListener.kt similarity index 89% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/listener/EventAuditListener.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/listener/EventAuditListener.kt index da6601d352..91e085aeb7 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/listener/EventAuditListener.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/listener/EventAuditListener.kt @@ -25,11 +25,13 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.repository.listener +package com.tencent.bkrepo.common.metadata.listener import com.tencent.bkrepo.common.artifact.event.base.ArtifactEvent -import com.tencent.bkrepo.common.metadata.service.log.OperateLogService +import com.tencent.bkrepo.common.metadata.condition.SyncCondition +import com.tencent.bkrepo.common.operate.api.OperateLogService import com.tencent.bkrepo.common.service.util.HttpContextHolder +import org.springframework.context.annotation.Conditional import org.springframework.context.event.EventListener import org.springframework.stereotype.Component @@ -37,6 +39,7 @@ import org.springframework.stereotype.Component * 事件审计记录监听器 */ @Component +@Conditional(SyncCondition::class) class EventAuditListener( private val operateLogService: OperateLogService ) { diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/listener/EventStreamListener.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/listener/EventStreamListener.kt similarity index 91% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/listener/EventStreamListener.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/listener/EventStreamListener.kt index fe109b06ca..6617c8aedd 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/listener/EventStreamListener.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/listener/EventStreamListener.kt @@ -25,10 +25,12 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.repository.listener +package com.tencent.bkrepo.common.metadata.listener import com.tencent.bkrepo.common.artifact.event.base.ArtifactEvent +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.stream.event.supplier.MessageSupplier +import org.springframework.context.annotation.Conditional import org.springframework.context.event.EventListener import org.springframework.stereotype.Component @@ -36,6 +38,7 @@ import org.springframework.stereotype.Component * 用于将事件发送到消息流的监听器 */ @Component +@Conditional(SyncCondition::class) class EventStreamListener( private val messageSupplier: MessageSupplier ) { diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/listener/NodeModifyEventListener.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/listener/NodeModifyEventListener.kt similarity index 98% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/listener/NodeModifyEventListener.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/listener/NodeModifyEventListener.kt index b9e058e837..bd84c0ee80 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/listener/NodeModifyEventListener.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/listener/NodeModifyEventListener.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.repository.listener +package com.tencent.bkrepo.common.metadata.listener import com.google.common.cache.CacheBuilder import com.google.common.cache.CacheLoader @@ -45,12 +45,14 @@ import com.tencent.bkrepo.common.artifact.event.node.NodeMovedEvent import com.tencent.bkrepo.common.artifact.event.node.NodeRenamedEvent import com.tencent.bkrepo.common.artifact.path.PathUtils import com.tencent.bkrepo.common.artifact.path.PathUtils.combineFullPath +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.mongo.dao.AbstractMongoDao import com.tencent.bkrepo.common.mongo.dao.util.Pages import com.tencent.bkrepo.common.metadata.dao.node.NodeDao import com.tencent.bkrepo.common.metadata.model.TNode import com.tencent.bkrepo.common.metadata.service.node.NodeService import org.slf4j.LoggerFactory +import org.springframework.context.annotation.Conditional import org.springframework.context.event.EventListener import org.springframework.data.domain.Sort import org.springframework.data.mongodb.core.query.Query @@ -69,6 +71,7 @@ import java.util.concurrent.atomic.LongAdder * 节点事件监听,用户统计目录size以及目录下文件个数 */ @Component +@Conditional(SyncCondition::class) class NodeModifyEventListener( private val nodeService: NodeService, private val nodeDao: NodeDao, diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/listener/NodeUpdateAccessDateEventListener.kt b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/listener/NodeUpdateAccessDateEventListener.kt similarity index 94% rename from src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/listener/NodeUpdateAccessDateEventListener.kt rename to src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/listener/NodeUpdateAccessDateEventListener.kt index dfa8a9b565..5130fa1a64 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/listener/NodeUpdateAccessDateEventListener.kt +++ b/src/backend/common/common-metadata/metadata-service/src/main/kotlin/com/tencent/bkrepo/common/metadata/listener/NodeUpdateAccessDateEventListener.kt @@ -25,15 +25,17 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.bkrepo.repository.listener +package com.tencent.bkrepo.common.metadata.listener -import com.tencent.bkrepo.common.artifact.event.ArtifactEventProperties +import com.tencent.bkrepo.common.artifact.properties.ArtifactEventProperties import com.tencent.bkrepo.common.artifact.event.base.ArtifactEvent import com.tencent.bkrepo.common.artifact.event.base.EventType +import com.tencent.bkrepo.common.metadata.condition.SyncCondition import com.tencent.bkrepo.common.mongo.constant.ID import com.tencent.bkrepo.common.metadata.dao.node.NodeDao import com.tencent.bkrepo.common.metadata.model.TNode import org.slf4j.LoggerFactory +import org.springframework.context.annotation.Conditional import org.springframework.data.mongodb.core.query.Query import org.springframework.data.mongodb.core.query.Update import org.springframework.data.mongodb.core.query.isEqualTo @@ -48,6 +50,7 @@ import java.time.format.DateTimeFormatter * 消费基于MQ传递的事件去更新对应access date */ @Component +@Conditional(SyncCondition::class) class NodeUpdateAccessDateEventListener( private val nodeDao: NodeDao, private val artifactEventProperties: ArtifactEventProperties, diff --git a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/config/RepositoryConsumerConfig.kt b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/config/RepositoryConsumerConfig.kt index e86704d91f..239f534c78 100644 --- a/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/config/RepositoryConsumerConfig.kt +++ b/src/backend/repository/biz-repository/src/main/kotlin/com/tencent/bkrepo/repository/config/RepositoryConsumerConfig.kt @@ -32,7 +32,7 @@ package com.tencent.bkrepo.repository.config import com.tencent.bkrepo.common.artifact.event.base.ArtifactEvent -import com.tencent.bkrepo.repository.listener.NodeUpdateAccessDateEventListener +import com.tencent.bkrepo.common.metadata.listener.NodeUpdateAccessDateEventListener import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.messaging.Message