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

Function convertStreamConfigDomains

jetstream/jetstream.go:692–717  ·  view source on GitHub ↗

convertStreamConfigDomains converts domain configurations to external configurations in both mirror and sources of a StreamConfig. It creates a copy of the config to avoid modifying the caller's version.

(cfg StreamConfig)

Source from the content-addressed store, hash-verified

690// in both mirror and sources of a StreamConfig. It creates a copy of the config to avoid
691// modifying the caller's version.
692func convertStreamConfigDomains(cfg StreamConfig) (StreamConfig, error) {
693 ncfg := cfg
694 // If we have a mirror and an external domain, convert to ext.APIPrefix.
695 if ncfg.Mirror != nil && ncfg.Mirror.Domain != "" {
696 // Copy so we do not change the caller's version.
697 ncfg.Mirror = ncfg.Mirror.copy()
698 if err := ncfg.Mirror.convertDomain(); err != nil {
699 return StreamConfig{}, err
700 }
701 }
702
703 // Check sources for the same conversion.
704 if len(ncfg.Sources) > 0 {
705 ncfg.Sources = append([]*StreamSource(nil), ncfg.Sources...)
706 for i, ss := range ncfg.Sources {
707 if ss.Domain != "" {
708 ncfg.Sources[i] = ss.copy()
709 if err := ncfg.Sources[i].convertDomain(); err != nil {
710 return StreamConfig{}, err
711 }
712 }
713 }
714 }
715
716 return ncfg, nil
717}
718
719// UpdateStream updates an existing stream. If stream does not exist,
720// ErrStreamNotFound is returned.

Callers 2

CreateStreamMethod · 0.85
UpdateStreamMethod · 0.85

Calls 2

copyMethod · 0.45
convertDomainMethod · 0.45

Tested by

no test coverage detected