File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed
Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,10 @@ import (
66 "github.com/alibaba/sentinel-golang/core/config"
77 "github.com/alibaba/sentinel-golang/core/log/metric"
88 "github.com/alibaba/sentinel-golang/core/system"
9+ "github.com/alibaba/sentinel-golang/logging"
910 "github.com/alibaba/sentinel-golang/util"
1011)
1112
12- // InitDefault initializes Sentinel using the configuration from system
1313// environment and the default value.
1414func InitDefault () error {
1515 return initSentinel ("" )
@@ -50,8 +50,12 @@ func initCoreComponents() error {
5050 if err := metric .InitTask (); err != nil {
5151 return err
5252 }
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+ }
5358
54- system .InitCollector (config .SystemStatCollectIntervalMs ())
5559 if config .UseCacheTime () {
5660 util .StartTimeTicker ()
5761 }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package system
33import (
44 "github.com/alibaba/sentinel-golang/core/base"
55 "github.com/alibaba/sentinel-golang/core/stat"
6+ "github.com/alibaba/sentinel-golang/util"
67)
78
89type AdaptiveSlot struct {
@@ -12,6 +13,10 @@ func (s *AdaptiveSlot) Check(ctx *base.EntryContext) *base.TokenResult {
1213 if ctx == nil || ctx .Resource == nil || ctx .Resource .FlowType () != base .Inbound {
1314 return nil
1415 }
16+ // system module is not available for windows OS
17+ if util .IsWindowsOS () {
18+ return nil
19+ }
1520 rules := GetRules ()
1621 result := ctx .RuleCheckResult
1722 for _ , rule := range rules {
Original file line number Diff line number Diff line change 11package util
22
3- import "unsafe"
3+ import (
4+ "runtime"
5+ "unsafe"
6+ )
47
58// SliceHeader is a safe version of SliceHeader used within this project.
69type SliceHeader struct {
@@ -14,3 +17,9 @@ type StringHeader struct {
1417 Data unsafe.Pointer
1518 Len int
1619}
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