Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public WorkflowServiceStubsImpl(
ClientInterceptor deadlineInterceptor = new GrpcDeadlineInterceptor(options);
GrpcTracingInterceptor tracingInterceptor = new GrpcTracingInterceptor();
Metadata headers = new Metadata();
headers.merge(options.getHeaders());
headers.put(LIBRARY_VERSION_HEADER_KEY, Version.LIBRARY_VERSION);
headers.put(SUPPORTED_SERVER_VERSIONS_HEADER_KEY, Version.SUPPORTED_SERVER_VERSIONS);
headers.put(CLIENT_NAME_HEADER_KEY, CLIENT_NAME_HEADER_VALUE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@

package io.temporal.serviceclient;

import com.google.common.collect.ImmutableMap;
import com.uber.m3.tally.NoopScope;
import com.uber.m3.tally.Scope;
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import io.grpc.Metadata;
import io.grpc.NameResolver;
import io.grpc.netty.shaded.io.netty.handler.ssl.SslContext;
import io.temporal.api.workflowservice.v1.WorkflowServiceGrpc;
import java.time.Duration;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
Expand Down Expand Up @@ -87,7 +86,7 @@ public static WorkflowServiceStubsOptions getDefaultInstance() {
private final Duration connectionBackoffResetFrequency;

/** Optional gRPC headers */
private final Map<String, String> headers;
private final Metadata headers;

private final Scope metricsScope;

Expand Down Expand Up @@ -143,8 +142,11 @@ private WorkflowServiceStubsOptions(Builder builder, boolean ignore) {
this.connectionBackoffResetFrequency = builder.connectionBackoffResetFrequency;
this.blockingStubInterceptor = builder.blockingStubInterceptor;
this.futureStubInterceptor = builder.futureStubInterceptor;
this.headers =
builder.headers == null ? ImmutableMap.of() : ImmutableMap.copyOf(builder.headers);
if (builder.headers != null) {
this.headers = builder.headers;
} else {
this.headers = new Metadata();
}
this.metricsScope = builder.metricsScope == null ? new NoopScope() : builder.metricsScope;
}

Expand Down Expand Up @@ -189,7 +191,7 @@ public Duration getConnectionBackoffResetFrequency() {
return connectionBackoffResetFrequency;
}

public Map<String, String> getHeaders() {
public Metadata getHeaders() {
return headers;
}

Expand Down Expand Up @@ -219,6 +221,7 @@ public Scope getMetricsScope() {
* @author venkat
*/
public static class Builder {

private ManagedChannel channel;
private SslContext sslContext;
private boolean enableHttps;
Expand All @@ -227,7 +230,7 @@ public static class Builder {
private Duration rpcLongPollTimeout = DEFAULT_POLL_RPC_TIMEOUT;
private Duration rpcQueryTimeout = DEFAULT_QUERY_RPC_TIMEOUT;
private Duration connectionBackoffResetFrequency = DEFAULT_CONNECTION_BACKOFF_RESET_FREQUENCY;
private Map<String, String> headers;
private Metadata headers;
private Function<
WorkflowServiceGrpc.WorkflowServiceBlockingStub,
WorkflowServiceGrpc.WorkflowServiceBlockingStub>
Expand Down Expand Up @@ -330,7 +333,7 @@ public Builder setQueryRpcTimeout(Duration timeout) {
return this;
}

public Builder setHeaders(Map<String, String> headers) {
public Builder setHeaders(Metadata headers) {
this.headers = headers;
return this;
}
Expand Down