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

com.palantir.atlasdb.timelock.api.management.TimeLockManagementServiceAsync Maven / Gradle / Ivy

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

import com.google.common.util.concurrent.ListenableFuture;
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.Override;
import java.lang.String;
import java.lang.Void;
import java.util.Set;
import javax.annotation.Generated;

@Generated("com.palantir.conjure.java.services.dialogue.DialogueInterfaceGenerator")
@DialogueService(TimeLockManagementServiceAsync.Factory.class)
public interface TimeLockManagementServiceAsync {
    /**
     * The endpoint loads all persisted namespaces. leaderPaxos is filtered out from the set
     * as it is not a namespace.
     * @apiNote {@code POST /tl/management/getNamespaces}
     */
    @ClientEndpoint(method = "POST", path = "/tl/management/getNamespaces")
    ListenableFuture> getNamespaces(AuthHeader authHeader);

    /**
     * The operation of achieving consensus on all namespaces is NOT atomic. In the case of failures, it can
     * be assumed that consensus was achieved on some namespaces.
     * @apiNote {@code POST /tl/management/achieveConsensus}
     */
    @ClientEndpoint(method = "POST", path = "/tl/management/achieveConsensus")
    ListenableFuture achieveConsensus(AuthHeader authHeader, Set namespaces);

    /**
     * Creates an asynchronous/non-blocking client for a TimeLockManagementService service.
     */
    static TimeLockManagementServiceAsync of(EndpointChannelFactory _endpointChannelFactory, ConjureRuntime _runtime) {
        return new TimeLockManagementServiceAsync() {
            private final PlainSerDe _plainSerDe = _runtime.plainSerDe();

            private final EndpointChannel getNamespacesChannel =
                    _endpointChannelFactory.endpoint(DialogueTimeLockManagementEndpoints.getNamespaces);

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

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

            private final EndpointChannel achieveConsensusChannel =
                    _endpointChannelFactory.endpoint(DialogueTimeLockManagementEndpoints.achieveConsensus);

            private final Deserializer achieveConsensusDeserializer =
                    _runtime.bodySerDe().emptyBodyDeserializer();

            @Override
            public ListenableFuture> getNamespaces(AuthHeader authHeader) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                return _runtime.clients().call(getNamespacesChannel, _request.build(), getNamespacesDeserializer);
            }

            @Override
            public ListenableFuture achieveConsensus(AuthHeader authHeader, Set namespaces) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                _request.body(achieveConsensusSerializer.serialize(namespaces));
                return _runtime.clients().call(achieveConsensusChannel, _request.build(), achieveConsensusDeserializer);
            }

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

    /**
     * Creates an asynchronous/non-blocking client for a TimeLockManagementService service.
     */
    static TimeLockManagementServiceAsync 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 TimeLockManagementServiceAsync create(
                EndpointChannelFactory endpointChannelFactory, ConjureRuntime runtime) {
            return TimeLockManagementServiceAsync.of(endpointChannelFactory, runtime);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy