Пример #1
0
func (server *Server) LoadDrivers() error {
	log.Debugf("server.go: Config is %v", server.Config)
	for _, r := range server.Config.Drivers {
		if driver := drivers.GetDriver(r.Provider); driver != nil {
			if driver.Type == drivers.NotificationType(r.Type) {
				dr, err := driver.New(r.Config)
				if err != nil {
					return fmt.Errorf("failed to create %s driver:%v", r.Provider, err)
				} else if dr == nil {
					return fmt.Errorf("failed to create %s driver, it is created as nil", r.Provider)
				} else {
					server.Drivers[dr.Type()] = dr
				}
			} else {
				return fmt.Errorf("server.go: %s named driver is \"%s\" driver in config, but it is actually a \"%s\" driver", r.Provider, r.Type, driver.Type)
			}
		} else {
			return fmt.Errorf("server.go: %s named driver not found", r.Provider)
		}
	}
	return nil
}
Пример #2
0
func (server *Server) LoadDrivers() {
	log.Debugf("server.go: Config is %v", server.Config)

	for _, r := range server.Config.Drivers {
		if driver := drivers.GetDriver(r.Provider); driver != nil {
			if driver.Type == r.Type {
				dr, err := driver.New(r.Config)
				if err != nil {
					log.Errorf("server.go: Error while creating %s driver:%v", r.Provider, err)
				} else if dr == nil {
					log.Errorf("server.go: %s driver is created as nil", r.Provider)
				} else {
					server.addDriver(dr)
				}
			} else {
				log.Errorf("server.go: %s named driver is \"%s\" driver in config, but it is actually a \"%s\" driver", r.Provider, r.Type, driver.Type)
			}
		} else {
			log.Errorf("server.go: %s named driver not found", r.Provider)
		}
	}
}