當前位置: 首頁>>代碼示例>>Java>>正文


Java Metadata.merge方法代碼示例

本文整理匯總了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);
        }
    };
}
 
開發者ID:hsavaliya,項目名稱:GoogleAssistantSDK,代碼行數:25,代碼來源:SpeechService.java

示例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);
        }
    };
}
 
開發者ID:brandall76,項目名稱:Saiy-PS,代碼行數:25,代碼來源:GoogleCredentialsInterceptor.java

示例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);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:13,代碼來源:CompressionTest.java

示例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;
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:8,代碼來源:CompressionTest.java

示例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);
    }
  };
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:32,代碼來源:ClientAuthInterceptor.java

示例6: start

import io.grpc.Metadata; //導入方法依賴的package包/類
@Override
public void start(Listener<RespT> responseListener, Metadata headers) {
  headers.merge(extraHeaders);
  super.start(responseListener, headers);
}
 
開發者ID:grpc,項目名稱:grpc-java,代碼行數:6,代碼來源:MetadataUtils.java


注:本文中的io.grpc.Metadata.merge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。