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

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

package com.palantir.atlasdb.timelock.adjudicate.feedback;

import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
import com.palantir.conjure.java.undertow.lib.Deserializer;
import com.palantir.conjure.java.undertow.lib.Endpoint;
import com.palantir.conjure.java.undertow.lib.ReturnValueWriter;
import com.palantir.conjure.java.undertow.lib.TypeMarker;
import com.palantir.conjure.java.undertow.lib.UndertowRuntime;
import com.palantir.conjure.java.undertow.lib.UndertowService;
import com.palantir.timelock.feedback.ConjureTimeLockClientFeedback;
import com.palantir.timelock.feedback.LeaderElectionStatistics;
import com.palantir.tokens.auth.AuthHeader;
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.util.HttpString;
import io.undertow.util.Methods;
import io.undertow.util.StatusCodes;
import java.io.IOException;
import java.util.List;
import javax.annotation.Generated;

@Generated("com.palantir.conjure.java.services.UndertowServiceHandlerGenerator")
public final class TimeLockClientFeedbackServiceEndpoints implements UndertowService {
    private final UndertowTimeLockClientFeedbackService delegate;

    private TimeLockClientFeedbackServiceEndpoints(UndertowTimeLockClientFeedbackService delegate) {
        this.delegate = delegate;
    }

    public static UndertowService of(UndertowTimeLockClientFeedbackService delegate) {
        return new TimeLockClientFeedbackServiceEndpoints(delegate);
    }

    @Override
    public List endpoints(UndertowRuntime runtime) {
        return ImmutableList.of(
                new ReportFeedbackEndpoint(runtime, delegate), new ReportLeaderMetricsEndpoint(runtime, delegate));
    }

    private static final class ReportFeedbackEndpoint implements HttpHandler, Endpoint, ReturnValueWriter {
        private final UndertowRuntime runtime;

        private final UndertowTimeLockClientFeedbackService delegate;

        private final Deserializer deserializer;

        ReportFeedbackEndpoint(UndertowRuntime runtime, UndertowTimeLockClientFeedbackService delegate) {
            this.runtime = runtime;
            this.delegate = delegate;
            this.deserializer =
                    runtime.bodySerDe().deserializer(new TypeMarker() {}, this);
        }

        @Override
        public void handleRequest(HttpServerExchange exchange) throws IOException {
            AuthHeader authHeader = runtime.auth().header(exchange);
            ConjureTimeLockClientFeedback feedback = deserializer.deserialize(exchange);
            ListenableFuture result = delegate.reportFeedback(authHeader, feedback);
            runtime.async().register(result, this, exchange);
        }

        @Override
        public void write(Void result, HttpServerExchange exchange) throws IOException {
            exchange.setStatusCode(StatusCodes.NO_CONTENT);
        }

        @Override
        public HttpString method() {
            return Methods.POST;
        }

        @Override
        public String template() {
            return "/tl/feedback/reportFeedback";
        }

        @Override
        public String serviceName() {
            return "TimeLockClientFeedbackService";
        }

        @Override
        public String name() {
            return "reportFeedback";
        }

        @Override
        public HttpHandler handler() {
            return this;
        }
    }

    private static final class ReportLeaderMetricsEndpoint implements HttpHandler, Endpoint, ReturnValueWriter {
        private final UndertowRuntime runtime;

        private final UndertowTimeLockClientFeedbackService delegate;

        private final Deserializer deserializer;

        ReportLeaderMetricsEndpoint(UndertowRuntime runtime, UndertowTimeLockClientFeedbackService delegate) {
            this.runtime = runtime;
            this.delegate = delegate;
            this.deserializer = runtime.bodySerDe().deserializer(new TypeMarker() {}, this);
        }

        @Override
        public void handleRequest(HttpServerExchange exchange) throws IOException {
            AuthHeader authHeader = runtime.auth().header(exchange);
            LeaderElectionStatistics statistics = deserializer.deserialize(exchange);
            ListenableFuture result = delegate.reportLeaderMetrics(authHeader, statistics);
            runtime.async().register(result, this, exchange);
        }

        @Override
        public void write(Void result, HttpServerExchange exchange) throws IOException {
            exchange.setStatusCode(StatusCodes.NO_CONTENT);
        }

        @Override
        public HttpString method() {
            return Methods.POST;
        }

        @Override
        public String template() {
            return "/tl/feedback/reportLeaderMetrics";
        }

        @Override
        public String serviceName() {
            return "TimeLockClientFeedbackService";
        }

        @Override
        public String name() {
            return "reportLeaderMetrics";
        }

        @Override
        public HttpHandler handler() {
            return this;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy