本文整理匯總了Java中io.grpc.Metadata.merge方法的典型用法代碼示例。如果您正苦於以下問題:Java Metadata.merge方法的具體用法?Java Metadata.merge怎麽用?Java Metadata.merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.grpc.Metadata
的用法示例。
在下文中一共展示了Metadata.merge方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: interceptCall
import io.grpc.Metadata; //導入方法依賴的package包/類
@Override
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
final MethodDescriptor<ReqT, RespT> method, CallOptions callOptions,
final Channel next) {
return new ClientInterceptors.CheckedForwardingClientCall<ReqT, RespT>(
next.newCall(method, callOptions)) {
@Override
protected void checkedStart(Listener<RespT> responseListener, Metadata headers)
throws StatusException {
Metadata cachedSaved;
URI uri = serviceUri(next, method);
synchronized (this) {
Map<String, List<String>> latestMetadata = getRequestMetadata(uri);
if (mLastMetadata == null || mLastMetadata != latestMetadata) {
mLastMetadata = latestMetadata;
mCached = toHeaders(mLastMetadata);
}
cachedSaved = mCached;
}
headers.merge(cachedSaved);
delegate().start(responseListener, headers);
}
};
}
示例2: interceptCall
import io.grpc.Metadata; //導入方法依賴的package包/類
@Override
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(final MethodDescriptor<ReqT, RespT> method,
CallOptions callOptions, final Channel next) {
return new ClientInterceptors.CheckedForwardingClientCall<ReqT, RespT>(
next.newCall(method, callOptions)) {
@Override
protected void checkedStart(Listener<RespT> responseListener, Metadata headers)
throws StatusException {
Metadata cachedSaved;
URI uri = serviceUri(next, method);
synchronized (GoogleCredentialsInterceptor.this) {
Map<String, List<String>> latestMetadata = getRequestMetadata(uri);
if (mLastMetadata == null || mLastMetadata != latestMetadata) {
mLastMetadata = latestMetadata;
mCached = toHeaders(mLastMetadata);
}
cachedSaved = mCached;
}
headers.merge(cachedSaved);
delegate().start(responseListener, headers);
}
};
}
示例3: interceptCall
import io.grpc.Metadata; //導入方法依賴的package包/類
@Override
public <ReqT, RespT> io.grpc.ServerCall.Listener<ReqT> interceptCall(
ServerCall<ReqT, RespT> call, Metadata headers, ServerCallHandler<ReqT, RespT> next) {
if (serverEncoding) {
call.setCompression("fzip");
}
call.setMessageCompression(enableServerMessageCompression);
Metadata headersCopy = new Metadata();
headersCopy.merge(headers);
serverResponseHeaders = headersCopy;
return next.startCall(call, headers);
}
示例4: onHeaders
import io.grpc.Metadata; //導入方法依賴的package包/類
@Override
public void onHeaders(Metadata headers) {
super.onHeaders(headers);
Metadata headersCopy = new Metadata();
headersCopy.merge(headers);
clientResponseHeaders = headersCopy;
}
示例5: interceptCall
import io.grpc.Metadata; //導入方法依賴的package包/類
@Override
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
final MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, final Channel next) {
// TODO(ejona86): If the call fails for Auth reasons, this does not properly propagate info that
// would be in WWW-Authenticate, because it does not yet have access to the header.
return new CheckedForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) {
@Override
protected void checkedStart(Listener<RespT> responseListener, Metadata headers)
throws StatusException {
Metadata cachedSaved;
URI uri = serviceUri(next, method);
synchronized (ClientAuthInterceptor.this) {
// TODO(louiscryan): This is icky but the current auth library stores the same
// metadata map until the next refresh cycle. This will be fixed once
// https://github.com/google/google-auth-library-java/issues/3
// is resolved.
// getRequestMetadata() may return a different map based on the provided URI, i.e., for
// JWT. However, today it does not cache JWT and so we won't bother tring to cache its
// return value based on the URI.
Map<String, List<String>> latestMetadata = getRequestMetadata(uri);
if (lastMetadata == null || lastMetadata != latestMetadata) {
lastMetadata = latestMetadata;
cached = toHeaders(lastMetadata);
}
cachedSaved = cached;
}
headers.merge(cachedSaved);
delegate().start(responseListener, headers);
}
};
}
示例6: start
import io.grpc.Metadata; //導入方法依賴的package包/類
@Override
public void start(Listener<RespT> responseListener, Metadata headers) {
headers.merge(extraHeaders);
super.start(responseListener, headers);
}