File tree 3 files changed +21
-3
lines changed
3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,10 @@ import (
6
6
"github.com/alibaba/sentinel-golang/core/config"
7
7
"github.com/alibaba/sentinel-golang/core/log/metric"
8
8
"github.com/alibaba/sentinel-golang/core/system"
9
+ "github.com/alibaba/sentinel-golang/logging"
9
10
"github.com/alibaba/sentinel-golang/util"
10
11
)
11
12
12
- // InitDefault initializes Sentinel using the configuration from system
13
13
// environment and the default value.
14
14
func InitDefault () error {
15
15
return initSentinel ("" )
@@ -50,8 +50,12 @@ func initCoreComponents() error {
50
50
if err := metric .InitTask (); err != nil {
51
51
return err
52
52
}
53
+ if ! util .IsWindowsOS () {
54
+ system .InitCollector (config .SystemStatCollectIntervalMs ())
55
+ } else {
56
+ logging .Warn ("[Init initCoreComponents] system metric collect is not available for system module in windows" )
57
+ }
53
58
54
- system .InitCollector (config .SystemStatCollectIntervalMs ())
55
59
if config .UseCacheTime () {
56
60
util .StartTimeTicker ()
57
61
}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package system
3
3
import (
4
4
"github.com/alibaba/sentinel-golang/core/base"
5
5
"github.com/alibaba/sentinel-golang/core/stat"
6
+ "github.com/alibaba/sentinel-golang/util"
6
7
)
7
8
8
9
type AdaptiveSlot struct {
@@ -12,6 +13,10 @@ func (s *AdaptiveSlot) Check(ctx *base.EntryContext) *base.TokenResult {
12
13
if ctx == nil || ctx .Resource == nil || ctx .Resource .FlowType () != base .Inbound {
13
14
return nil
14
15
}
16
+ // system module is not available for windows OS
17
+ if util .IsWindowsOS () {
18
+ return nil
19
+ }
15
20
rules := GetRules ()
16
21
result := ctx .RuleCheckResult
17
22
for _ , rule := range rules {
Original file line number Diff line number Diff line change 1
1
package util
2
2
3
- import "unsafe"
3
+ import (
4
+ "runtime"
5
+ "unsafe"
6
+ )
4
7
5
8
// SliceHeader is a safe version of SliceHeader used within this project.
6
9
type SliceHeader struct {
@@ -14,3 +17,9 @@ type StringHeader struct {
14
17
Data unsafe.Pointer
15
18
Len int
16
19
}
20
+
21
+ const windows = "windows"
22
+
23
+ func IsWindowsOS () bool {
24
+ return runtime .GOOS == windows
25
+ }
You can’t perform that action at this time.
0 commit comments