-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add serverUUID as part of states mgmt (persistence), fix(UserMg…
…mtTest), version bump to 0.9.0.3
- Loading branch information
Showing
11 changed files
with
118 additions
and
52 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
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
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
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
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
46 changes: 46 additions & 0 deletions
46
src/main/java/io/codenotary/immudb4j/ImmuServerUUIDInterceptor.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,46 @@ | ||
package io.codenotary.immudb4j; | ||
|
||
import io.grpc.*; | ||
import io.grpc.ForwardingClientCallListener.SimpleForwardingClientCallListener; | ||
|
||
|
||
public class ImmuServerUUIDInterceptor implements ClientInterceptor { | ||
|
||
private static final String SERVER_UUID = "immudb-uuid"; | ||
|
||
private final ImmuClient client; | ||
|
||
public ImmuServerUUIDInterceptor(ImmuClient client) { | ||
this.client = client; | ||
} | ||
|
||
@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) { | ||
|
||
SimpleForwardingClientCallListener<RespT> listener = new SimpleForwardingClientCallListener<RespT>(responseListener) { | ||
|
||
@Override | ||
public void onHeaders(Metadata headers) { | ||
String serverUuid = headers.get(Metadata.Key.of(SERVER_UUID, Metadata.ASCII_STRING_MARSHALLER)); | ||
if (serverUuid != null && !serverUuid.equals(client.getCurrentServerUuid())) { | ||
client.setCurrentServerUuid(serverUuid); | ||
// System.out.printf(">>> ImmuServerUUIDInterceptor > Updated currentServerUuid to '%s'.\n", serverUuid); | ||
} | ||
super.onHeaders(headers); | ||
} | ||
}; | ||
super.start(listener, 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
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
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
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
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