示例#1
0
文件: main.go 项目: tracer/tracer
func loadQueryers(srv *server.Server, conf config.Config) ([]server.QueryTransport, error) {
	var out []server.QueryTransport

	transports, err := conf.QueryTransports()
	if err != nil {
		return nil, err
	}
	for _, name := range transports {
		fn, ok := server.GetQueryTransport(name)
		if !ok {
			return nil, fmt.Errorf("unsupported query transport: %s", name)
		}
		transportConf, err := conf.QueryTransportConfig(name)
		if err != nil {
			return nil, err
		}
		transport, err := fn(srv, transportConf)
		if err != nil {
			return nil, err
		}

		out = append(out, transport)
	}
	return out, nil
}
示例#2
0
文件: main.go 项目: tracer/tracer
func loadStorageTransport(srv *server.Server, conf config.Config) (server.StorageTransport, error) {
	name, err := conf.StorageTransport()
	if err != nil {
		return nil, err
	}
	fn, ok := server.GetStorageTransport(name)
	if !ok {
		return nil, fmt.Errorf("unsupported storage transport: %s", name)
	}
	transportConf, err := conf.StorageTransportConfig()
	if err != nil {
		return nil, err
	}
	return fn(srv, transportConf)
}
示例#3
0
文件: main.go 项目: tracer/tracer
func loadStorage(conf config.Config) (server.Storage, error) {
	name, err := conf.Storage()
	if err != nil {
		return nil, err
	}
	storer, ok := server.GetStorage(name)
	if !ok {
		return nil, fmt.Errorf("unsupported storage engine: %s", name)
	}
	storageConf, err := conf.StorageConfig()
	if err != nil {
		return nil, err
	}
	return storer(storageConf)
}