< Summary

Class:Microsoft.Extensions.DependencyInjection.AkkaHostedService
Assembly:SeungYongShim.Akka.DependencyInjection
File(s):/home/runner/work/SeungYongShim.Akka/SeungYongShim.Akka/src/SeungYongShim.Akka.DependencyInjection/AkkaHostedService.cs
Covered lines:17
Uncovered lines:0
Coverable lines:17
Total lines:41
Line coverage:100% (17 of 17)
Covered branches:0
Total branches:0
Tag:81_945672945

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)0%110100%
StartAsync()0%330100%
StopAsync(...)0%220100%

File(s)

/home/runner/work/SeungYongShim.Akka/SeungYongShim.Akka/src/SeungYongShim.Akka.DependencyInjection/AkkaHostedService.cs

#LineLine coverage
 1using System;
 2using System.Threading;
 3using System.Threading.Tasks;
 4using Akka.Actor;
 5using Microsoft.Extensions.Hosting;
 6
 7namespace Microsoft.Extensions.DependencyInjection
 8{
 9    internal delegate void AkkaHostedServiceStart(ActorSystem actorSystem);
 10
 11    internal class AkkaHostedService : IHostedService
 12    {
 813        public AkkaHostedService(IServiceProvider serviceProvider, ActorSystem actorSystem, AkkaHostedServiceStart akkaH
 814        {
 815            ServiceProvider = serviceProvider;
 816            ActorSystem = actorSystem;
 817            AkkaHostedServiceStart = akkaHostedServiceStart;
 818        }
 19
 20        public IServiceProvider ServiceProvider { get; }
 21        public ActorSystem ActorSystem { get; }
 22        public AkkaHostedServiceStart AkkaHostedServiceStart { get; }
 23
 24        public async Task StartAsync(CancellationToken cancellationToken)
 825        {
 826            AkkaHostedServiceStart(ActorSystem);
 27
 828            await Task.Delay(300);
 829        }
 30
 31        public Task StopAsync(CancellationToken cancellationToken)
 832        {
 833            using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10)))
 834            {
 835                ActorSystem.Terminate().Wait(cts.Token);
 836            }
 37
 838            return Task.CompletedTask;
 839        }
 40    }
 41}