Skip to content

Commit 31e470a

Browse files
committed
refactoring for codestyle
1 parent 2ea0df7 commit 31e470a

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

sdk-workflows/src/main/java/io/dapr/workflows/client/DaprWorkflowClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import io.dapr.config.Properties;
2222
import io.dapr.utils.NetworkUtils;
2323
import io.dapr.workflows.Workflow;
24-
import io.dapr.workflows.internal.APITokenClientInterceptor;
24+
import io.dapr.workflows.internal.ApiTokenClientInterceptor;
2525
import io.grpc.CallOptions;
2626
import io.grpc.Channel;
2727
import io.grpc.ClientCall;
@@ -263,6 +263,6 @@ public void close() throws InterruptedException {
263263
}
264264
}
265265

266-
private static ClientInterceptor WORKFLOW_INTERCEPTOR = new APITokenClientInterceptor();
266+
private static ClientInterceptor WORKFLOW_INTERCEPTOR = new ApiTokenClientInterceptor();
267267
}
268268

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
/*
2+
* Copyright 2023 The Dapr Authors
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
114
package io.dapr.workflows.internal;
215

316
import io.dapr.client.Headers;
@@ -10,23 +23,23 @@
1023
import io.grpc.Metadata;
1124
import io.grpc.MethodDescriptor;
1225

13-
public class APITokenClientInterceptor implements ClientInterceptor {
14-
@Override
15-
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
16-
MethodDescriptor<ReqT, RespT> methodDescriptor,
17-
CallOptions options,
18-
Channel channel) {
19-
// TBD: do we need timeout in workflow client?
20-
ClientCall<ReqT, RespT> clientCall = channel.newCall(methodDescriptor, options);
21-
return new ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>(clientCall) {
26+
public class ApiTokenClientInterceptor implements ClientInterceptor {
27+
@Override
28+
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
29+
MethodDescriptor<ReqT, RespT> methodDescriptor,
30+
CallOptions options,
31+
Channel channel) {
32+
// TBD: do we need timeout in workflow client?
33+
ClientCall<ReqT, RespT> clientCall = channel.newCall(methodDescriptor, options);
34+
return new ForwardingClientCall.SimpleForwardingClientCall<ReqT, RespT>(clientCall) {
2235
@Override
2336
public void start(final Listener<RespT> responseListener, final Metadata metadata) {
24-
String daprApiToken = Properties.API_TOKEN.get();
25-
if (daprApiToken != null) {
26-
metadata.put(Metadata.Key.of(Headers.DAPR_API_TOKEN, Metadata.ASCII_STRING_MARSHALLER), daprApiToken);
27-
}
28-
super.start(responseListener, metadata);
37+
String daprApiToken = Properties.API_TOKEN.get();
38+
if (daprApiToken != null) {
39+
metadata.put(Metadata.Key.of(Headers.DAPR_API_TOKEN, Metadata.ASCII_STRING_MARSHALLER), daprApiToken);
40+
}
41+
super.start(responseListener, metadata);
2942
}
30-
};
31-
}
43+
};
44+
}
3245
}

sdk-workflows/src/main/java/io/dapr/workflows/runtime/WorkflowRuntimeBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
import com.microsoft.durabletask.DurableTaskGrpcWorkerBuilder;
1717
import io.dapr.utils.NetworkUtils;
1818
import io.dapr.workflows.Workflow;
19-
import io.dapr.workflows.internal.APITokenClientInterceptor;
19+
import io.dapr.workflows.internal.ApiTokenClientInterceptor;
2020
import io.grpc.ClientInterceptor;
2121

2222
public class WorkflowRuntimeBuilder {
2323
private static volatile WorkflowRuntime instance;
2424
private DurableTaskGrpcWorkerBuilder builder;
25-
private static ClientInterceptor WORKFLOW_INTERCEPTOR = new APITokenClientInterceptor();
25+
private static ClientInterceptor WORKFLOW_INTERCEPTOR = new ApiTokenClientInterceptor();
2626

2727
public WorkflowRuntimeBuilder() {
2828
this.builder = new DurableTaskGrpcWorkerBuilder().grpcChannel(

0 commit comments

Comments
 (0)