All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.stargate.grpc.service.streaming.StreamingQueryHandler Maven / Gradle / Ivy

There is a newer version: 2.1.0-BETA-14
Show newest version
package io.stargate.grpc.service.streaming;

import io.stargate.db.Persistence;
import io.stargate.grpc.service.ExceptionHandler;
import io.stargate.grpc.service.QueryHandler;
import io.stargate.grpc.service.StreamingSuccessHandler;
import io.stargate.proto.QueryOuterClass;
import java.util.concurrent.ScheduledExecutorService;

/**
 * Handles the response for normal queries, constructs the {@link
 * io.stargate.proto.QueryOuterClass.StreamingResponse} for the {@link
 * io.stargate.proto.QueryOuterClass.Response}. Finally, invokes the {@link StreamingSuccessHandler}
 * for it.
 */
public class StreamingQueryHandler extends QueryHandler {
  private final StreamingSuccessHandler streamingSuccessHandler;

  StreamingQueryHandler(
      QueryOuterClass.Query query,
      Persistence.Connection connection,
      Persistence persistence,
      ScheduledExecutorService executor,
      int schemaAgreementRetries,
      StreamingSuccessHandler streamingSuccessHandler,
      ExceptionHandler exceptionHandler) {
    super(query, connection, persistence, executor, schemaAgreementRetries, exceptionHandler);
    this.streamingSuccessHandler = streamingSuccessHandler;
  }

  @Override
  protected void setSuccess(QueryOuterClass.Response response) {
    streamingSuccessHandler.handleResponse(
        QueryOuterClass.StreamingResponse.newBuilder().setResponse(response).build());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy