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

com.palantir.atlasdb.timelock.api.MultiClientConjureTimelockServiceBlocking Maven / Gradle / Ivy

There is a newer version: 0.1152.0
Show newest version
package com.palantir.atlasdb.timelock.api;

import com.palantir.conjure.java.lib.internal.ClientEndpoint;
import com.palantir.dialogue.Channel;
import com.palantir.dialogue.ConjureRuntime;
import com.palantir.dialogue.Deserializer;
import com.palantir.dialogue.DialogueService;
import com.palantir.dialogue.DialogueServiceFactory;
import com.palantir.dialogue.Endpoint;
import com.palantir.dialogue.EndpointChannel;
import com.palantir.dialogue.EndpointChannelFactory;
import com.palantir.dialogue.PlainSerDe;
import com.palantir.dialogue.Request;
import com.palantir.dialogue.Serializer;
import com.palantir.dialogue.TypeMarker;
import com.palantir.tokens.auth.AuthHeader;
import java.lang.Deprecated;
import java.lang.Override;
import java.lang.String;
import java.lang.SuppressWarnings;
import java.util.Map;
import java.util.Set;
import javax.annotation.Generated;

@Generated("com.palantir.conjure.java.services.dialogue.DialogueInterfaceGenerator")
@DialogueService(MultiClientConjureTimelockServiceBlocking.Factory.class)
public interface MultiClientConjureTimelockServiceBlocking {
    /**
     * Version of ConjureTimelockService#leaderTime endpoint for acquiring leaderTimes for a set of namespaces.
     * @apiNote {@code POST /tl/multi/lts}
     */
    @ClientEndpoint(method = "POST", path = "/tl/multi/lts")
    LeaderTimes leaderTimes(AuthHeader authHeader, Set namespaces);

    /**
     * Version of ConjureTimelockService#startTransactions that starts transactions for multiple namespaces.
     * @apiNote {@code POST /tl/multi/sts}
     * @deprecated This endpoint is deprecated. Please use {@link #startTransactionsForClients} to start transactions for multiple clients.
     */
    @ClientEndpoint(method = "POST", path = "/tl/multi/sts")
    @Deprecated
    Map startTransactions(
            AuthHeader authHeader, Map requests);

    /**
     * Version of ConjureTimelockService#getCommitTimestamps for acquiring commit timestamps for multiple namespaces.
     * @apiNote {@code POST /tl/multi/gcts}
     * @deprecated This endpoint is deprecated. Please use {@link #getCommitTimestampsForClients} to get commit timestamps for multiple clients.
     */
    @ClientEndpoint(method = "POST", path = "/tl/multi/gcts")
    @Deprecated
    Map getCommitTimestamps(
            AuthHeader authHeader, Map requests);

    /**
     * Version of ConjureTimelockService#startTransactions that starts transactions for multiple namespaces.
     * @apiNote {@code POST /tl/multi/stsfc}
     */
    @ClientEndpoint(method = "POST", path = "/tl/multi/stsfc")
    Map startTransactionsForClients(
            AuthHeader authHeader, Map requests);

    /**
     * Version of ConjureTimelockService#getCommitTimestamps for acquiring commit timestamps for multiple namespaces.
     * @apiNote {@code POST /tl/multi/gctsfc}
     */
    @ClientEndpoint(method = "POST", path = "/tl/multi/gctsfc")
    Map getCommitTimestampsForClients(
            AuthHeader authHeader, Map requests);

    /**
     * Creates a synchronous/blocking client for a MultiClientConjureTimelockService service.
     */
    static MultiClientConjureTimelockServiceBlocking of(
            EndpointChannelFactory _endpointChannelFactory, ConjureRuntime _runtime) {
        return new MultiClientConjureTimelockServiceBlocking() {
            private final PlainSerDe _plainSerDe = _runtime.plainSerDe();

            private final Serializer> leaderTimesSerializer =
                    _runtime.bodySerDe().serializer(new TypeMarker>() {});

            private final EndpointChannel leaderTimesChannel =
                    _endpointChannelFactory.endpoint(DialogueMultiClientConjureTimelockEndpoints.leaderTimes);

            private final Deserializer leaderTimesDeserializer =
                    _runtime.bodySerDe().deserializer(new TypeMarker() {});

            private final Serializer> startTransactionsSerializer =
                    _runtime.bodySerDe()
                            .serializer(new TypeMarker>() {});

            private final EndpointChannel startTransactionsChannel =
                    _endpointChannelFactory.endpoint(DialogueMultiClientConjureTimelockEndpoints.startTransactions);

            private final Deserializer> startTransactionsDeserializer =
                    _runtime.bodySerDe()
                            .deserializer(new TypeMarker>() {});

            private final Serializer> getCommitTimestampsSerializer =
                    _runtime.bodySerDe().serializer(new TypeMarker>() {});

            private final EndpointChannel getCommitTimestampsChannel =
                    _endpointChannelFactory.endpoint(DialogueMultiClientConjureTimelockEndpoints.getCommitTimestamps);

            private final Deserializer> getCommitTimestampsDeserializer =
                    _runtime.bodySerDe().deserializer(new TypeMarker>() {});

            private final Serializer>
                    startTransactionsForClientsSerializer = _runtime.bodySerDe()
                            .serializer(new TypeMarker>() {});

            private final EndpointChannel startTransactionsForClientsChannel = _endpointChannelFactory.endpoint(
                    DialogueMultiClientConjureTimelockEndpoints.startTransactionsForClients);

            private final Deserializer>
                    startTransactionsForClientsDeserializer = _runtime.bodySerDe()
                            .deserializer(new TypeMarker>() {});

            private final Serializer>
                    getCommitTimestampsForClientsSerializer = _runtime.bodySerDe()
                            .serializer(new TypeMarker>() {});

            private final EndpointChannel getCommitTimestampsForClientsChannel = _endpointChannelFactory.endpoint(
                    DialogueMultiClientConjureTimelockEndpoints.getCommitTimestampsForClients);

            private final Deserializer>
                    getCommitTimestampsForClientsDeserializer = _runtime.bodySerDe()
                            .deserializer(new TypeMarker>() {});

            @Override
            public LeaderTimes leaderTimes(AuthHeader authHeader, Set namespaces) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                _request.body(leaderTimesSerializer.serialize(namespaces));
                return _runtime.clients().callBlocking(leaderTimesChannel, _request.build(), leaderTimesDeserializer);
            }

            @Override
            @SuppressWarnings("deprecation")
            public Map startTransactions(
                    AuthHeader authHeader, Map requests) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                _request.body(startTransactionsSerializer.serialize(requests));
                return _runtime.clients()
                        .callBlocking(startTransactionsChannel, _request.build(), startTransactionsDeserializer);
            }

            @Override
            @SuppressWarnings("deprecation")
            public Map getCommitTimestamps(
                    AuthHeader authHeader, Map requests) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                _request.body(getCommitTimestampsSerializer.serialize(requests));
                return _runtime.clients()
                        .callBlocking(getCommitTimestampsChannel, _request.build(), getCommitTimestampsDeserializer);
            }

            @Override
            public Map startTransactionsForClients(
                    AuthHeader authHeader, Map requests) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                _request.body(startTransactionsForClientsSerializer.serialize(requests));
                return _runtime.clients()
                        .callBlocking(
                                startTransactionsForClientsChannel,
                                _request.build(),
                                startTransactionsForClientsDeserializer);
            }

            @Override
            public Map getCommitTimestampsForClients(
                    AuthHeader authHeader, Map requests) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                _request.body(getCommitTimestampsForClientsSerializer.serialize(requests));
                return _runtime.clients()
                        .callBlocking(
                                getCommitTimestampsForClientsChannel,
                                _request.build(),
                                getCommitTimestampsForClientsDeserializer);
            }

            @Override
            public String toString() {
                return "MultiClientConjureTimelockServiceBlocking{_endpointChannelFactory=" + _endpointChannelFactory
                        + ", runtime=" + _runtime + '}';
            }
        };
    }

    /**
     * Creates an asynchronous/non-blocking client for a MultiClientConjureTimelockService service.
     */
    static MultiClientConjureTimelockServiceBlocking of(Channel _channel, ConjureRuntime _runtime) {
        if (_channel instanceof EndpointChannelFactory) {
            return of((EndpointChannelFactory) _channel, _runtime);
        }
        return of(
                new EndpointChannelFactory() {
                    @Override
                    public EndpointChannel endpoint(Endpoint endpoint) {
                        return _runtime.clients().bind(_channel, endpoint);
                    }
                },
                _runtime);
    }

    final class Factory implements DialogueServiceFactory {
        @Override
        public MultiClientConjureTimelockServiceBlocking create(
                EndpointChannelFactory endpointChannelFactory, ConjureRuntime runtime) {
            return MultiClientConjureTimelockServiceBlocking.of(endpointChannelFactory, runtime);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy