Skip to content

Commit 66295c1

Browse files
chore: deprecate client utils (#22)
* chore: deprecate client utils * fix: stray e * ci: add snyk argument
1 parent cb552a0 commit 66295c1

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

.github/workflows/pr-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ jobs:
5050
- name: Setup snyk
5151
uses: snyk/actions/setup@0.3.0
5252
- name: Snyk test
53-
run: snyk test --all-sub-projects --org=hypertrace --severity-threshold=low --policy-path=.snyk --configuration-matching='^runtimeClasspath$'
53+
run: snyk test --all-sub-projects --org=hypertrace --severity-threshold=low --policy-path=.snyk --configuration-matching='^runtimeClasspath$' --remote-repo-url='https://github.com/hypertrace/java-grpc-utils.git'
5454
env:
5555
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}

grpc-client-utils/src/main/java/org/hypertrace/core/grpcutils/client/GrpcClientRequestContextUtil.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,27 @@
88

99
/**
1010
* Utility class which has methods to easily read and propagate headers from GRPC request context.
11+
*
12+
* @deprecated This class has been replaced by {@link RequestContext} which can run code directly
13+
* through its {@link RequestContext#call(Callable)} and {@link RequestContext#run(Runnable)}
14+
* methods.
1115
*/
16+
@Deprecated
1217
public class GrpcClientRequestContextUtil {
1318
/**
14-
* Utility method to execute the given {@link Callable} in the context of given tenant by
15-
* setting the tenant id in the request headers.
19+
* Utility method to execute the given {@link Callable} in the context of given tenant by setting
20+
* the tenant id in the request headers.
1621
*
1722
* @throws RuntimeException if there was an issue in executing the request.
1823
*/
1924
public static <V> V executeInTenantContext(String tenantId, Callable<V> c) {
20-
return executeWithHeadersContext(Map.of(RequestContextConstants.TENANT_ID_HEADER_KEY, tenantId), c);
25+
return executeWithHeadersContext(
26+
Map.of(RequestContextConstants.TENANT_ID_HEADER_KEY, tenantId), c);
2127
}
2228

2329
/**
24-
* Same as the method above but this takes a Runnable instead of Callable. Useful when using async grpc client stubs.
30+
* Same as the method above but this takes a Runnable instead of Callable. Useful when using async
31+
* grpc client stubs.
2532
*
2633
* @param tenantId
2734
* @param r
@@ -36,19 +43,22 @@ public static void executeInTenantContext(String tenantId, Runnable r) {
3643
*
3744
* @throws RuntimeException if there was an issue in executing the request.
3845
*/
39-
public static <V> V executeWithHeadersContext(@Nonnull Map<String, String> headers, @Nonnull Callable<V> c) {
46+
public static <V> V executeWithHeadersContext(
47+
@Nonnull Map<String, String> headers, @Nonnull Callable<V> c) {
4048
RequestContext requestContext = new RequestContext();
4149
headers.forEach(requestContext::add);
4250
return requestContext.call(c);
4351
}
4452

4553
/**
46-
* Same as the method above but this takes a Runnable instead of Callable. Useful when using async grpc client stubs.
54+
* Same as the method above but this takes a Runnable instead of Callable. Useful when using async
55+
* grpc client stubs.
4756
*
4857
* @param headers
4958
* @param r
5059
*/
51-
public static void executeWithHeadersContext(@Nonnull Map<String, String> headers, @Nonnull Runnable r) {
60+
public static void executeWithHeadersContext(
61+
@Nonnull Map<String, String> headers, @Nonnull Runnable r) {
5262
RequestContext requestContext = new RequestContext();
5363
headers.forEach(requestContext::add);
5464
requestContext.run(r);

0 commit comments

Comments
 (0)