func (self *BenchmarkHarness) handleWrites(s *server) {
	clientConfig := &client.ClientConfig{
		Host:       s.ConnectionString,
		Database:   self.Config.ClusterCredentials.Database,
		Username:   self.Config.ClusterCredentials.User,
		Password:   self.Config.ClusterCredentials.Password,
		IsSecure:   self.Config.ClusterCredentials.IsSecure,
		HttpClient: NewHttpClient(self.Config.ClusterCredentials.Timeout.Duration, self.Config.ClusterCredentials.SkipVerify),
	}
	c, err := client.New(clientConfig)
	if err != nil {
		panic(fmt.Sprintf("Error connecting to server \"%s\": %s", s.ConnectionString, err))
	}
	for {
		write := <-self.writes

		startTime := time.Now()
		err := c.WriteSeries(write.Series)
		microsecondsTaken := time.Now().Sub(startTime).Nanoseconds() / 1000

		if err != nil {
			self.reportFailure(&failureResult{write: write, err: err, microseconds: microsecondsTaken})
		} else {
			self.reportSuccess(&successResult{write: write, microseconds: microsecondsTaken})
		}
	}
}
Exemple #2
0
func (self *InfluxDb) Connect(connectString string) error {
	var err error
	config := &client.ClientConfig{
		Database: "flanders",
	}
	self.connection, err = client.New(config)
	if err != nil {
		return err
	}

	return nil
}
func (self *BenchmarkHarness) reportClient() *client.Client {
	clientConfig := &client.ClientConfig{
		Host:       self.Config.StatsServer.ConnectionString,
		Database:   self.Config.StatsServer.Database,
		Username:   self.Config.StatsServer.User,
		Password:   self.Config.StatsServer.Password,
		IsSecure:   self.Config.StatsServer.IsSecure,
		HttpClient: NewHttpClient(self.Config.StatsServer.Timeout.Duration, self.Config.StatsServer.SkipVerify),
	}
	c, _ := client.New(clientConfig)
	return c
}
func (self *BenchmarkHarness) queryAndReport(loadDef *loadDefinition, q *query, queryString string) {
	s := self.Config.Servers[rand.Intn(len(self.Config.Servers))]
	clientConfig := &client.ClientConfig{
		Host:       s.ConnectionString,
		Database:   self.Config.ClusterCredentials.Database,
		Username:   self.Config.ClusterCredentials.User,
		Password:   self.Config.ClusterCredentials.Password,
		IsSecure:   self.Config.ClusterCredentials.IsSecure,
		HttpClient: NewHttpClient(self.Config.ClusterCredentials.Timeout.Duration, self.Config.ClusterCredentials.SkipVerify),
	}
	c, err := client.New(clientConfig)
	if err != nil {
		// report query fail
	}
	startTime := time.Now()
	results, err := c.Query(queryString)
	microsecondsTaken := time.Now().Sub(startTime).Nanoseconds() / 1000

	if err != nil {
		self.reportQueryFailure(q.Name, queryString, err.Error())
	} else {
		self.reportQuerySuccess(results, q.Name, microsecondsTaken)
	}
}