func()

in config/service_config.go [102:153]


func (s *ServiceConfig) Init(rc *RootConfig) error {
	if err := initProviderMethodConfig(s); err != nil {
		return err
	}
	if err := defaults.Set(s); err != nil {
		return err
	}
	s.exported = atomic.NewBool(false)
	s.metadataType = rc.Application.MetadataType
	if s.Filter == "" {
		s.Filter = rc.Provider.Filter
	}
	if s.Version == "" {
		s.Version = rc.Application.Version
	}
	if s.Group == "" {
		s.Group = rc.Application.Group
	}
	s.unexported = atomic.NewBool(false)
	if len(s.RCRegistriesMap) == 0 {
		s.RCRegistriesMap = rc.Registries
	}
	if len(s.RCProtocolsMap) == 0 {
		s.RCProtocolsMap = rc.Protocols
	}
	if rc.Provider != nil {
		s.ProxyFactoryKey = rc.Provider.ProxyFactory
	}
	s.RegistryIDs = translateIds(s.RegistryIDs)
	if len(s.RegistryIDs) <= 0 {
		s.RegistryIDs = rc.Provider.RegistryIDs
	}

	s.ProtocolIDs = translateIds(s.ProtocolIDs)
	if len(s.ProtocolIDs) <= 0 {
		s.ProtocolIDs = rc.Provider.ProtocolIDs
	}
	if len(s.ProtocolIDs) <= 0 {
		for k := range rc.Protocols {
			s.ProtocolIDs = append(s.ProtocolIDs, k)
		}
	}
	if s.TracingKey == "" {
		s.TracingKey = rc.Provider.TracingKey
	}
	err := s.check()
	if err != nil {
		panic(err)
	}
	s.export = true
	return verify(s)
}