Commit 1e847fad authored by Liuhaoyang's avatar Liuhaoyang

Refactor IBootService

parent 07107922
...@@ -24,6 +24,8 @@ namespace SkyWalking.Boot ...@@ -24,6 +24,8 @@ namespace SkyWalking.Boot
{ {
public interface IBootService : IDisposable public interface IBootService : IDisposable
{ {
int Order { get; }
Task Initialize(CancellationToken token); Task Initialize(CancellationToken token);
} }
} }
\ No newline at end of file
...@@ -58,13 +58,10 @@ namespace SkyWalking.Boot ...@@ -58,13 +58,10 @@ namespace SkyWalking.Boot
public async Task Initialize() public async Task Initialize()
{ {
var types = FindServiceTypes(); var types = FindServiceTypes();
foreach (var type in types) foreach (var service in types.Select(Activator.CreateInstance).OfType<IBootService>().OrderBy(x => x.Order))
{ {
if (Activator.CreateInstance(type) is IBootService service) await service.Initialize(_tokenSource.Token);
{ _services.Add(service.GetType(), service);
await service.Initialize(_tokenSource.Token);
_services.Add(type, service);
}
} }
} }
......
...@@ -31,6 +31,8 @@ namespace SkyWalking.Boot ...@@ -31,6 +31,8 @@ namespace SkyWalking.Boot
{ {
} }
public virtual int Order { get; } = 2;
public async Task Initialize(CancellationToken token) public async Task Initialize(CancellationToken token)
{ {
await Initializing(token); await Initializing(token);
......
...@@ -37,6 +37,8 @@ namespace SkyWalking.Sampling ...@@ -37,6 +37,8 @@ namespace SkyWalking.Sampling
{ {
} }
public int Order { get; } = 1;
public Task Initialize(CancellationToken token) public Task Initialize(CancellationToken token)
{ {
return Task.CompletedTask; return Task.CompletedTask;
......
...@@ -14,7 +14,4 @@ ...@@ -14,7 +14,4 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SkyWalking.Abstractions\SkyWalking.Abstractions.csproj" /> <ProjectReference Include="..\SkyWalking.Abstractions\SkyWalking.Abstractions.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Remote" />
</ItemGroup>
</Project> </Project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment