// New returns pointer to DataProvider
New returns pointer to DataProvider
// New returns pointer to DataProvider
func New(config *config.Config) (provider *DataProvider, err error) {
	log.Debug("Create data provider")
	provider = &DataProvider{}
	provider.sensors = make(map[string]*sensorDescription)
	provider.subscribeInfoMap = make(map[uint64]*subscribeInfo)
	provider.adapters = make([]DataAdapter, 0, 8)
	for _, adapterCfg := range config.Adapters {
		if adapterCfg.Disabled {
			log.WithField("plugin", adapterCfg.Plugin).Debug("Skip disabled adapter")
			continue
		}
		adapter, err := provider.createAdapter(adapterCfg.Plugin, adapterCfg.Params)
		if err != nil {
			return nil, err
		}
		provider.adapters = append(provider.adapters, adapter)
	}
	if len(provider.adapters) == 0 {
		return nil, errors.New("no valid adapter info provided")
	}
	return provider, nil
}
func New ( config * config . Config ) ( provider * DataProvider , err error ) { log . Debug ( " " ) provider = & DataProvider { } provider . sensors = make ( map [ string ] * sensorDescription ) provider . subscribeInfoMap = make ( map [ uint64 ] * subscribeInfo ) provider . adapters = make ( [ ] DataAdapter , 0 , 8 ) for _ , adapterCfg := range config . Adapters { if adapterCfg . Disabled { log . WithField ( " " , adapterCfg . Plugin ) . Debug ( " " ) continue } adapter , err := provider . createAdapter ( adapterCfg . Plugin , adapterCfg . Params ) if err != nil { return nil , err } provider . adapters = append ( provider . adapters , adapter ) } if len ( provider . adapters ) == 0 { return nil , errors . New ( " " ) } return provider , nil }
New returns pointer to DataProvider
New returns pointer to DataProvider