github.com/xmplusdev/xray-core@v1.8.10/infra/conf/observatory.go (about) 1 package conf 2 3 import ( 4 "google.golang.org/protobuf/proto" 5 6 "github.com/xmplusdev/xray-core/app/observatory" 7 "github.com/xmplusdev/xray-core/app/observatory/burst" 8 "github.com/xmplusdev/xray-core/infra/conf/cfgcommon/duration" 9 ) 10 11 type ObservatoryConfig struct { 12 SubjectSelector []string `json:"subjectSelector"` 13 ProbeURL string `json:"probeURL"` 14 ProbeInterval duration.Duration `json:"probeInterval"` 15 EnableConcurrency bool `json:"enableConcurrency"` 16 } 17 18 func (o *ObservatoryConfig) Build() (proto.Message, error) { 19 return &observatory.Config{SubjectSelector: o.SubjectSelector, ProbeUrl: o.ProbeURL, ProbeInterval: int64(o.ProbeInterval), EnableConcurrency: o.EnableConcurrency}, nil 20 } 21 22 type BurstObservatoryConfig struct { 23 SubjectSelector []string `json:"subjectSelector"` 24 // health check settings 25 HealthCheck *healthCheckSettings `json:"pingConfig,omitempty"` 26 } 27 28 func (b BurstObservatoryConfig) Build() (proto.Message, error) { 29 if result, err := b.HealthCheck.Build(); err == nil { 30 return &burst.Config{SubjectSelector: b.SubjectSelector, PingConfig: result.(*burst.HealthPingConfig)}, nil 31 } else { 32 return nil, err 33 } 34 }