func ReadConfigFromFile(path string) (*Config, error) {
	buffer, err := ioutil.ReadFile(path)
	if err != nil {
		return nil, err
	}
	return ReadConfig(buffer)
}
ReadConfigFromFile parses a YAML config file into a new Config struct.
package core
import (
	"fmt"
	"io/ioutil"
	"reflect"
	"github.com/sirupsen/logrus"
	"github.com/trivago/tgo"
	"github.com/trivago/tgo/tcontainer"
	"github.com/trivago/tgo/treflect"
	yaml "gopkg.in/yaml.v2"
)
const pluginAggregate = "Aggregate"
var (
	consumerInterface = reflect.TypeOf((*Consumer)(nil)).Elem()
	producerInterface = reflect.TypeOf((*Producer)(nil)).Elem()
	routerInterface   = reflect.TypeOf((*Router)(nil)).Elem()
)
type Config struct {
	Values  map[string]tcontainer.MarshalMap
	Plugins []PluginConfig
}
func ReadConfig(buffer []byte) (*Config, error) {
	config := new(Config)
	if err := yaml.Unmarshal(buffer, &config.Values); err != nil {
		return nil, err
	}
	hasError := false
	for pluginID, configValues := range config.Values {
		if typeName, _ := configValues.String("Type"); typeName == pluginAggregate {
			aggregateMap, err := configValues.MarshalMap("Plugins")
			if err != nil {
				hasError = true
				logrus.Error("Can't read 'Aggregate' configuration: ", err)
				continue
			}
			for subPluginID, subConfigValues := range aggregateMap {
				subPluginsID := fmt.Sprintf("%s-%s", pluginID, subPluginID)
				subConfig, err := tcontainer.ConvertToMarshalMap(subConfigValues, nil)
				if err != nil {
					hasError = true
					logrus.Error("Error in plugin config ", subPluginsID, err)
					continue
				}
				delete(configValues, "Type")
				delete(configValues, "Plugins")
				pluginConfig := NewPluginConfig(subPluginsID, "")
				pluginConfig.Read(configValues)
				pluginConfig.Read(subConfig)
				config.Plugins = append(config.Plugins, pluginConfig)
			}
		} else {
			pluginConfig := NewPluginConfig(pluginID, "")
			pluginConfig.Read(configValues)
			config.Plugins = append(config.Plugins, pluginConfig)
		}
	}
	if hasError {
		return config, fmt.Errorf("configuration parsing produced errors")
	}
	return config, nil
}