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

com.eventstore.dbclient.EnableProjection Maven / Gradle / Ivy

package com.eventstore.dbclient;

import com.eventstore.dbclient.proto.projections.Projectionmanagement;
import com.eventstore.dbclient.proto.projections.ProjectionsGrpc;
import io.grpc.Metadata;
import io.grpc.stub.MetadataUtils;

import java.util.concurrent.CompletableFuture;

class EnableProjection {
    private final GrpcClient client;
    private final String projectionName;
    private EnableProjectionOptions options;

    public EnableProjection(final GrpcClient client, final String projectionName, final EnableProjectionOptions options) {
        this.client = client;
        this.projectionName = projectionName;
        this.options = options;
    }

    public CompletableFuture execute() {
        return this.client.run(channel -> {
            Projectionmanagement.EnableReq.Options.Builder optionsBuilder =
                    Projectionmanagement.EnableReq.Options.newBuilder()
                            .setName(this.projectionName);

            Projectionmanagement.EnableReq request = Projectionmanagement.EnableReq.newBuilder()
                    .setOptions(optionsBuilder)
                    .build();

            ProjectionsGrpc.ProjectionsStub client =
                    GrpcUtils.configureStub(ProjectionsGrpc.newStub(channel), this.client.getSettings(), this.options);

            CompletableFuture result = new CompletableFuture<>();

            client.enable(request, GrpcUtils.convertSingleResponse(result));

            return result;
        });
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy