Optional TLS and timeouts for statsServer

pull/603/head
Edward Muller 2014-05-30 07:41:04 -07:00
parent 7d4cc6e793
commit b7e104ac94
2 changed files with 24 additions and 5 deletions

View File

@ -12,6 +12,9 @@ connection_string = "localhost:8086"
database = "reports" database = "reports"
user = "user" user = "user"
password = "pass" password = "pass"
is_secure = false
skip_verify = false
timeout = "5s"
# A regular database, user, and password to read and write data on the cluster being benchmarked. # A regular database, user, and password to read and write data on the cluster being benchmarked.
[cluster_credentials] [cluster_credentials]

View File

@ -2,10 +2,13 @@ package main
import ( import (
crand "crypto/rand" crand "crypto/rand"
"crypto/tls"
"flag" "flag"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"math/rand" "math/rand"
"net"
"net/http"
"os" "os"
"runtime" "runtime"
"sync" "sync"
@ -27,10 +30,13 @@ type benchmarkConfig struct {
} }
type statsServer struct { type statsServer struct {
ConnectionString string `toml:"connection_string"` ConnectionString string `toml:"connection_string"`
User string `toml:"user"` User string `toml:"user"`
Password string `toml:"password"` Password string `toml:"password"`
Database string `toml:"database"` Database string `toml:"database"`
IsSecure bool `toml:"is_secure"`
SkipVerify bool `toml:"skip_verify"`
Timeout time.Duration `toml:"timeout"`
} }
type clusterCredentials struct { type clusterCredentials struct {
@ -197,7 +203,17 @@ func (self *BenchmarkHarness) reportClient() *influxdb.Client {
Host: self.Config.StatsServer.ConnectionString, Host: self.Config.StatsServer.ConnectionString,
Database: self.Config.StatsServer.Database, Database: self.Config.StatsServer.Database,
Username: self.Config.StatsServer.User, Username: self.Config.StatsServer.User,
Password: self.Config.StatsServer.Password} Password: self.Config.StatsServer.Password,
IsSecure: self.Config.StatsServer.IsSecure,
HttpClient: &http.Client{
Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: self.Config.StatsServer.SkipVerify},
ResponseHeaderTimeout: self.Config.StatsServer.Timeout,
Dial: func(network, address string) (net.Conn, error) {
return net.DialTimeout(network, address, self.Config.StatsServer.Timeout)
},
},
},
}
client, _ := influxdb.NewClient(clientConfig) client, _ := influxdb.NewClient(clientConfig)
return client return client
} }