io.quarkus.grpc.runtime.devmode.StreamCollectorInterceptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-grpc Show documentation
Show all versions of quarkus-grpc Show documentation
Serve and consume gRPC services
package io.quarkus.grpc.runtime.devmode;
import jakarta.annotation.Priority;
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.Interceptor;
import jakarta.interceptor.InvocationContext;
import io.grpc.stub.ServerCallStreamObserver;
import io.grpc.stub.StreamObserver;
import io.quarkus.grpc.stubs.ServerCalls;
import io.quarkus.grpc.stubs.StreamCollector;
@CollectStreams
@Priority(1)
@Interceptor
public class StreamCollectorInterceptor {
private final StreamCollector streamCollector;
public StreamCollectorInterceptor() {
this.streamCollector = ServerCalls.getStreamCollector();
}
@SuppressWarnings("unchecked")
@AroundInvoke
Object collect(InvocationContext context) throws Exception {
// Wraps the first StreamObserver parameter if available
Object[] params = context.getParameters();
int streamIndex = 0;
StreamObserver