mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git & split mode] IJPL-208232 Added additional usages of durable api where long-living rpc flows are used
GitOrigin-RevId: 6466a398580d57b708d29a02158a38b127998b99
This commit is contained in:
committed by
intellij-monorepo-bot
parent
596d06f9ae
commit
08c17c44f0
@@ -8,6 +8,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.platform.project.projectId
|
||||
import com.intellij.platform.vcs.impl.shared.rpc.RepositoryId
|
||||
import com.intellij.vcs.git.rpc.GitIncomingOutgoingStateApi
|
||||
import fleet.rpc.client.durable
|
||||
import git4idea.GitStandardLocalBranch
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -18,9 +19,11 @@ internal class GitInOutStateHolder(private val project: Project, cs: CoroutineSc
|
||||
|
||||
init {
|
||||
cs.launch {
|
||||
GitIncomingOutgoingStateApi.getInstance().syncState(project.projectId()).collect {
|
||||
LOG.debug("Received new state - in ${it.incoming.size} repos, out ${it.outgoing.size} repos")
|
||||
state = it
|
||||
durable {
|
||||
GitIncomingOutgoingStateApi.getInstance().syncState(project.projectId()).collect {
|
||||
LOG.debug("Received new state - in ${it.incoming.size} repos, out ${it.outgoing.size} repos")
|
||||
state = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.intellij.vcs.git.rpc.GitRepositoryApi
|
||||
import com.intellij.vcs.git.rpc.GitRepositoryDto
|
||||
import com.intellij.vcs.git.rpc.GitRepositoryEvent
|
||||
import com.intellij.vcs.git.rpc.GitRepositoryStateDto
|
||||
import fleet.rpc.client.durable
|
||||
import git4idea.GitStandardLocalBranch
|
||||
import git4idea.GitStandardRemoteBranch
|
||||
import git4idea.GitTag
|
||||
@@ -89,40 +90,43 @@ class GitRepositoriesHolder(
|
||||
*/
|
||||
private suspend fun subscribeToRepoEvents() {
|
||||
cs.childScope("Git repository state synchronization").launch {
|
||||
GitRepositoryApi.getInstance().getRepositoriesEvents(project.projectId()).collect { event ->
|
||||
LOG.debug("Received repository event: $event")
|
||||
when (event) {
|
||||
is GitRepositoryEvent.ReloadState -> {
|
||||
val newState = event.repositories.associate { it.repositoryId to convertToRepositoryInfo(it) }
|
||||
repositories.keys.retainAll(newState.keys)
|
||||
repositories.putAll(newState)
|
||||
durable {
|
||||
GitRepositoryApi.getInstance().getRepositoriesEvents(project.projectId()).collect { event ->
|
||||
LOG.debug("Received repository event: $event")
|
||||
when (event) {
|
||||
is GitRepositoryEvent.ReloadState -> {
|
||||
val newState = event.repositories.associate { it.repositoryId to convertToRepositoryInfo(it) }
|
||||
repositories.keys.retainAll(newState.keys)
|
||||
repositories.putAll(newState)
|
||||
|
||||
if (!initSignal.isCompleted) {
|
||||
initSignal.complete(Unit)
|
||||
if (!initSignal.isCompleted) {
|
||||
initSignal.complete(Unit)
|
||||
}
|
||||
}
|
||||
is GitRepositoryEvent.RepositoriesSync -> {
|
||||
if (event.repositories.size != repositories.size || !repositories.keys.containsAll(event.repositories)) {
|
||||
LOG.warn("State of repositories is not synchronized. " +
|
||||
"Received repositories: ${event.repositories.joinToString { it.toString() }}. " +
|
||||
"Known repositories are: ${repositories.keys.joinToString { it.toString() }}")
|
||||
GitRepositoryApi.getInstance().forceSync(project.projectId())
|
||||
}
|
||||
else {
|
||||
LOG.debug("Repositories state is synchronized")
|
||||
}
|
||||
}
|
||||
is GitRepositoryEvent.RepositoryCreated -> {
|
||||
repositories[event.repository.repositoryId] = convertToRepositoryInfo(event.repository)
|
||||
}
|
||||
is GitRepositoryEvent.RepositoryDeleted -> repositories.remove(event.repositoryId)
|
||||
is GitRepositoryEvent.SingleRepositoryUpdate -> handleSingleRepoUpdate(event)
|
||||
GitRepositoryEvent.TagsHidden -> {
|
||||
repositories.values.forEach { it.state.tags = emptySet() }
|
||||
}
|
||||
}
|
||||
is GitRepositoryEvent.RepositoriesSync -> {
|
||||
if (event.repositories.size != repositories.size || !repositories.keys.containsAll(event.repositories)) {
|
||||
LOG.warn("State of repositories is not synchronized. " +
|
||||
"Received repositories: ${event.repositories.joinToString { it.toString() }}. " +
|
||||
"Known repositories are: ${repositories.keys.joinToString { it.toString() }}")
|
||||
GitRepositoryApi.getInstance().forceSync(project.projectId())
|
||||
} else {
|
||||
LOG.debug("Repositories state is synchronized")
|
||||
}
|
||||
}
|
||||
is GitRepositoryEvent.RepositoryCreated -> {
|
||||
repositories[event.repository.repositoryId] = convertToRepositoryInfo(event.repository)
|
||||
}
|
||||
is GitRepositoryEvent.RepositoryDeleted -> repositories.remove(event.repositoryId)
|
||||
is GitRepositoryEvent.SingleRepositoryUpdate -> handleSingleRepoUpdate(event)
|
||||
GitRepositoryEvent.TagsHidden -> {
|
||||
repositories.values.forEach { it.state.tags = emptySet() }
|
||||
}
|
||||
}
|
||||
|
||||
if (initialized) {
|
||||
getUpdateType(event)?.let { project.messageBus.syncPublisher(UPDATES).afterUpdate(it) }
|
||||
if (initialized) {
|
||||
getUpdateType(event)?.let { project.messageBus.syncPublisher(UPDATES).afterUpdate(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.intellij.platform.project.projectId
|
||||
import com.intellij.platform.vcs.impl.shared.rpc.RepositoryId
|
||||
import com.intellij.vcs.git.repo.GitRepositoryColor.Companion.toAwtColor
|
||||
import com.intellij.vcs.git.rpc.GitRepositoryColorsApi
|
||||
import fleet.rpc.client.durable
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.Serializable
|
||||
@@ -41,9 +42,11 @@ internal class GitRepositoryColorsHolder(project: Project, cs: CoroutineScope) {
|
||||
|
||||
init {
|
||||
cs.launch {
|
||||
GitRepositoryColorsApi.getInstance().syncColors(project.projectId()).collect { newState ->
|
||||
LOG.debug("Received new colors - ${newState.colors.size} repos")
|
||||
state = newState
|
||||
durable {
|
||||
GitRepositoryColorsApi.getInstance().syncColors(project.projectId()).collect { newState ->
|
||||
LOG.debug("Received new colors - ${newState.colors.size} repos")
|
||||
state = newState
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user