本文整理汇总了Java中io.grpc.Metadata.Headers方法的典型用法代码示例。如果您正苦于以下问题:Java Metadata.Headers方法的具体用法?Java Metadata.Headers怎么用?Java Metadata.Headers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.grpc.Metadata
的用法示例。
在下文中一共展示了Metadata.Headers方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retryCall
import io.grpc.Metadata; //导入方法依赖的package包/类
private void retryCall(
RequestT payload,
Metadata.Headers requestHeaders,
Listener<ResponseT> listener) {
final Call<RequestT, ResponseT> delegate = channel.newCall(method);
delegate.start(listener, requestHeaders);
delegate.request(1);
cancelled.addListener(new Runnable() {
@Override
public void run() {
delegate.cancel();
}
}, MoreExecutors.directExecutor());
delegate.sendPayload(payload);
delegate.halfClose();
}
示例2: start
import io.grpc.Metadata; //导入方法依赖的package包/类
@Override
public void start(Listener<ResponseT> listener, Metadata.Headers headers) {
Preconditions.checkState(
this.listener == null,
"start should not be invoked more than once for unary calls.");
this.listener = listener;
this.headers = headers;
}
示例3: RetryListener
import io.grpc.Metadata; //导入方法依赖的package包/类
public RetryListener(
RetryingCall<RequestT, ResponseT> call,
RequestT payload,
Metadata.Headers requestHeaders,
boolean isRetriableCall,
Call.Listener<ResponseT> delegate) {
this.retryingCall = call;
this.delegate = delegate;
this.payload = payload;
this.requestHeaders = requestHeaders;
this.isRetriableCall = isRetriableCall;
}
示例4: start
import io.grpc.Metadata; //导入方法依赖的package包/类
@Override
public void start(Listener<ResponseT> responseListener, Metadata.Headers headers) {
Listener<ResponseT> forwardingListener = createGatheringListener(responseListener);
super.start(forwardingListener, headers);
}
示例5: wrapChannel
import io.grpc.Metadata; //导入方法依赖的package包/类
private static CloseableChannel wrapChannel(ChannelOptions channelOptions,
ExecutorService executor, Channel channel, ClientCloseHandler onClientClose) {
List<ClientInterceptor> interceptors = new ArrayList<>();
if (channelOptions.getCredential() != null) {
interceptors.add(new ClientAuthInterceptor(channelOptions.getCredential(), executor));
}
if (channelOptions.getAuthority() != null) {
Metadata.Headers headers = new Metadata.Headers();
headers.setAuthority(channelOptions.getAuthority());
interceptors.add(MetadataUtils.newAttachHeadersInterceptor(headers));
}
CallCompletionStatusInterceptor preRetryCallStatusInterceptor = null;
if (!Strings.isNullOrEmpty(channelOptions.getCallStatusReportPath())) {
preRetryCallStatusInterceptor = new CallCompletionStatusInterceptor();
interceptors.add(preRetryCallStatusInterceptor);
}
if (!interceptors.isEmpty()) {
channel = ClientInterceptors.intercept(channel, interceptors);
interceptors.clear();
}
if (channelOptions.getUnaryCallRetryOptions().enableRetries()) {
ScheduledExecutorService scheduledRetries;
if (channelOptions.getScheduledExecutorService() != null) {
scheduledRetries = channelOptions.getScheduledExecutorService();
} else {
scheduledRetries = createScheduledRetryPool();
onClientClose = createChainedCloseHandler(
onClientClose, createExecutorCloseHandler(scheduledRetries));
}
RetryOptions unaryCallRetryOptions = channelOptions.getUnaryCallRetryOptions();
channel = new UnaryCallRetryInterceptor(
channel,
scheduledRetries,
METHODS_TO_RETRY_MAP,
unaryCallRetryOptions.getInitialBackoffMillis(),
unaryCallRetryOptions.getBackoffMultiplier(),
unaryCallRetryOptions.getMaxElaspedBackoffMillis());
}
if (!Strings.isNullOrEmpty(channelOptions.getCallStatusReportPath())) {
CallCompletionStatusInterceptor postRetryCallStatusInterceptor =
new CallCompletionStatusInterceptor();
registerCallStatusReportingShutdownHook(
channelOptions.getCallStatusReportPath(),
preRetryCallStatusInterceptor,
postRetryCallStatusInterceptor);
channel = ClientInterceptors.intercept(channel, postRetryCallStatusInterceptor);
}
return createCloseableChannel(channel, onClientClose);
}
示例6: onHeaders
import io.grpc.Metadata; //导入方法依赖的package包/类
@Override
public void onHeaders(Metadata.Headers headers) {
stateSignalledToListener = true;
delegate.onHeaders(headers);
}