Exemple #1
0
// NewInfluxDBStore returns a new InfluxDB-backed store. It starts an
// in-process / embedded InfluxDB server.
func NewInfluxDBStore(config *InfluxDBConfig) (*InfluxDBStore, error) {
	s, err := influxDBServer.NewServer(config.Server, config.BuildInfo)
	if err != nil {
		return nil, err
	}

	// If the user specified a log output location, configure everything to use that.
	if config.LogOutput != nil {
		s.SetLogOutput(config.LogOutput)
	}
	if err := s.Open(); err != nil {
		return nil, err
	}

	httpdAddr := config.Server.HTTPD.BindAddress
	if httpdAddr == "" {
		httpdAddr = fmt.Sprintf("%s:%d", influxDBClient.DefaultHost, influxDBClient.DefaultPort)
	}
	clientTarget, err := url.Parse("http://" + httpdAddr)
	if err != nil {
		return nil, err
	}
	in := InfluxDBStore{
		config:       config,
		clientTarget: clientTarget,
		log:          log.New(os.Stderr, "appdash: InfluxDBStore: ", log.LstdFlags),
	}
	if err := in.init(s); err != nil {
		return nil, err
	}
	return &in, nil
}
// NewServer returns a new instance of Server.
func NewServer(c *run.Config) *Server {
	buildInfo := &run.BuildInfo{
		Version: "testServer",
		Commit:  "testCommit",
		Branch:  "testBranch",
	}
	srv, _ := run.NewServer(c, buildInfo)
	s := Server{
		Server: srv,
		Config: c,
	}
	return &s
}
// OpenServerWithVersion opens a test server with a specific version.
func OpenServerWithVersion(c *run.Config, version string) *Server {
	buildInfo := &run.BuildInfo{
		Version: version,
		Commit:  "",
		Branch:  "",
	}
	srv, _ := run.NewServer(c, buildInfo)
	s := Server{
		Server: srv,
		Config: c,
	}
	if err := s.Open(); err != nil {
		panic(err.Error())
	}
	configureLogging(&s)

	return &s
}