com.turbospaces.dispatch.RequestQueuePostSpec Maven / Gradle / Ivy
package com.turbospaces.dispatch;
import java.time.Duration;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
import com.google.protobuf.Any;
import com.google.protobuf.Message;
import com.turbospaces.api.Topic;
import io.netty.util.AsciiString;
public interface RequestQueuePostSpec extends QueuePostSpec {
Any pack();
static RequestBuilder newBuilder(Message request) {
return new RequestBuilder(request);
}
static RequestBuilder newBuilder(Message request, Duration duration) {
return new RequestBuilder(request, duration);
}
public static class RequestBuilder extends Builder {
private final Message request;
public RequestBuilder(Message request) {
this.request = Objects.requireNonNull(request);
}
public RequestBuilder(Message request, Duration duration) {
super(duration);
this.request = Objects.requireNonNull(request);
}
@Override
public RequestQueuePostSpec build() {
QueuePostSpec post = super.build();
return new RequestQueuePostSpec() {
@Override
public Topic topic() {
return post.topic();
}
@Override
public Optional timeout() {
return post.timeout();
}
@Override
public Optional routingKey() {
return post.routingKey();
}
@Override
public Optional replyTo() {
return post.replyTo();
}
@Override
public UUID messageId() {
return post.messageId();
}
@Override
public Any pack() {
return Any.pack(request);
}
};
}
}
}