Skip to content

Commit 51a1d46

Browse files
committed
rename: callerOptions -> callerBuilder
1 parent a9d8af2 commit 51a1d46

File tree

22 files changed

+110
-110
lines changed

22 files changed

+110
-110
lines changed

src/BuildingBlocks/Service/Masa.BuildingBlocks.Service.Caller/CallerBase.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public abstract class CallerBase
1919
/// </summary>
2020
protected virtual Func<IServiceProvider, IResponseMessage>? ResponseMessageFactory => null;
2121

22-
protected CallerBuilder CallerOptions { get; private set; } = default!;
22+
protected CallerBuilder CallerBuilder { get; private set; } = default!;
2323

2424
public ILogger? Logger { get; private set; }
2525

@@ -41,9 +41,9 @@ protected virtual ICaller GetCaller()
4141

4242
public abstract void UseCallerExtension();
4343

44-
public void SetCallerOptions(CallerBuilder callerOptionsBuilder, string name)
44+
public void SetCallerOptions(CallerBuilder callerBuilder, string name)
4545
{
46-
CallerOptions = callerOptionsBuilder;
46+
CallerBuilder = callerBuilder;
4747
Name = name;
4848
}
4949

src/BuildingBlocks/Service/Masa.BuildingBlocks.Service.Caller/Extensions/CallerBuilderExtensions.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ namespace Masa.BuildingBlocks.Service.Caller;
77
public static class CallerBuilderExtensions
88
{
99
public static void UseCustomCaller(
10-
this CallerBuilder callerOptionsBuilder,
10+
this CallerBuilder callerBuilder,
1111
Func<IServiceProvider, IManualCaller> implementationFactory)
1212
{
13-
callerOptionsBuilder.Services.Configure<CallerFactoryOptions>(callerOptions =>
13+
callerBuilder.Services.Configure<CallerFactoryOptions>(factoryOptions =>
1414
{
15-
if (callerOptions.Options.Any(relation => relation.Name.Equals(callerOptionsBuilder.Name, StringComparison.OrdinalIgnoreCase)))
15+
if (factoryOptions.Options.Any(relation => relation.Name.Equals(callerBuilder.Name, StringComparison.OrdinalIgnoreCase)))
1616
throw new ArgumentException(
17-
$"The caller name already exists, please change the name, the repeat name is [{callerOptionsBuilder.Name}]");
17+
$"The caller name already exists, please change the name, the repeat name is [{callerBuilder.Name}]");
1818

19-
callerOptions.Options.Add(new MasaRelationOptions<IManualCaller>(
20-
callerOptionsBuilder.Name,
19+
factoryOptions.Options.Add(new MasaRelationOptions<IManualCaller>(
20+
callerBuilder.Name,
2121
implementationFactory));
2222
});
2323
}

src/BuildingBlocks/Service/Masa.BuildingBlocks.Service.Caller/Extensions/MasaCallerClientBuilderExtensions.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ public static void UseAuthentication(
3939

4040
AddAuthenticationCore(masaCallerClientBuilder.Services);
4141

42-
masaCallerClientBuilder.Services.Configure<AuthenticationServiceFactoryOptions>(callerOptions =>
42+
masaCallerClientBuilder.Services.Configure<AuthenticationServiceFactoryOptions>(factoryOptions =>
4343
{
44-
if (callerOptions.Options.Any(relation
44+
if (factoryOptions.Options.Any(relation
4545
=> relation.Name.Equals(masaCallerClientBuilder.Name, StringComparison.OrdinalIgnoreCase)))
4646
throw new ArgumentException(
4747
$"The caller name already exists, please change the name, the repeat name is [{masaCallerClientBuilder.Name}]");
4848

49-
callerOptions.Options.Add(new AuthenticationServiceRelationOptions(masaCallerClientBuilder.Name, implementationFactory));
49+
factoryOptions.Options.Add(new AuthenticationServiceRelationOptions(masaCallerClientBuilder.Name, implementationFactory));
5050
});
5151
}
5252

src/BuildingBlocks/Storage/Masa.BuildingBlocks.Storage.ObjectStorage/Extensions/ObjectStorageBuilderExtensions.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ public static void UseCustomObjectStorage(
1212
Func<IServiceProvider, IManualObjectStorageClient> implementationFactory,
1313
Func<IServiceProvider, IBucketNameProvider> bucketNameImplementationFactory)
1414
{
15-
objectStorageBuilder.Services.Configure<ObjectStorageFactoryOptions>(callerOptions =>
15+
objectStorageBuilder.Services.Configure<ObjectStorageFactoryOptions>(factoryOptions =>
1616
{
17-
if (callerOptions.Options.Any(relation => relation.Name.Equals(objectStorageBuilder.Name, StringComparison.OrdinalIgnoreCase)))
17+
if (factoryOptions.Options.Any(relation => relation.Name.Equals(objectStorageBuilder.Name, StringComparison.OrdinalIgnoreCase)))
1818
throw new ArgumentException(
1919
$"The ObjectStorage name already exists, please change the name, the repeat name is [{objectStorageBuilder.Name}]");
2020

21-
callerOptions.Options.Add(new(objectStorageBuilder.Name, implementationFactory));
21+
factoryOptions.Options.Add(new(objectStorageBuilder.Name, implementationFactory));
2222
});
2323

24-
objectStorageBuilder.Services.Configure<BucketNameFactoryOptions>(callerOptions =>
24+
objectStorageBuilder.Services.Configure<BucketNameFactoryOptions>(factoryOptions =>
2525
{
26-
if (callerOptions.Options.Any(relation => relation.Name.Equals(objectStorageBuilder.Name, StringComparison.OrdinalIgnoreCase)))
26+
if (factoryOptions.Options.Any(relation => relation.Name.Equals(objectStorageBuilder.Name, StringComparison.OrdinalIgnoreCase)))
2727
throw new ArgumentException(
2828
$"The Bucket name already exists, please change the name, the repeat name is [{objectStorageBuilder.Name}]");
2929

30-
callerOptions.Options.Add(new(objectStorageBuilder.Name, bucketNameImplementationFactory));
30+
factoryOptions.Options.Add(new(objectStorageBuilder.Name, bucketNameImplementationFactory));
3131
});
3232
}
3333
}

src/Contrib/Configuration/ConfigurationApi/Masa.Contrib.Configuration.ConfigurationApi.Dcc/MasaConfigurationExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ public static class MasaConfigurationExtensions
1010
public static IMasaConfigurationBuilder UseDcc(
1111
this IMasaConfigurationBuilder builder,
1212
Action<JsonSerializerOptions>? jsonSerializerOptions = null,
13-
Action<CallerBuilder>? callerOptions = null,
13+
Action<CallerBuilder>? callerBuilder = null,
1414
string sectionName = "DccOptions")
1515
{
1616
var configurationSection = builder.Configuration.GetSection(sectionName);
1717
var dccOptions = configurationSection.Get<DccOptions>();
18-
return builder.UseDcc(dccOptions, jsonSerializerOptions, callerOptions);
18+
return builder.UseDcc(dccOptions, jsonSerializerOptions, callerBuilder);
1919
}
2020

2121
public static IMasaConfigurationBuilder UseDcc(

src/Contrib/Service/Caller/Masa.Contrib.Service.Caller.DaprClient/DaprCallerBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ MasaDaprClientBuilder UseDapr()
2727
{
2828
UseDaprPre();
2929

30-
var daprClientBuilder = CallerOptions.UseDapr(callerClient =>
30+
var daprClientBuilder = CallerBuilder.UseDapr(callerClient =>
3131
{
3232
callerClient.AppId = AppId;
3333
ConfigMasaCallerClient(callerClient);

src/Contrib/Service/Caller/Masa.Contrib.Service.Caller.DaprClient/Extensions/CallerOptionsExtensions.cs src/Contrib/Service/Caller/Masa.Contrib.Service.Caller.DaprClient/Extensions/CallerBuilderExtensions.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,40 @@
55

66
namespace Masa.BuildingBlocks.Service.Caller;
77

8-
public static class CallerOptionsExtensions
8+
public static class CallerBuilderExtensions
99
{
10-
public static MasaDaprClientBuilder UseDapr(this CallerBuilder callerOptionsBuilder,
10+
public static MasaDaprClientBuilder UseDapr(this CallerBuilder callerBuilder,
1111
Action<MasaDaprClient> masDaprClientConfigure,
1212
Action<DaprClientBuilder>? configure = null)
1313
{
1414
MasaArgumentException.ThrowIfNull(masDaprClientConfigure);
1515

16-
callerOptionsBuilder.Services.AddDaprClient(configure);
16+
callerBuilder.Services.AddDaprClient(configure);
1717

18-
return callerOptionsBuilder.UseDaprCore(() =>
18+
return callerBuilder.UseDaprCore(() =>
1919
{
20-
callerOptionsBuilder.UseCustomCaller(serviceProvider =>
20+
callerBuilder.UseCustomCaller(serviceProvider =>
2121
{
2222
var masaDaprClient = new MasaDaprClient(serviceProvider);
2323
masDaprClientConfigure.Invoke(masaDaprClient);
2424
var appid = serviceProvider.GetRequiredService<ICallerProvider>().CompletionAppId(masaDaprClient.AppId);
2525

2626
return new DaprCaller(
2727
serviceProvider,
28-
callerOptionsBuilder.Name,
28+
callerBuilder.Name,
2929
appid,
3030
masaDaprClient.RequestMessageFactory,
3131
masaDaprClient.ResponseMessageFactory);
3232
});
3333
});
3434
}
3535

36-
private static MasaDaprClientBuilder UseDaprCore(this CallerBuilder callerOptionsBuilder,
36+
private static MasaDaprClientBuilder UseDaprCore(this CallerBuilder callerBuilder,
3737
Action action)
3838
{
39-
callerOptionsBuilder.Services.TryAddSingleton<ICallerProvider, DefaultCallerProvider>();
40-
callerOptionsBuilder.Services.AddOptions();
39+
callerBuilder.Services.TryAddSingleton<ICallerProvider, DefaultCallerProvider>();
40+
callerBuilder.Services.AddOptions();
4141
action.Invoke();
42-
return new MasaDaprClientBuilder(callerOptionsBuilder.Services, callerOptionsBuilder.Name);
42+
return new MasaDaprClientBuilder(callerBuilder.Services, callerBuilder.Name);
4343
}
4444
}

src/Contrib/Service/Caller/Masa.Contrib.Service.Caller.HttpClient/Extensions/CallerOptionsExtensions.cs src/Contrib/Service/Caller/Masa.Contrib.Service.Caller.HttpClient/Extensions/CallerBuilderExtensions.cs

+11-11
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,38 @@
55

66
namespace Masa.BuildingBlocks.Service.Caller;
77

8-
public static class CallerOptionsExtensions
8+
public static class CallerBuilderExtensions
99
{
10-
public static MasaHttpClientBuilder UseHttpClient(this CallerBuilder callerOptionsBuilder)
11-
=> callerOptionsBuilder.UseHttpClientCore(null);
10+
public static MasaHttpClientBuilder UseHttpClient(this CallerBuilder callerBuilder)
11+
=> callerBuilder.UseHttpClientCore(null);
1212

13-
public static MasaHttpClientBuilder UseHttpClient(this CallerBuilder callerOptionsBuilder,
13+
public static MasaHttpClientBuilder UseHttpClient(this CallerBuilder callerBuilder,
1414
Action<MasaHttpClient> clientConfigure)
1515
{
1616
MasaArgumentException.ThrowIfNull(clientConfigure);
1717

18-
return callerOptionsBuilder.UseHttpClientCore(clientConfigure);
18+
return callerBuilder.UseHttpClientCore(clientConfigure);
1919
}
2020

21-
private static MasaHttpClientBuilder UseHttpClientCore(this CallerBuilder callerOptionsBuilder,
21+
private static MasaHttpClientBuilder UseHttpClientCore(this CallerBuilder callerBuilder,
2222
Action<MasaHttpClient>? clientConfigure)
2323
{
24-
callerOptionsBuilder.Services.AddHttpClient(callerOptionsBuilder.Name);
24+
callerBuilder.Services.AddHttpClient(callerBuilder.Name);
2525

26-
callerOptionsBuilder.UseCustomCaller(serviceProvider =>
26+
callerBuilder.UseCustomCaller(serviceProvider =>
2727
{
2828
var masaHttpClient = new MasaHttpClient(serviceProvider);
2929
clientConfigure?.Invoke(masaHttpClient);
30-
var httpClient = serviceProvider.GetRequiredService<IHttpClientFactory>().CreateClient(callerOptionsBuilder.Name);
30+
var httpClient = serviceProvider.GetRequiredService<IHttpClientFactory>().CreateClient(callerBuilder.Name);
3131
masaHttpClient.ConfigureHttpClient(httpClient);
3232
return new HttpClientCaller(
3333
httpClient,
3434
serviceProvider,
35-
callerOptionsBuilder.Name,
35+
callerBuilder.Name,
3636
masaHttpClient.Prefix,
3737
masaHttpClient.RequestMessageFactory,
3838
masaHttpClient.ResponseMessageFactory);
3939
});
40-
return new MasaHttpClientBuilder(callerOptionsBuilder.Services, callerOptionsBuilder.Name);
40+
return new MasaHttpClientBuilder(callerBuilder.Services, callerBuilder.Name);
4141
}
4242
}

src/Contrib/Service/Caller/Masa.Contrib.Service.Caller.HttpClient/HttpClientCallerBase.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private MasaHttpClientBuilder UseHttpClient()
2828
{
2929
UseHttpClientPre();
3030

31-
var masaHttpClientBuilder = CallerOptions.UseHttpClient(callerClient =>
31+
var masaHttpClientBuilder = CallerBuilder.UseHttpClient(callerClient =>
3232
{
3333
callerClient.Prefix = Prefix;
3434
callerClient.BaseAddress = BaseAddress;

src/Contrib/Service/Caller/Tests/Masa.Contrib.Service.Caller.DaprClient.Tests/CallerTest.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ public class CallerTest
1616
public void TestAppIdByUseDapr()
1717
{
1818
var services = new ServiceCollection();
19-
services.AddCaller(callerOptions =>
19+
services.AddCaller(callerBuilder =>
2020
{
21-
callerOptions.UseDapr(client => client.AppId = DEFAULT_APP_ID);
21+
callerBuilder.UseDapr(client => client.AppId = DEFAULT_APP_ID);
2222
});
2323

2424
var serviceProvider = services.BuildServiceProvider();
@@ -37,9 +37,9 @@ public void TestAppIdByUseDaprAndAlwaysGetNewestDaprClient()
3737
var services = new ServiceCollection();
3838
var key = "callerBaseAddress" + Guid.NewGuid();
3939
Environment.SetEnvironmentVariable(key, DEFAULT_APP_ID);
40-
services.AddCaller(callerOptions =>
40+
services.AddCaller(callerBuilder =>
4141
{
42-
callerOptions.UseDapr(client =>
42+
callerBuilder.UseDapr(client =>
4343
{
4444
client.AppId = Environment.GetEnvironmentVariable(key)!;
4545
});
@@ -74,9 +74,9 @@ public void TestAppIdByUseDaprAndSetEnvironment()
7474
var services = new ServiceCollection();
7575
var actualAppId = Guid.NewGuid().ToString();
7676
Environment.SetEnvironmentVariable(DEFAULT_APP_ID, actualAppId);
77-
services.AddCaller(callerOptions =>
77+
services.AddCaller(callerBuilder =>
7878
{
79-
callerOptions.UseDapr(client => client.AppId = DEFAULT_APP_ID);
79+
callerBuilder.UseDapr(client => client.AppId = DEFAULT_APP_ID);
8080
});
8181

8282
var serviceProvider = services.BuildServiceProvider();
@@ -98,9 +98,9 @@ public void TestAppIdByUseDaprAndSetEnvironmentAndUseJsonConfig()
9898

9999
var actualAppId = Guid.NewGuid().ToString();
100100
Environment.SetEnvironmentVariable(DEFAULT_APP_ID, actualAppId);
101-
services.AddCaller(callerOptions =>
101+
services.AddCaller(callerBuilder =>
102102
{
103-
callerOptions.UseDapr(client => client.AppId = DEFAULT_APP_ID);
103+
callerBuilder.UseDapr(client => client.AppId = DEFAULT_APP_ID);
104104
});
105105

106106
var serviceProvider = services.BuildServiceProvider();
@@ -120,9 +120,9 @@ public void TestAppIdByUseDaprAndUseJsonConfig()
120120
var services = new ServiceCollection();
121121
AddJsonConfig(services);
122122

123-
services.AddCaller(callerOptions =>
123+
services.AddCaller(callerBuilder =>
124124
{
125-
callerOptions.UseDapr(client => client.AppId = DEFAULT_APP_ID);
125+
callerBuilder.UseDapr(client => client.AppId = DEFAULT_APP_ID);
126126
});
127127

128128
var serviceProvider = services.BuildServiceProvider();

src/Contrib/Service/Caller/Tests/Masa.Contrib.Service.Caller.HttpClient.Tests/CallerTest.cs

+12-12
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ public class CallerTest
1818

1919
private const string FRAMEWORK_BASE_ADDRESS = "https://github.com/masastack/MASA.Framework";
2020

21-
private CallerBuilder _callerOptions;
21+
private CallerBuilder _callerBuilder;
2222
private const string NAME = "";
2323

2424
[TestInitialize]
2525
public void Initialize()
2626
{
2727
var services = new ServiceCollection();
28-
_callerOptions = new CallerBuilder(services, NAME);
28+
_callerBuilder = new CallerBuilder(services, NAME);
2929
}
3030

3131
[TestMethod]
@@ -34,12 +34,12 @@ public void TestUseHttpClient()
3434
var docBaseAddress = "https://docs.masastack.com";
3535
var key = "callerBaseAddress" + Guid.NewGuid();
3636
Environment.SetEnvironmentVariable(key, FRAMEWORK_BASE_ADDRESS);
37-
var masaHttpClientBuilder = _callerOptions.UseHttpClient(httpClient =>
37+
var masaHttpClientBuilder = _callerBuilder.UseHttpClient(httpClient =>
3838
{
3939
httpClient.BaseAddress = Environment.GetEnvironmentVariable(key)!;
4040
});
4141
Assert.AreEqual(NAME, masaHttpClientBuilder.Name);
42-
Assert.AreEqual(_callerOptions.Services, masaHttpClientBuilder.Services);
42+
Assert.AreEqual(_callerBuilder.Services, masaHttpClientBuilder.Services);
4343

4444
var serviceProvider = masaHttpClientBuilder.Services.BuildServiceProvider();
4545
var httpClientFactory = serviceProvider.GetService<IHttpClientFactory>();
@@ -60,9 +60,9 @@ public void TestHttpClientByUseHttpClient()
6060
Environment.SetEnvironmentVariable(key, FRAMEWORK_BASE_ADDRESS);
6161

6262
var services = new ServiceCollection();
63-
services.AddCaller(callerOptions =>
63+
services.AddCaller(callerBuilder =>
6464
{
65-
callerOptions.UseHttpClient(client =>
65+
callerBuilder.UseHttpClient(client =>
6666
{
6767
client.Prefix = "masa";
6868
client.BaseAddress = Environment.GetEnvironmentVariable(key)!;
@@ -95,9 +95,9 @@ public void TestHttpClientByUseHttpClient()
9595
public void TestMiddlewaresByUseHttpClient()
9696
{
9797
var services = new ServiceCollection();
98-
services.AddCaller(callerOptions =>
98+
services.AddCaller(callerBuilder =>
9999
{
100-
callerOptions.UseHttpClient(client =>
100+
callerBuilder.UseHttpClient(client =>
101101
{
102102
client.BaseAddress = FRAMEWORK_BASE_ADDRESS;
103103
}).UseI18n();
@@ -116,9 +116,9 @@ public void TestMiddlewaresByUseHttpClient()
116116
public void TestRequestMessageByUseHttpClient()
117117
{
118118
var services = new ServiceCollection();
119-
services.AddCaller(callerOptions =>
119+
services.AddCaller(callerBuilder =>
120120
{
121-
callerOptions.UseHttpClient(client =>
121+
callerBuilder.UseHttpClient(client =>
122122
{
123123
client.BaseAddress = FRAMEWORK_BASE_ADDRESS;
124124
});
@@ -145,9 +145,9 @@ public void TestRequestMessageByUseHttpClient()
145145
public void TestCustomRequestMessageByUseHttpClient()
146146
{
147147
var services = new ServiceCollection();
148-
services.AddCaller(callerOptions =>
148+
services.AddCaller(callerBuilder =>
149149
{
150-
callerOptions.UseHttpClient(client =>
150+
callerBuilder.UseHttpClient(client =>
151151
{
152152
client.UseXml();
153153
client.BaseAddress = FRAMEWORK_BASE_ADDRESS;

0 commit comments

Comments
 (0)