Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
CAP
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
CAP
Commits
07107922
Commit
07107922
authored
Apr 15, 2018
by
Liuhaoyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor BootService
parent
88f766a6
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
117 additions
and
26 deletions
+117
-26
IBootService.cs
src/SkyWalking.Abstractions/Boot/IBootService.cs
+4
-2
CollectorConfig.cs
src/SkyWalking.Abstractions/Config/CollectorConfig.cs
+24
-0
DictionaryConfig.cs
src/SkyWalking.Abstractions/Config/DictionaryConfig.cs
+16
-16
ServiceManager.cs
src/SkyWalking.Core/Boot/ServiceManager.cs
+7
-4
TimerService.cs
src/SkyWalking.Core/Boot/TimerService.cs
+55
-0
ContextManager.cs
src/SkyWalking.Core/Context/ContextManager.cs
+3
-1
SamplingService.cs
src/SkyWalking.Core/Sampling/SamplingService.cs
+5
-3
SkyWalking.Core.csproj
src/SkyWalking.Core/SkyWalking.Core.csproj
+3
-0
No files found.
src/SkyWalking.Abstractions/Boot/IBootService.cs
View file @
07107922
...
...
@@ -17,11 +17,13 @@
*/
using
System
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
SkyWalking.Boot
{
public
interface
IBootService
:
IDisposable
public
interface
IBootService
:
IDisposable
{
void
Init
(
);
Task
Initialize
(
CancellationToken
token
);
}
}
\ No newline at end of file
src/SkyWalking.Abstractions/Config/CollectorConfig.cs
0 → 100644
View file @
07107922
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
namespace
SkyWalking.Config
{
public
class
CollectorConfig
{
}
}
\ No newline at end of file
src/SkyWalking.Abstractions/Config/DictionaryConfig.cs
View file @
07107922
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
namespace
SkyWalking.Config
{
...
...
src/SkyWalking.Core/Boot/ServiceManager.cs
View file @
07107922
...
...
@@ -20,6 +20,8 @@ using System;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Runtime.CompilerServices
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
SkyWalking.Boot
{
...
...
@@ -30,6 +32,7 @@ namespace SkyWalking.Boot
public
static
ServiceManager
Instance
=>
_instance
;
private
readonly
Dictionary
<
Type
,
object
>
_services
=
new
Dictionary
<
Type
,
object
>();
private
readonly
CancellationTokenSource
_tokenSource
=
new
CancellationTokenSource
();
private
ServiceManager
()
{
...
...
@@ -52,16 +55,14 @@ namespace SkyWalking.Boot
return
(
T
)
GetService
(
typeof
(
T
));
}
[
MethodImpl
(
MethodImplOptions
.
Synchronized
)]
public
void
Init
()
public
async
Task
Initialize
()
{
var
types
=
FindServiceTypes
();
foreach
(
var
type
in
types
)
{
if
(
Activator
.
CreateInstance
(
type
)
is
IBootService
service
)
{
service
.
Init
(
);
await
service
.
Initialize
(
_tokenSource
.
Token
);
_services
.
Add
(
type
,
service
);
}
}
...
...
@@ -70,11 +71,13 @@ namespace SkyWalking.Boot
[
MethodImpl
(
MethodImplOptions
.
Synchronized
)]
public
void
Dispose
()
{
_tokenSource
.
Cancel
();
foreach
(
var
item
in
_services
.
Values
)
{
var
service
=
item
as
IBootService
;
service
?.
Dispose
();
}
_tokenSource
.
Dispose
();
}
}
}
\ No newline at end of file
src/SkyWalking.Core/Boot/TimerService.cs
0 → 100644
View file @
07107922
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using
System
;
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
SkyWalking.Boot
{
public
abstract
class
TimerService
:
IBootService
{
protected
abstract
TimeSpan
Interval
{
get
;
}
private
Task
_task
;
public
virtual
void
Dispose
()
{
}
public
async
Task
Initialize
(
CancellationToken
token
)
{
await
Initializing
(
token
);
_task
=
Task
.
Factory
.
StartNew
(
async
()
=>
{
while
(
true
)
{
await
Execute
(
token
);
await
Task
.
Delay
(
Interval
,
token
);
}
},
token
,
TaskCreationOptions
.
LongRunning
,
TaskScheduler
.
Default
);
}
protected
virtual
Task
Initializing
(
CancellationToken
token
)
{
return
Task
.
CompletedTask
;
}
protected
abstract
Task
Execute
(
CancellationToken
token
);
}
}
\ No newline at end of file
src/SkyWalking.Core/Context/ContextManager.cs
View file @
07107922
...
...
@@ -18,6 +18,7 @@
using
System
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
SkyWalking.Boot
;
using
SkyWalking.Config
;
using
SkyWalking.Context.Trace
;
...
...
@@ -178,10 +179,11 @@ namespace SkyWalking.Context
{
}
public
void
Init
(
)
public
Task
Initialize
(
CancellationToken
token
)
{
TracingContext
.
ListenerManager
.
Add
(
this
);
IgnoredTracerContext
.
ListenerManager
.
Add
(
this
);
return
Task
.
CompletedTask
;
}
public
void
AfterFinish
(
ITracerContext
tracerContext
)
...
...
src/SkyWalking.Core/Sampling/SamplingService.cs
View file @
07107922
...
...
@@ -16,6 +16,9 @@
*
*/
using
System.Threading
;
using
System.Threading.Tasks
;
namespace
SkyWalking.Sampling
{
public
class
SamplingService
:
ISampler
...
...
@@ -32,12 +35,11 @@ namespace SkyWalking.Sampling
public
void
Dispose
()
{
throw
new
System
.
NotImplementedException
();
}
public
void
Init
(
)
public
Task
Initialize
(
CancellationToken
token
)
{
throw
new
System
.
NotImplementedException
()
;
return
Task
.
CompletedTask
;
}
}
}
\ No newline at end of file
src/SkyWalking.Core/SkyWalking.Core.csproj
View file @
07107922
...
...
@@ -14,4 +14,7 @@
<ItemGroup>
<ProjectReference Include="..\SkyWalking.Abstractions\SkyWalking.Abstractions.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Remote" />
</ItemGroup>
</Project>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment