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
1217public 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