MCPcopy Create free account
hub / github.com/cortexproject/cortex / UnmarshalJSON

Method UnmarshalJSON

pkg/util/validation/limits.go:447–474  ·  view source on GitHub ↗

UnmarshalJSON implements the json.Unmarshaler interface.

(data []byte)

Source from the content-addressed store, hash-verified

445
446// UnmarshalJSON implements the json.Unmarshaler interface.
447func (l *Limits) UnmarshalJSON(data []byte) error {
448 // Like the YAML method above, we want to set l to the defaults and then overwrite
449 // it with the input. We prevent an infinite loop of calling UnmarshalJSON by hiding
450 // behind type indirection.
451 if defaultLimits != nil {
452 *l = *defaultLimits
453 // Make copy of default limits. Otherwise unmarshalling would modify map in default limits.
454 l.copyNotificationIntegrationLimits(defaultLimits.NotificationRateLimitPerIntegration)
455 }
456
457 type plain Limits
458 dec := json.NewDecoder(bytes.NewReader(data))
459 dec.DisallowUnknownFields()
460
461 if err := dec.Decode((*plain)(l)); err != nil {
462 return err
463 }
464
465 if err := l.compileQueryAttributeRegex(); err != nil {
466 return err
467 }
468
469 if err := l.calculateMaxSeriesPerLabelSetId(); err != nil {
470 return err
471 }
472
473 return nil
474}
475
476func (l *Limits) calculateMaxSeriesPerLabelSetId() error {
477 hMap := map[uint64]struct{}{}

Callers 1

decodeOTLPWriteRequestFunction · 0.45

Implementers 1

Overridespkg/util/validation/limits.go

Tested by

no test coverage detected