Skip to content

Commit 7c0bf6f

Browse files
Revert "feat(servers): move execution out of reactor netty threads" (#2028)
Reverts #1943 this context switching is causing CPU usage increase.
1 parent 8e4de48 commit 7c0bf6f

File tree

1 file changed

+10
-14
lines changed
  • servers/graphql-kotlin-server/src/main/kotlin/com/expediagroup/graphql/server/execution

1 file changed

+10
-14
lines changed

servers/graphql-kotlin-server/src/main/kotlin/com/expediagroup/graphql/server/execution/GraphQLServer.kt

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024 Expedia, Inc
2+
* Copyright 2022 Expedia, Inc
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,10 +21,8 @@ import com.expediagroup.graphql.generator.extensions.plus
2121
import com.expediagroup.graphql.server.types.GraphQLResponse
2222
import com.expediagroup.graphql.server.types.GraphQLServerResponse
2323
import kotlinx.coroutines.CoroutineScope
24-
import kotlinx.coroutines.Dispatchers
2524
import kotlinx.coroutines.SupervisorJob
2625
import kotlinx.coroutines.coroutineScope
27-
import kotlinx.coroutines.withContext
2826
import kotlin.coroutines.CoroutineContext
2927
import kotlin.coroutines.EmptyCoroutineContext
3028

@@ -50,20 +48,18 @@ open class GraphQLServer<Request>(
5048
): GraphQLServerResponse? =
5149
coroutineScope {
5250
requestParser.parseRequest(request)?.let { graphQLRequest ->
53-
withContext(Dispatchers.Default) {
54-
val graphQLContext = contextFactory.generateContext(request)
51+
val graphQLContext = contextFactory.generateContext(request)
5552

56-
val customCoroutineContext = (graphQLContext.get<CoroutineContext>() ?: EmptyCoroutineContext)
57-
val graphQLExecutionScope = CoroutineScope(
58-
coroutineContext + customCoroutineContext + SupervisorJob()
59-
)
53+
val customCoroutineContext = (graphQLContext.get<CoroutineContext>() ?: EmptyCoroutineContext)
54+
val graphQLExecutionScope = CoroutineScope(
55+
coroutineContext + customCoroutineContext + SupervisorJob()
56+
)
6057

61-
val graphQLContextWithCoroutineScope = graphQLContext + mapOf(
62-
CoroutineScope::class to graphQLExecutionScope
63-
)
58+
val graphQLContextWithCoroutineScope = graphQLContext + mapOf(
59+
CoroutineScope::class to graphQLExecutionScope
60+
)
6461

65-
requestHandler.executeRequest(graphQLRequest, graphQLContextWithCoroutineScope)
66-
}
62+
requestHandler.executeRequest(graphQLRequest, graphQLContextWithCoroutineScope)
6763
}
6864
}
6965
}

0 commit comments

Comments
 (0)