Skip to content

Commit ef47a3c

Browse files
authored
chore: change addr.Address to opengemini.Address (#201)
Signed-off-by: Young Xu <[email protected]>
1 parent b19a843 commit ef47a3c

File tree

12 files changed

+17
-33
lines changed

12 files changed

+17
-33
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ go get github.com/openGemini/opengemini-client-go
3333
Import the Client Library:
3434

3535
```go
36-
import "github.com/libgox/addr"
3736
import "github.com/openGemini/opengemini-client-go/opengemini"
3837
```
3938

4039
Create a Client:
4140

4241
```go
4342
config := &opengemini.Config{
44-
Addresses: []*addr.Address{
43+
Addresses: []*opengemini.Address{
4544
{
4645
Host: "127.0.0.1",
4746
Port: 8086,

README_CN.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ go get github.com/openGemini/opengemini-client-go
3333
引入客户端库:
3434

3535
```go
36-
import "github.com/libgox/addr"
3736
import "github.com/openGemini/opengemini-client-go/opengemini"
3837
```
3938

4039
创建客户端:
4140

4241
```go
4342
config := &opengemini.Config{
44-
Addresses: []*addr.Address{
43+
Addresses: []*opengemini.Address{
4544
{
4645
Host: "127.0.0.1",
4746
Port: 8086,

examples/example/example.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ import (
2424
"math/rand"
2525
"time"
2626

27-
"github.com/libgox/addr"
28-
2927
"github.com/openGemini/opengemini-client-go/opengemini"
3028
)
3129

3230
func main() {
3331
// create an openGemini client
3432
config := &opengemini.Config{
35-
Addresses: []addr.Address{{
33+
Addresses: []opengemini.Address{{
3634
Host: "127.0.0.1",
3735
Port: 8086,
3836
}},

examples/multiple-clients/main.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import (
1818
"fmt"
1919
"net/http"
2020

21-
"github.com/libgox/addr"
22-
2321
"github.com/openGemini/opengemini-client-go/opengemini"
2422
"github.com/prometheus/client_golang/prometheus"
2523
"github.com/prometheus/client_golang/prometheus/promhttp"
@@ -28,7 +26,7 @@ import (
2826
func main() {
2927
// create an openGemini client
3028
configA := &opengemini.Config{
31-
Addresses: []addr.Address{{
29+
Addresses: []opengemini.Address{{
3230
Host: "127.0.0.1",
3331
Port: 8086,
3432
}},
@@ -43,7 +41,7 @@ func main() {
4341
}
4442

4543
configB := &opengemini.Config{
46-
Addresses: []addr.Address{{
44+
Addresses: []opengemini.Address{{
4745
Host: "127.0.0.1",
4846
Port: 8086,
4947
}},

go.mod

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ module github.com/openGemini/opengemini-client-go
33
go 1.21
44

55
require (
6-
github.com/libgox/addr v0.2.0
76
github.com/libgox/gocollections v0.1.1
87
github.com/libgox/unicodex v0.1.0
98
github.com/prometheus/client_golang v1.20.5
10-
github.com/stretchr/testify v1.9.0
9+
github.com/stretchr/testify v1.10.0
1110
github.com/vmihailenco/msgpack/v5 v5.4.1
1211
)
1312

go.sum

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
1515
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
1616
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
1717
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
18-
github.com/libgox/addr v0.2.0 h1:he4Vv7lzcGy/1qNpjJufEWRql0S23Ki/j0XpTDMDu3s=
19-
github.com/libgox/addr v0.2.0/go.mod h1:j0hEfpRqTZy4BsstS9Egsn1U0JmNdj/VkbF2VBmJlFw=
2018
github.com/libgox/gocollections v0.1.1 h1:u102d/xMBF+8Cf/5UuFpcM/iP0NgvWlOR9tVo14Fs6s=
2119
github.com/libgox/gocollections v0.1.1/go.mod h1:Y4udpR8lStv1f67hVWbMCrcTyTvf98bFFsu/ZXvAvZ0=
2220
github.com/libgox/unicodex v0.1.0 h1:l7kBlt5yO/PLX4QmaOV6GLO7W2jFUECQsyxGWQPhwq8=
@@ -35,8 +33,8 @@ github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0leargg
3533
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
3634
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
3735
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
38-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
39-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
36+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
37+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
4038
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
4139
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
4240
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=

opengemini/client.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"log/slog"
2121
"time"
2222

23-
"github.com/libgox/addr"
2423
"github.com/prometheus/client_golang/prometheus"
2524
)
2625

@@ -126,7 +125,7 @@ type Client interface {
126125
type Config struct {
127126
// Addresses Configure the service URL for the openGemini service.
128127
// This parameter is required.
129-
Addresses []addr.Address
128+
Addresses []Address
130129
// AuthConfig configuration information for authentication.
131130
AuthConfig *AuthConfig
132131
// BatchConfig configuration information for batch processing.

opengemini/client_impl.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ import (
2020
"log/slog"
2121
"net"
2222
"net/http"
23+
"strconv"
2324
"sync/atomic"
2425
"time"
2526

26-
"github.com/libgox/addr"
2727
"github.com/libgox/gocollections/syncx"
2828
)
2929

@@ -109,14 +109,14 @@ func (c *client) Close() error {
109109
return nil
110110
}
111111

112-
func buildEndpoints(addresses []addr.Address, tlsEnabled bool) []endpoint {
112+
func buildEndpoints(addresses []Address, tlsEnabled bool) []endpoint {
113113
urls := make([]endpoint, len(addresses))
114114
protocol := "http://"
115115
if tlsEnabled {
116116
protocol = "https://"
117117
}
118118
for i, addr := range addresses {
119-
urls[i] = endpoint{url: protocol + addr.Addr()}
119+
urls[i] = endpoint{url: protocol + net.JoinHostPort(addr.Host, strconv.Itoa(addr.Port))}
120120
}
121121
return urls
122122
}

opengemini/ping_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ package opengemini
1717
import (
1818
"testing"
1919

20-
"github.com/libgox/addr"
21-
2220
"github.com/stretchr/testify/require"
2321
)
2422

@@ -31,7 +29,7 @@ func TestPingSuccess(t *testing.T) {
3129

3230
func TestPingFailForInaccessibleAddress(t *testing.T) {
3331
c := testNewClient(t, &Config{
34-
Addresses: []addr.Address{{
32+
Addresses: []Address{{
3533
Host: "localhost",
3634
Port: 8086,
3735
}, {

opengemini/query_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"testing"
2020
"time"
2121

22-
"github.com/libgox/addr"
2322
"github.com/stretchr/testify/assert"
2423
)
2524

@@ -73,7 +72,7 @@ func TestQueryWithEpoch(t *testing.T) {
7372
}
7473
func TestQueryWithMsgPack(t *testing.T) {
7574
c := testNewClient(t, &Config{
76-
Addresses: []addr.Address{{
75+
Addresses: []Address{{
7776
Host: "localhost",
7877
Port: 8086,
7978
}},

opengemini/test_util.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ package opengemini
1717
import (
1818
"testing"
1919

20-
"github.com/libgox/addr"
2120
"github.com/libgox/unicodex/letter"
2221
"github.com/stretchr/testify/require"
2322
)
2423

2524
func testDefaultClient(t *testing.T) Client {
2625
return testNewClient(t, &Config{
27-
Addresses: []addr.Address{{
26+
Addresses: []Address{{
2827
Host: "localhost",
2928
Port: 8086,
3029
}},

opengemini/write_test.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ import (
1919
"testing"
2020
"time"
2121

22-
"github.com/libgox/addr"
23-
2422
"github.com/stretchr/testify/assert"
2523
"github.com/stretchr/testify/require"
2624
)
@@ -256,7 +254,7 @@ func TestWriteAssignedIntegerField(t *testing.T) {
256254

257255
func TestWriteWithBatchInterval(t *testing.T) {
258256
c := testNewClient(t, &Config{
259-
Addresses: []addr.Address{{
257+
Addresses: []Address{{
260258
Host: "127.0.0.1",
261259
Port: 8086,
262260
}},
@@ -303,7 +301,7 @@ END:
303301

304302
func TestWriteWithBatchSize(t *testing.T) {
305303
c := testNewClient(t, &Config{
306-
Addresses: []addr.Address{{
304+
Addresses: []Address{{
307305
Host: "127.0.0.1",
308306
Port: 8086,
309307
}},

0 commit comments

Comments
 (0)