forked from actiontech/dble
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inner 1563 - add header metadata for grpc
- Loading branch information
1 parent
4a0f9d5
commit 5631b2a
Showing
3 changed files
with
63 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/com/actiontech/dble/cluster/general/impl/MetaDataClientInterceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.actiontech.dble.cluster.general.impl; | ||
|
||
import com.actiontech.dble.config.model.SystemConfig; | ||
import io.grpc.*; | ||
|
||
public class MetaDataClientInterceptor implements ClientInterceptor { | ||
|
||
private static String UCORE_RPC_CLIENT_ID_KEY = "universe-client-id"; | ||
private static Metadata.Key<String> dbleIdHeadKey = Metadata.Key.of(UCORE_RPC_CLIENT_ID_KEY, Metadata.ASCII_STRING_MARSHALLER); | ||
|
||
@Override | ||
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(MethodDescriptor<ReqT, RespT> method, | ||
CallOptions callOptions, Channel next) { | ||
return new ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>(next.newCall(method, callOptions)) { | ||
|
||
@Override | ||
public void start(Listener<RespT> responseListener, Metadata headers) { | ||
headers.put(dbleIdHeadKey, "dble-" + SystemConfig.getInstance().getInstanceName()); | ||
super.start(responseListener, headers); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters