Skip to content

Commit

Permalink
chore: change addr.Address to opengemini.Address
Browse files Browse the repository at this point in the history
Signed-off-by: Young Xu <[email protected]>
  • Loading branch information
xuthus5 committed Nov 24, 2024
1 parent b19a843 commit 3a0db9c
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 33 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ go get github.com/openGemini/opengemini-client-go
Import the Client Library:

```go
import "github.com/libgox/addr"
import "github.com/openGemini/opengemini-client-go/opengemini"
```

Create a Client:

```go
config := &opengemini.Config{
Addresses: []*addr.Address{
Addresses: []*opengemini.Address{
{
Host: "127.0.0.1",
Port: 8086,
Expand Down
3 changes: 1 addition & 2 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ go get github.com/openGemini/opengemini-client-go
引入客户端库:

```go
import "github.com/libgox/addr"
import "github.com/openGemini/opengemini-client-go/opengemini"
```

创建客户端:

```go
config := &opengemini.Config{
Addresses: []*addr.Address{
Addresses: []*opengemini.Address{
{
Host: "127.0.0.1",
Port: 8086,
Expand Down
4 changes: 1 addition & 3 deletions examples/example/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ import (
"math/rand"
"time"

"github.com/libgox/addr"

"github.com/openGemini/opengemini-client-go/opengemini"
)

func main() {
// create an openGemini client
config := &opengemini.Config{
Addresses: []addr.Address{{
Addresses: []opengemini.Address{{
Host: "127.0.0.1",
Port: 8086,
}},
Expand Down
6 changes: 2 additions & 4 deletions examples/multiple-clients/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"fmt"
"net/http"

"github.com/libgox/addr"

"github.com/openGemini/opengemini-client-go/opengemini"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand All @@ -28,7 +26,7 @@ import (
func main() {
// create an openGemini client
configA := &opengemini.Config{
Addresses: []addr.Address{{
Addresses: []opengemini.Address{{
Host: "127.0.0.1",
Port: 8086,
}},
Expand All @@ -43,7 +41,7 @@ func main() {
}

configB := &opengemini.Config{
Addresses: []addr.Address{{
Addresses: []opengemini.Address{{
Host: "127.0.0.1",
Port: 8086,
}},
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ module github.com/openGemini/opengemini-client-go
go 1.21

require (
github.com/libgox/addr v0.2.0
github.com/libgox/gocollections v0.1.1
github.com/libgox/unicodex v0.1.0
github.com/prometheus/client_golang v1.20.5
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
github.com/vmihailenco/msgpack/v5 v5.4.1
)

Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/libgox/addr v0.2.0 h1:he4Vv7lzcGy/1qNpjJufEWRql0S23Ki/j0XpTDMDu3s=
github.com/libgox/addr v0.2.0/go.mod h1:j0hEfpRqTZy4BsstS9Egsn1U0JmNdj/VkbF2VBmJlFw=
github.com/libgox/gocollections v0.1.1 h1:u102d/xMBF+8Cf/5UuFpcM/iP0NgvWlOR9tVo14Fs6s=
github.com/libgox/gocollections v0.1.1/go.mod h1:Y4udpR8lStv1f67hVWbMCrcTyTvf98bFFsu/ZXvAvZ0=
github.com/libgox/unicodex v0.1.0 h1:l7kBlt5yO/PLX4QmaOV6GLO7W2jFUECQsyxGWQPhwq8=
Expand All @@ -35,8 +33,8 @@ github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0leargg
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
Expand Down
3 changes: 1 addition & 2 deletions opengemini/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"log/slog"
"time"

"github.com/libgox/addr"
"github.com/prometheus/client_golang/prometheus"
)

Expand Down Expand Up @@ -126,7 +125,7 @@ type Client interface {
type Config struct {
// Addresses Configure the service URL for the openGemini service.
// This parameter is required.
Addresses []addr.Address
Addresses []Address
// AuthConfig configuration information for authentication.
AuthConfig *AuthConfig
// BatchConfig configuration information for batch processing.
Expand Down
6 changes: 3 additions & 3 deletions opengemini/client_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"log/slog"
"net"
"net/http"
"strconv"
"sync/atomic"
"time"

"github.com/libgox/addr"
"github.com/libgox/gocollections/syncx"
)

Expand Down Expand Up @@ -109,14 +109,14 @@ func (c *client) Close() error {
return nil
}

func buildEndpoints(addresses []addr.Address, tlsEnabled bool) []endpoint {
func buildEndpoints(addresses []Address, tlsEnabled bool) []endpoint {
urls := make([]endpoint, len(addresses))
protocol := "http://"
if tlsEnabled {
protocol = "https://"
}
for i, addr := range addresses {
urls[i] = endpoint{url: protocol + addr.Addr()}
urls[i] = endpoint{url: protocol + net.JoinHostPort(addr.Host, strconv.Itoa(addr.Port))}
}
return urls
}
Expand Down
4 changes: 1 addition & 3 deletions opengemini/ping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ package opengemini
import (
"testing"

"github.com/libgox/addr"

"github.com/stretchr/testify/require"
)

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

func TestPingFailForInaccessibleAddress(t *testing.T) {
c := testNewClient(t, &Config{
Addresses: []addr.Address{{
Addresses: []Address{{
Host: "localhost",
Port: 8086,
}, {
Expand Down
3 changes: 1 addition & 2 deletions opengemini/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"testing"
"time"

"github.com/libgox/addr"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -73,7 +72,7 @@ func TestQueryWithEpoch(t *testing.T) {
}
func TestQueryWithMsgPack(t *testing.T) {
c := testNewClient(t, &Config{
Addresses: []addr.Address{{
Addresses: []Address{{
Host: "localhost",
Port: 8086,
}},
Expand Down
3 changes: 1 addition & 2 deletions opengemini/test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ package opengemini
import (
"testing"

"github.com/libgox/addr"
"github.com/libgox/unicodex/letter"
"github.com/stretchr/testify/require"
)

func testDefaultClient(t *testing.T) Client {
return testNewClient(t, &Config{
Addresses: []addr.Address{{
Addresses: []Address{{
Host: "localhost",
Port: 8086,
}},
Expand Down
6 changes: 2 additions & 4 deletions opengemini/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"testing"
"time"

"github.com/libgox/addr"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -256,7 +254,7 @@ func TestWriteAssignedIntegerField(t *testing.T) {

func TestWriteWithBatchInterval(t *testing.T) {
c := testNewClient(t, &Config{
Addresses: []addr.Address{{
Addresses: []Address{{
Host: "127.0.0.1",
Port: 8086,
}},
Expand Down Expand Up @@ -303,7 +301,7 @@ END:

func TestWriteWithBatchSize(t *testing.T) {
c := testNewClient(t, &Config{
Addresses: []addr.Address{{
Addresses: []Address{{
Host: "127.0.0.1",
Port: 8086,
}},
Expand Down

0 comments on commit 3a0db9c

Please sign in to comment.