Added custom executor for grpc server with fixed 20 threads. Default thread pool is unbounded :(

This commit is contained in:
a10zn8
2022-12-01 19:57:23 +04:00
parent 57beb3f794
commit 6603a160c4

View File

@@ -16,6 +16,7 @@
*/
package io.emeraldpay.dshackle
import com.google.common.util.concurrent.ThreadFactoryBuilder
import io.emeraldpay.dshackle.config.MainConfig
import io.emeraldpay.dshackle.monitoring.accesslog.AccessHandlerGrpc
import io.grpc.Server
@@ -24,6 +25,7 @@ import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service
import java.net.InetSocketAddress
import java.util.concurrent.Executors
import javax.annotation.PostConstruct
import javax.annotation.PreDestroy
@@ -63,6 +65,13 @@ open class GrpcServer(
serverBuilder.addService(it)
}
serverBuilder.executor(
Executors.newFixedThreadPool(
20,
ThreadFactoryBuilder().setNameFormat("custom-grpc-%d").build()
)
)
val server = serverBuilder.build()
this.server = server