Skip to content

Commit 8584e8f

Browse files
committed
rename MetricPusherService -> MetricPusherHostedService
1 parent 3a6e375 commit 8584e8f

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var metricPusher = new MetricPusher(new MetricPusherOptions
2929
```
3030

3131
```c#
32-
services.AddMetricPusherService(metricPusher);
32+
services.AddMetricPusherHostedService(metricPusher);
3333
```
3434

3535
## Contribute

src/MetricPusherService.cs renamed to src/MetricPusherHostedService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
namespace Prometheus.Client.MetricPusher.HostedService;
77

8-
public class MetricPusherService : BackgroundService
8+
public class MetricPusherHostedService : BackgroundService
99
{
1010
private readonly IMetricPusher _pusher;
1111
private readonly TimeSpan _interval;
1212

13-
public MetricPusherService(IMetricPusher pusher)
13+
public MetricPusherHostedService(IMetricPusher pusher)
1414
: this(pusher, Defaults.Interval)
1515
{
1616
}
1717

18-
public MetricPusherService(IMetricPusher pusher, TimeSpan interval)
18+
public MetricPusherHostedService(IMetricPusher pusher, TimeSpan interval)
1919
{
2020
_pusher = pusher;
2121
_interval = interval;

src/ServiceCollectionExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ namespace Prometheus.Client.MetricPusher.HostedService;
66

77
public static class ServiceCollectionExtensions
88
{
9-
public static IServiceCollection AddMetricPusherService(this IServiceCollection services, IMetricPusher pusher)
9+
public static IServiceCollection AddMetricPusherHostedService(this IServiceCollection services, IMetricPusher pusher)
1010
{
11-
return AddMetricPusherService(services, pusher, Defaults.Interval);
11+
return AddMetricPusherHostedService(services, pusher, Defaults.Interval);
1212
}
1313

14-
public static IServiceCollection AddMetricPusherService(this IServiceCollection services, IMetricPusher pusher, TimeSpan interval)
14+
public static IServiceCollection AddMetricPusherHostedService(this IServiceCollection services, IMetricPusher pusher, TimeSpan interval)
1515
{
1616
if (pusher == null)
1717
throw new ArgumentNullException(nameof(pusher));
1818
if (interval == TimeSpan.Zero)
1919
throw new ArgumentOutOfRangeException(nameof(interval));
2020

21-
services.AddSingleton<IHostedService, MetricPusherService>(_ => new MetricPusherService(pusher, interval));
21+
services.AddSingleton<IHostedService, MetricPusherHostedService>(_ => new MetricPusherHostedService(pusher, interval));
2222

2323
return services;
2424
}

tests/MetricPusherServiceTests.cs renamed to tests/MetricPusherHostedServiceTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
namespace Prometheus.Client.MetricPusher.HostedService.Tests;
55

6-
public class MetricPusherServiceTests
6+
public class MetricPusherHostedServiceTests
77
{
88
[Fact]
99
public async Task WithDefaultInterval_PushMetricPeriodically()
1010
{
1111
var metricPusherMock = Substitute.For<IMetricPusher>();
12-
var metricPusherService = new MetricPusherService(metricPusherMock);
12+
var metricPusherService = new MetricPusherHostedService(metricPusherMock);
1313
var canellationToken = Arg.Any<CancellationToken>();
1414

1515
await metricPusherService.StartAsync(canellationToken);
@@ -27,7 +27,7 @@ public async Task WithDefaultInterval_PushMetricPeriodically()
2727
public async Task WithGivenInterval_PushMetricPeriodically(int seconds)
2828
{
2929
var metricPusherMock = Substitute.For<IMetricPusher>();
30-
var metricPusherService = new MetricPusherService(metricPusherMock, TimeSpan.FromSeconds(seconds));
30+
var metricPusherService = new MetricPusherHostedService(metricPusherMock, TimeSpan.FromSeconds(seconds));
3131
var canellationToken = Arg.Any<CancellationToken>();
3232

3333
await metricPusherService.StartAsync(canellationToken);

tests/ServiceCollecttionExtensionsTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public void AddMetricPusherService_WithNullMetricPusher_ThrowsArgumentNullExcept
1010
{
1111
var servicesCollection = Substitute.For<IServiceCollection>();
1212

13-
Action act = () => servicesCollection.AddMetricPusherService(null, TimeSpan.FromSeconds(1));
13+
Action act = () => servicesCollection.AddMetricPusherHostedService(null, TimeSpan.FromSeconds(1));
1414

1515
act.Should().Throw<ArgumentNullException>();
1616
}
@@ -21,7 +21,7 @@ public void AddMetricPusherService_WithZeroTimeInterval_ThrowsArgumentOutOfRange
2121
var servicesCollection = Substitute.For<IServiceCollection>();
2222
var metricPusher = Substitute.For<IMetricPusher>();
2323

24-
Action act = () => servicesCollection.AddMetricPusherService(metricPusher, TimeSpan.Zero);
24+
Action act = () => servicesCollection.AddMetricPusherHostedService(metricPusher, TimeSpan.Zero);
2525

2626
act.Should().Throw<ArgumentOutOfRangeException>();
2727
}
@@ -32,11 +32,11 @@ public void AddMetricPusherService_WithDefaultInterval_AddsMetricPusherServiceIn
3232
var servicesCollection = new ServiceCollection();
3333
var metricPusher = Substitute.For<IMetricPusher>();
3434

35-
servicesCollection.AddMetricPusherService(metricPusher);
35+
servicesCollection.AddMetricPusherHostedService(metricPusher);
3636
var provider = servicesCollection.BuildServiceProvider();
3737
var service = provider.GetRequiredService<IHostedService>();
3838

39-
service.Should().BeOfType<MetricPusherService>();
39+
service.Should().BeOfType<MetricPusherHostedService>();
4040
}
4141

4242
[Fact]
@@ -45,10 +45,10 @@ public void AddMetricPusherService_WithValidParameterValues_AddsMetricPusherServ
4545
var servicesCollection = new ServiceCollection();
4646
var metricPusher = Substitute.For<IMetricPusher>();
4747

48-
servicesCollection.AddMetricPusherService(metricPusher, TimeSpan.FromSeconds(1));
48+
servicesCollection.AddMetricPusherHostedService(metricPusher, TimeSpan.FromSeconds(1));
4949
var provider = servicesCollection.BuildServiceProvider();
5050
var service = provider.GetRequiredService<IHostedService>();
5151

52-
service.Should().BeOfType<MetricPusherService>();
52+
service.Should().BeOfType<MetricPusherHostedService>();
5353
}
5454
}

0 commit comments

Comments
 (0)