MCPcopy Index your code
hub / github.com/tailscale/tailscale / LoadRateConfig

Function LoadRateConfig

derp/derpserver/derpserver.go:538–551  ·  view source on GitHub ↗

LoadRateConfig reads and JSON-unmarshals a [RateConfig] from the file at path.

(path string)

Source from the content-addressed store, hash-verified

536
537// LoadRateConfig reads and JSON-unmarshals a [RateConfig] from the file at path.
538func LoadRateConfig(path string) (RateConfig, error) {
539 if path == "" {
540 return RateConfig{}, errors.New("rate config path is empty")
541 }
542 b, err := os.ReadFile(path)
543 if err != nil {
544 return RateConfig{}, fmt.Errorf("error reading rate config: %w", err)
545 }
546 var rc RateConfig
547 if err := json.Unmarshal(b, &rc); err != nil {
548 return RateConfig{}, fmt.Errorf("error parsing rate config: %w", err)
549 }
550 return rc, nil
551}
552
553// LoadAndApplyRateConfig reads a [RateConfig] from the file at path and
554// applies it to the server via [Server.UpdateRateLimits].

Callers 2

TestLoadRateConfigFunction · 0.85

Calls 3

ReadFileMethod · 0.65
ErrorfMethod · 0.65
NewMethod · 0.45

Tested by 1

TestLoadRateConfigFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…