@@ -11,13 +11,18 @@ import java.time.Instant
11
11
import java.time.ZoneOffset
12
12
import java.time.ZonedDateTime
13
13
import java.time.temporal.ChronoUnit
14
+ import java.util.concurrent.Executors
15
+ import java.util.concurrent.FutureTask
14
16
import java.util.concurrent.atomic.AtomicInteger
15
17
16
18
@Service(" githubActionsPipelineCommitsService" )
17
19
class PipelineCommitService (
18
20
private val buildRepository : BuildRepository ,
19
21
private val commitService : CommitService
20
22
) {
23
+ private val defaultNumberOfBranchFetchConcurrency = 10
24
+ private val executorService = Executors .newFixedThreadPool(defaultNumberOfBranchFetchConcurrency)
25
+
21
26
fun mapCommitToRun (
22
27
pipeline : PipelineConfiguration ,
23
28
runs : MutableList <GithubActionsRun >,
@@ -28,8 +33,9 @@ class PipelineCommitService(
28
33
val numberOfBranches = runsGroupedByBranch.size
29
34
val progressCounter = AtomicInteger (0 )
30
35
31
- runsGroupedByBranch
32
- .forEach { (branch, run) ->
36
+ val taskMap: MutableMap <String , FutureTask <Map <GithubActionsRun , List <Commit >>>> = mutableMapOf ()
37
+ runsGroupedByBranch.forEach { (branch, run) ->
38
+ val branchTask = FutureTask {
33
39
emitCb(
34
40
SyncProgress (
35
41
pipeline.id,
@@ -40,8 +46,15 @@ class PipelineCommitService(
40
46
GithubActionConstants .totalNumberOfSteps,
41
47
)
42
48
)
43
- branchCommitsMap[branch] = mapRunToCommits(pipeline, run)
49
+ mapRunToCommits(pipeline, run)
44
50
}
51
+ taskMap[branch] = branchTask
52
+ executorService.submit(branchTask)
53
+ }
54
+ runsGroupedByBranch.forEach { (branch, _) ->
55
+ branchCommitsMap[branch] = taskMap[branch]!! .get()
56
+ }
57
+
45
58
return branchCommitsMap.toMap()
46
59
}
47
60
0 commit comments