MCPcopy
hub / github.com/nats-io/nats.go / checkConfig

Function checkConfig

js.go:1611–1671  ·  view source on GitHub ↗
(s, u *ConsumerConfig)

Source from the content-addressed store, hash-verified

1609}
1610
1611func checkConfig(s, u *ConsumerConfig) error {
1612 makeErr := func(fieldName string, usrVal, srvVal any) error {
1613 return fmt.Errorf("nats: configuration requests %s to be %v, but consumer's value is %v", fieldName, usrVal, srvVal)
1614 }
1615
1616 if u.Durable != _EMPTY_ && u.Durable != s.Durable {
1617 return makeErr("durable", u.Durable, s.Durable)
1618 }
1619 if u.Description != _EMPTY_ && u.Description != s.Description {
1620 return makeErr("description", u.Description, s.Description)
1621 }
1622 if u.DeliverPolicy != deliverPolicyNotSet && u.DeliverPolicy != s.DeliverPolicy {
1623 return makeErr("deliver policy", u.DeliverPolicy, s.DeliverPolicy)
1624 }
1625 if u.OptStartSeq > 0 && u.OptStartSeq != s.OptStartSeq {
1626 return makeErr("optional start sequence", u.OptStartSeq, s.OptStartSeq)
1627 }
1628 if u.OptStartTime != nil && !u.OptStartTime.IsZero() && !(*u.OptStartTime).Equal(*s.OptStartTime) {
1629 return makeErr("optional start time", u.OptStartTime, s.OptStartTime)
1630 }
1631 if u.AckPolicy != ackPolicyNotSet && u.AckPolicy != s.AckPolicy {
1632 return makeErr("ack policy", u.AckPolicy, s.AckPolicy)
1633 }
1634 if u.AckWait > 0 && u.AckWait != s.AckWait {
1635 return makeErr("ack wait", u.AckWait, s.AckWait)
1636 }
1637 if u.MaxDeliver > 0 && u.MaxDeliver != s.MaxDeliver {
1638 return makeErr("max deliver", u.MaxDeliver, s.MaxDeliver)
1639 }
1640 if u.ReplayPolicy != replayPolicyNotSet && u.ReplayPolicy != s.ReplayPolicy {
1641 return makeErr("replay policy", u.ReplayPolicy, s.ReplayPolicy)
1642 }
1643 if u.RateLimit > 0 && u.RateLimit != s.RateLimit {
1644 return makeErr("rate limit", u.RateLimit, s.RateLimit)
1645 }
1646 if u.SampleFrequency != _EMPTY_ && u.SampleFrequency != s.SampleFrequency {
1647 return makeErr("sample frequency", u.SampleFrequency, s.SampleFrequency)
1648 }
1649 if u.MaxWaiting > 0 && u.MaxWaiting != s.MaxWaiting {
1650 return makeErr("max waiting", u.MaxWaiting, s.MaxWaiting)
1651 }
1652 if u.MaxAckPending > 0 && u.MaxAckPending != s.MaxAckPending {
1653 return makeErr("max ack pending", u.MaxAckPending, s.MaxAckPending)
1654 }
1655 // For flow control, we want to fail if the user explicit wanted it, but
1656 // it is not set in the existing consumer. If it is not asked by the user,
1657 // the library still handles it and so no reason to fail.
1658 if u.FlowControl && !s.FlowControl {
1659 return makeErr("flow control", u.FlowControl, s.FlowControl)
1660 }
1661 if u.Heartbeat > 0 && u.Heartbeat != s.Heartbeat {
1662 return makeErr("heartbeat", u.Heartbeat, s.Heartbeat)
1663 }
1664 if u.Replicas > 0 && u.Replicas != s.Replicas {
1665 return makeErr("replicas", u.Replicas, s.Replicas)
1666 }
1667 if u.MemoryStorage && !s.MemoryStorage {
1668 return makeErr("memory storage", u.MemoryStorage, s.MemoryStorage)

Callers 2

processConsInfoFunction · 0.85
AddConsumerMethod · 0.85

Calls 2

ErrorfMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected