revert breaking change to `client.NewClient` function

pull/3579/head
Cory LaNou 2015-08-06 11:46:25 -05:00
parent 08f84a2925
commit 765509bd68
4 changed files with 17 additions and 17 deletions

View File

@ -20,7 +20,7 @@ func ExampleNewClient() {
// NOTE: this assumes you've setup a user and have setup shell env variables,
// namely INFLUX_USER/INFLUX_PWD. If not just ommit Username/Password below.
conf := &client.Config{
conf := client.Config{
URL: *host,
Username: os.Getenv("INFLUX_USER"),
Password: os.Getenv("INFLUX_PWD"),
@ -37,7 +37,7 @@ func ExampleClient_Ping() {
if err != nil {
log.Fatal(err)
}
con, err := client.NewClient(&client.Config{URL: *host})
con, err := client.NewClient(client.Config{URL: *host})
if err != nil {
log.Fatal(err)
}
@ -54,7 +54,7 @@ func ExampleClient_Query() {
if err != nil {
log.Fatal(err)
}
con, err := client.NewClient(&client.Config{URL: *host})
con, err := client.NewClient(client.Config{URL: *host})
if err != nil {
log.Fatal(err)
}
@ -73,7 +73,7 @@ func ExampleClient_Write() {
if err != nil {
log.Fatal(err)
}
con, err := client.NewClient(&client.Config{URL: *host})
con, err := client.NewClient(client.Config{URL: *host})
if err != nil {
log.Fatal(err)
}

View File

@ -83,8 +83,8 @@ type Config struct {
}
// NewConfig will create a config to be used in connecting to the client
func NewConfig() *Config {
return &Config{
func NewConfig() Config {
return Config{
Timeout: DefaultTimeout,
}
}
@ -106,7 +106,7 @@ const (
)
// NewClient will instantiate and return a connected client to issue commands to the server.
func NewClient(c *Config) (*Client, error) {
func NewClient(c Config) (*Client, error) {
client := Client{
url: c.URL,
username: c.Username,

View File

@ -84,7 +84,7 @@ func BenchmarkUnmarshalJSON10Tags(b *testing.B) {
}
func TestNewClient(t *testing.T) {
config := &client.Config{}
config := client.Config{}
_, err := client.NewClient(config)
if err != nil {
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
@ -96,7 +96,7 @@ func TestClient_Ping(t *testing.T) {
defer ts.Close()
u, _ := url.Parse(ts.URL)
config := &client.Config{URL: *u}
config := client.Config{URL: *u}
c, err := client.NewClient(config)
if err != nil {
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
@ -122,7 +122,7 @@ func TestClient_Query(t *testing.T) {
defer ts.Close()
u, _ := url.Parse(ts.URL)
config := &client.Config{URL: *u}
config := client.Config{URL: *u}
c, err := client.NewClient(config)
if err != nil {
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
@ -154,7 +154,7 @@ func TestClient_BasicAuth(t *testing.T) {
u, _ := url.Parse(ts.URL)
u.User = url.UserPassword("username", "password")
config := &client.Config{URL: *u, Username: "username", Password: "password"}
config := client.Config{URL: *u, Username: "username", Password: "password"}
c, err := client.NewClient(config)
if err != nil {
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
@ -175,7 +175,7 @@ func TestClient_Write(t *testing.T) {
defer ts.Close()
u, _ := url.Parse(ts.URL)
config := &client.Config{URL: *u}
config := client.Config{URL: *u}
c, err := client.NewClient(config)
if err != nil {
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
@ -226,7 +226,7 @@ func TestClient_UserAgent(t *testing.T) {
for _, test := range tests {
u, _ := url.Parse(ts.URL)
config := &client.Config{URL: *u, UserAgent: test.userAgent}
config := client.Config{URL: *u, UserAgent: test.userAgent}
c, err := client.NewClient(config)
if err != nil {
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
@ -507,7 +507,7 @@ func TestClient_Timeout(t *testing.T) {
defer ts.Close()
u, _ := url.Parse(ts.URL)
config := &client.Config{URL: *u, Timeout: 500 * time.Millisecond}
config := client.Config{URL: *u, Timeout: 500 * time.Millisecond}
c, err := client.NewClient(config)
if err != nil {
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
@ -521,7 +521,7 @@ func TestClient_Timeout(t *testing.T) {
t.Fatalf("unexpected error. expected 'use of closed network connection' error, got %v", err)
}
confignotimeout := &client.Config{URL: *u}
confignotimeout := client.Config{URL: *u}
cnotimeout, err := client.NewClient(confignotimeout)
_, err = cnotimeout.Query(query)
if err != nil {

View File

@ -101,7 +101,7 @@ func TestParseCommand_Insert(t *testing.T) {
defer ts.Close()
u, _ := url.Parse(ts.URL)
config := &client.Config{URL: *u}
config := client.Config{URL: *u}
c, err := client.NewClient(config)
if err != nil {
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)
@ -138,7 +138,7 @@ func TestParseCommand_InsertInto(t *testing.T) {
defer ts.Close()
u, _ := url.Parse(ts.URL)
config := &client.Config{URL: *u}
config := client.Config{URL: *u}
c, err := client.NewClient(config)
if err != nil {
t.Fatalf("unexpected error. expected %v, actual %v", nil, err)