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

com.palantir.atlasdb.timelock.adjudicate.feedback.TimeLockClientFeedbackServiceBlocking Maven / Gradle / Ivy

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

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.timelock.feedback.ConjureTimeLockClientFeedback;
import com.palantir.timelock.feedback.LeaderElectionStatistics;
import com.palantir.tokens.auth.AuthHeader;
import java.lang.Override;
import java.lang.String;
import java.lang.Void;
import javax.annotation.Generated;

@Generated("com.palantir.conjure.java.services.dialogue.DialogueInterfaceGenerator")
@DialogueService(TimeLockClientFeedbackServiceBlocking.Factory.class)
public interface TimeLockClientFeedbackServiceBlocking {
    /**
     * The endpoint receives feedback reports from clients which are required for TimeLock Adjudication.
     * @apiNote {@code POST /tl/feedback/reportFeedback}
     */
    @ClientEndpoint(method = "POST", path = "/tl/feedback/reportFeedback")
    void reportFeedback(AuthHeader authHeader, ConjureTimeLockClientFeedback feedback);

    /**
     * This endpoint recieves stats about Timelock leader election durations from all clients, then aggregates them
     * on the server side.
     * @apiNote {@code POST /tl/feedback/reportLeaderMetrics}
     */
    @ClientEndpoint(method = "POST", path = "/tl/feedback/reportLeaderMetrics")
    void reportLeaderMetrics(AuthHeader authHeader, LeaderElectionStatistics statistics);

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

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

            private final EndpointChannel reportFeedbackChannel =
                    _endpointChannelFactory.endpoint(DialogueTimeLockClientFeedbackEndpoints.reportFeedback);

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

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

            private final EndpointChannel reportLeaderMetricsChannel =
                    _endpointChannelFactory.endpoint(DialogueTimeLockClientFeedbackEndpoints.reportLeaderMetrics);

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

            @Override
            public void reportFeedback(AuthHeader authHeader, ConjureTimeLockClientFeedback feedback) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                _request.body(reportFeedbackSerializer.serialize(feedback));
                _runtime.clients().callBlocking(reportFeedbackChannel, _request.build(), reportFeedbackDeserializer);
            }

            @Override
            public void reportLeaderMetrics(AuthHeader authHeader, LeaderElectionStatistics statistics) {
                Request.Builder _request = Request.builder();
                _request.putHeaderParams("Authorization", authHeader.toString());
                _request.body(reportLeaderMetricsSerializer.serialize(statistics));
                _runtime.clients()
                        .callBlocking(reportLeaderMetricsChannel, _request.build(), reportLeaderMetricsDeserializer);
            }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy