Skip to content

Commit 5022a1e

Browse files
committed
Use CopySettingsForEmulator in PubSub clients
1 parent 6f8b4e0 commit 5022a1e

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

‎apis/Google.Cloud.PubSub.V1/Google.Cloud.PubSub.V1/PublisherServiceApiClientBuilder.cs

+15-10
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,21 @@ partial void InterceptBuildAsync(CancellationToken cancellationToken, ref Task<P
5656
private PublisherServiceApiClientBuilder MaybeCreateEmulatorClientBuilder()
5757
{
5858
var emulatorEnvironment = GetEmulatorEnvironment(s_emulatorEnvironmentVariables, s_emulatorEnvironmentVariables);
59-
return emulatorEnvironment is null ? null :
60-
// We don't set the EmulatorDetection property here to avoid recursively calling
61-
// MaybeCreateEmulatorClientBuilder().
62-
new PublisherServiceApiClientBuilder
63-
{
64-
Settings = Settings,
65-
Endpoint = emulatorEnvironment[s_emulatorHostEnvironmentVariable],
66-
ChannelCredentials = ChannelCredentials.Insecure,
67-
ChannelOptions = ChannelOptions
68-
};
59+
if (emulatorEnvironment is null)
60+
{
61+
return null;
62+
}
63+
// We don't set the EmulatorDetection property here to avoid recursively calling
64+
// MaybeCreateEmulatorClientBuilder().
65+
var builder = new PublisherServiceApiClientBuilder
66+
{
67+
Settings = Settings,
68+
Endpoint = emulatorEnvironment[s_emulatorHostEnvironmentVariable],
69+
ChannelCredentials = ChannelCredentials.Insecure,
70+
ChannelOptions = ChannelOptions
71+
};
72+
builder.CopySettingsForEmulator(this);
73+
return builder;
6974
}
7075

7176
/// <summary>

‎apis/Google.Cloud.PubSub.V1/Google.Cloud.PubSub.V1/SubscriberServiceApiClientBuilder.cs

+15-10
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,21 @@ partial void InterceptBuildAsync(CancellationToken cancellationToken, ref Task<S
5656
private SubscriberServiceApiClientBuilder MaybeCreateEmulatorClientBuilder()
5757
{
5858
var emulatorEnvironment = GetEmulatorEnvironment(s_emulatorEnvironmentVariables, s_emulatorEnvironmentVariables);
59-
return emulatorEnvironment is null ? null :
60-
// We don't set the EmulatorDetection property here to avoid recursively calling
61-
// MaybeCreateEmulatorClientBuilder().
62-
new SubscriberServiceApiClientBuilder
63-
{
64-
Settings = Settings,
65-
Endpoint = emulatorEnvironment[s_emulatorHostEnvironmentVariable],
66-
ChannelCredentials = ChannelCredentials.Insecure,
67-
ChannelOptions = ChannelOptions
68-
};
59+
if (emulatorEnvironment is null)
60+
{
61+
return null;
62+
}
63+
// We don't set the EmulatorDetection property here to avoid recursively calling
64+
// MaybeCreateEmulatorClientBuilder().
65+
var builder = new SubscriberServiceApiClientBuilder
66+
{
67+
Settings = Settings,
68+
Endpoint = emulatorEnvironment[s_emulatorHostEnvironmentVariable],
69+
ChannelCredentials = ChannelCredentials.Insecure,
70+
ChannelOptions = ChannelOptions
71+
};
72+
builder.CopySettingsForEmulator(this);
73+
return builder;
6974
}
7075

7176
/// <summary>

0 commit comments

Comments
 (0)