Hello All, I am implementing a gRPC service and have a use-case where I need to rate limit RPC calls but would like the rate limiting server interceptor to run directly on the network thread as it is non-blocking(Using direct executor). But once the requests passes through the rate limiter I would like to use a thread pool to handle the request. Is there a standard way to do this?
The way forward seems to be to use direct executor <https://grpc.github.io/grpc-java/javadoc/io/grpc/ServerBuilder.html#directExecutor()> while building the server, define a ServerCallExecutorSupplier <https://grpc.github.io/grpc-java/javadoc/io/grpc/ServerCallExecutorSupplier.html>, pass it as a callExecutor <https://grpc.github.io/grpc-java/javadoc/io/grpc/ServerBuilder.html#callExecutor(io.grpc.ServerCallExecutorSupplier)> to gRPC server and have this executor supplier return *null* when the request hasn't passed through rate limiter so that it will use direct executor and return a threaded executor when it does pass through the rate limiter. To figure out if a request made it through the rate limiter or not I was thinking I could use the metadata headers for that but this seems overly complicated. Is there a better solution? Thank you! -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/e55dc345-a733-4113-bb5c-478162ad4ccfn%40googlegroups.com.
