Search in sources :

Example 11 with ContextTransfer

use of com.pamirs.pradar.interceptor.ContextTransfer in project LinkAgent by shulieTech.

the class ClientCallStartInterceptor method getContextTransfer.

@Override
protected ContextTransfer getContextTransfer(Advice advice) {
    Object[] args = advice.getParameterArray();
    if (args == null || args.length != 2) {
        return null;
    }
    if (!(args[1] instanceof Metadata)) {
        return null;
    }
    final Metadata metadata = (Metadata) args[1];
    return new ContextTransfer() {

        @Override
        public void transfer(String keyName, String value) {
            Metadata.Key<String> key = Metadata.Key.of(keyName, Metadata.ASCII_STRING_MARSHALLER);
            if (null != value) {
                metadata.put(key, value);
            }
        }
    };
}
Also used : ContextTransfer(com.pamirs.pradar.interceptor.ContextTransfer) Metadata(io.grpc.Metadata)

Aggregations

ContextTransfer (com.pamirs.pradar.interceptor.ContextTransfer)11 JSONObject (com.alibaba.fastjson.JSONObject)2 HttpHeaders (com.google.api.client.http.HttpHeaders)1 HttpRequest (com.google.api.client.http.HttpRequest)1 HeaderProcessor (com.pamirs.attach.plugin.apache.kafka.header.HeaderProcessor)1 InvokeContext (com.pamirs.pradar.InvokeContext)1 Request (com.weibo.api.motan.rpc.Request)1 Metadata (io.grpc.Metadata)1 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)1 HttpMessage (io.netty.handler.codec.http.HttpMessage)1 HttpURLConnection (java.net.HttpURLConnection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 MimeHeaders (javax.xml.soap.MimeHeaders)1 Call (org.apache.axis.client.Call)1 HttpMethod (org.apache.commons.httpclient.HttpMethod)1 Message (org.apache.cxf.message.Message)1 ClassicHttpRequest (org.apache.hc.core5.http.ClassicHttpRequest)1 HttpHost (org.apache.hc.core5.http.HttpHost)1