The "gRPC Server" section of the Micronaut gRPC docs says, in part:
…by default the server will be setup to use Micronaut’s I/O executor service.
That suggests to me that it should be possible to configure the server to use a non-default executor service. I'm specifically interested in getting it to use the VIRTUAL
executor service.
The configuration reference for Micronaut gRPC identifies grpc.server.executor
as a configurable property of GrpcServerConfiguration
, but with a type of java.util.concurrent.Executor
. Looking at the source code for GrpcServerConfiguration
, it's not at all clear to me that the server executor can actually be changed, though.
The constructor accepts an executor, but calls out TaskExecutors.IO
specifically, and I don't see any hooks to override that. GrpcServerConfiguration
only calls NettyServerBuilder#executor
from its constructor, and there are no public (or private) methods for changing it after construction.
I think I have to be missing something; is there some other way to configure Micronaut gRPC to use virtual threads (or any executor other than TaskExecutors.IO
) for the gRPC server executor?
EDIT: to be clear, I have tried the obvious thing of setting grpc.server.executor
to BLOCKING
/VIRTUAL
(even though there's no real reason to believe that would have any effect), and gRPC calls continue to get sent to the IO executor.
As discussed in https://github.com/micronaut-projects/micronaut-grpc/issues/1097, this is, in fact, a bug in micronaut-grpc
; there is not (yet!) a way to configure the server executor via the Micronaut configuration layer.
Please see the linked issue for additional discussion and workarounds.