com.palantir.atlasdb.timelock.lock.watch.ConjureLockWatchingServiceAsync Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of timelock-api-dialogue Show documentation
Show all versions of timelock-api-dialogue Show documentation
Palantir open source project
package com.palantir.atlasdb.timelock.lock.watch;
import com.google.common.util.concurrent.ListenableFuture;
import com.palantir.atlasdb.timelock.api.LockWatchRequest;
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.logsafe.Safe;
import com.palantir.tokens.auth.AuthHeader;
import java.lang.Override;
import java.lang.String;
import java.lang.Void;
import javax.annotation.processing.Generated;
@Generated("com.palantir.conjure.java.services.dialogue.DialogueInterfaceGenerator")
@DialogueService(ConjureLockWatchingServiceAsync.Factory.class)
public interface ConjureLockWatchingServiceAsync {
/** @apiNote {@code POST /lw/sw/{namespace}} */
@ClientEndpoint(method = "POST", path = "/lw/sw/{namespace}")
ListenableFuture startWatching(AuthHeader authHeader, @Safe String namespace, LockWatchRequest request);
/** Creates an asynchronous/non-blocking client for a ConjureLockWatchingService service. */
static ConjureLockWatchingServiceAsync of(EndpointChannelFactory _endpointChannelFactory, ConjureRuntime _runtime) {
return new ConjureLockWatchingServiceAsync() {
private final PlainSerDe _plainSerDe = _runtime.plainSerDe();
private final Serializer startWatchingSerializer =
_runtime.bodySerDe().serializer(new TypeMarker() {});
private final EndpointChannel startWatchingChannel =
_endpointChannelFactory.endpoint(DialogueConjureLockWatchingEndpoints.startWatching);
private final Deserializer startWatchingDeserializer =
_runtime.bodySerDe().emptyBodyDeserializer();
@Override
public ListenableFuture startWatching(
AuthHeader authHeader, String namespace, LockWatchRequest request) {
Request.Builder _request = Request.builder();
_request.putHeaderParams("Authorization", authHeader.toString());
_request.putPathParams("namespace", _plainSerDe.serializeString(namespace));
_request.body(startWatchingSerializer.serialize(request));
return _runtime.clients().call(startWatchingChannel, _request.build(), startWatchingDeserializer);
}
@Override
public String toString() {
return "ConjureLockWatchingServiceAsync{_endpointChannelFactory=" + _endpointChannelFactory
+ ", runtime=" + _runtime + '}';
}
};
}
/** Creates an asynchronous/non-blocking client for a ConjureLockWatchingService service. */
static ConjureLockWatchingServiceAsync 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 ConjureLockWatchingServiceAsync create(
EndpointChannelFactory endpointChannelFactory, ConjureRuntime runtime) {
return ConjureLockWatchingServiceAsync.of(endpointChannelFactory, runtime);
}
}
}