observatory.go 1.1 KB

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