
com.uber.tchannel.messages.ThriftRequest Maven / Gradle / Ivy
/*
* Copyright (c) 2015 Uber Technologies, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.uber.tchannel.messages;
import com.uber.tchannel.headers.ArgScheme;
import com.uber.tchannel.headers.TransportHeaders;
import io.netty.buffer.ByteBuf;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public class ThriftRequest extends EncodedRequest {
private ThriftRequest(Builder builder) {
super(builder);
}
protected ThriftRequest(long id, long ttl,
String service, Map transportHeaders,
ByteBuf arg1, ByteBuf arg2, ByteBuf arg3) {
super(id, ttl, service, transportHeaders, arg1, arg2, arg3);
}
public static class Builder extends EncodedRequest.Builder {
public Builder(String service, String endpoint) {
super(service, endpoint);
this.transportHeaders.put(TransportHeaders.ARG_SCHEME_KEY, ArgScheme.THRIFT.getScheme());
this.argScheme = ArgScheme.THRIFT;
}
public Builder(String service, ByteBuf arg1) {
super(service, arg1);
this.transportHeaders.put(TransportHeaders.ARG_SCHEME_KEY, ArgScheme.THRIFT.getScheme());
this.argScheme = ArgScheme.THRIFT;
}
@Override
public Builder validate() {
super.validate();
return this;
}
public ThriftRequest build() {
return new ThriftRequest<>(this.validate());
}
@Override
public Builder setTimeout(long timeoutMillis) {
super.setTimeout(timeoutMillis);
return this;
}
@Override
public Builder setTimeout(long timeout, TimeUnit timeUnit) {
super.setTimeout(timeout, timeUnit);
return this;
}
@Override
public Builder setId(long id) {
super.setId(id);
return this;
}
@Override
public Builder setArg2(ByteBuf arg2) {
super.setArg2(arg2);
return this;
}
@Override
public Builder setArg3(ByteBuf arg3) {
super.setArg3(arg3);
return this;
}
@Override
public Builder setHeader(String key, String value) {
super.setHeader(key, value);
return this;
}
@Override
public Builder setHeaders(Map headers) {
super.setHeaders(headers);
return this;
}
@Override
public Builder setBody(T body) {
super.setBody(body);
return this;
}
@Override
public Builder setTransportHeader(String key, String value) {
super.setTransportHeader(key, value);
return this;
}
@Override
public Builder setTransportHeaders(Map transportHeaders) {
super.setTransportHeaders(transportHeaders);
return this;
}
@Override
public Builder setRetryLimit(int retryLimit) {
super.setRetryLimit(retryLimit);
return this;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy