From 765509bd6874841e861f9f5edf725984b04b28df Mon Sep 17 00:00:00 2001 From: Cory LaNou Date: Thu, 6 Aug 2015 11:46:25 -0500 Subject: [PATCH] revert breaking change to `client.NewClient` function --- client/example_test.go | 8 ++++---- client/influxdb.go | 6 +++--- client/influxdb_test.go | 16 ++++++++-------- cmd/influx/main_test.go | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/client/example_test.go b/client/example_test.go index 5bb886edb0..58805ceeaa 100644 --- a/client/example_test.go +++ b/client/example_test.go @@ -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) } diff --git a/client/influxdb.go b/client/influxdb.go index 16c301d97e..b460fc28d0 100644 --- a/client/influxdb.go +++ b/client/influxdb.go @@ -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, diff --git a/client/influxdb_test.go b/client/influxdb_test.go index d30a5ee787..0a6df042ee 100644 --- a/client/influxdb_test.go +++ b/client/influxdb_test.go @@ -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 { diff --git a/cmd/influx/main_test.go b/cmd/influx/main_test.go index 2939509c20..eb58cb1e86 100644 --- a/cmd/influx/main_test.go +++ b/cmd/influx/main_test.go @@ -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)