Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: move all implementation code to internal #16

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.PHONY: thrift
thrift:
thrift -r -gen go:package_prefix=github.com/sclgo/impala-go/services/ interfaces/ImpalaService.thrift
rm -rf ./services
mv gen-go services
thrift -r -gen go:package_prefix=github.com/sclgo/impala-go/internal/services/ interfaces/ImpalaService.thrift
rm -rf ./internal/services
mv gen-go ./internal/services

.PHONY: cli
cli: usql
Expand Down
164 changes: 0 additions & 164 deletions cmd/impala/main.go

This file was deleted.

24 changes: 0 additions & 24 deletions cmd/test/main.go

This file was deleted.

11 changes: 6 additions & 5 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ import (

"github.com/apache/thrift/lib/go/thrift"
"github.com/samber/lo"
"github.com/sclgo/impala-go/hive"
"github.com/sclgo/impala-go/sasl"
"github.com/sclgo/impala-go/internal/hive"
"github.com/sclgo/impala-go/internal/isql"
"github.com/sclgo/impala-go/internal/sasl"
)

var (
// ErrNotSupported means this operation is not supported by impala driver
ErrNotSupported = errors.New("impala: not supported")
ErrNotSupported = isql.ErrNotSupported
)

// Driver to impala
Expand Down Expand Up @@ -170,7 +171,7 @@ func (c *connector) Driver() driver.Driver {
return c.d
}

func connect(opts *Options) (*Conn, error) {
func connect(opts *Options) (*isql.Conn, error) {

addr := net.JoinHostPort(opts.Host, opts.Port)

Expand Down Expand Up @@ -242,5 +243,5 @@ func connect(opts *Options) (*Conn, error) {
QueryTimeout: opts.QueryTimeout,
})

return &Conn{client: client, t: transport, log: logger}, nil
return isql.NewConn(client, transport, logger), nil
}
4 changes: 3 additions & 1 deletion examples/enumerateDB.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ func main() {

connector := impala.NewConnector(&opts)
db := sql.OpenDB(connector)
defer db.Close()
defer func() {
_ = db.Close()
}()

ctx := context.Background()

Expand Down
2 changes: 1 addition & 1 deletion hive/client.go → internal/hive/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"

"github.com/apache/thrift/lib/go/thrift"
"github.com/sclgo/impala-go/services/cli_service"
"github.com/sclgo/impala-go/internal/services/cli_service"
)

// Client represents Hive Client
Expand Down
3 changes: 1 addition & 2 deletions hive/dbmetadata.go → internal/hive/dbmetadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import (
"time"

"github.com/samber/lo"

"github.com/sclgo/impala-go/services/cli_service"
"github.com/sclgo/impala-go/internal/services/cli_service"
)

type TableName struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"

"github.com/google/uuid"
"github.com/sclgo/impala-go/services/cli_service"
"github.com/sclgo/impala-go/internal/services/cli_service"
"github.com/stretchr/testify/require"
)

Expand Down
2 changes: 1 addition & 1 deletion hive/hive.go → internal/hive/hive.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"fmt"

"github.com/sclgo/impala-go/services/cli_service"
"github.com/sclgo/impala-go/internal/services/cli_service"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion hive/metadata.go → internal/hive/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"reflect"
"time"

"github.com/sclgo/impala-go/services/cli_service"
"github.com/sclgo/impala-go/internal/services/cli_service"
)

type TableSchema struct {
Expand Down
2 changes: 1 addition & 1 deletion hive/operation.go → internal/hive/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"

"github.com/samber/lo"
"github.com/sclgo/impala-go/services/cli_service"
"github.com/sclgo/impala-go/internal/services/cli_service"
)

const (
Expand Down
3 changes: 1 addition & 2 deletions hive/operation_test.go → internal/hive/operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"log"
"testing"

"github.com/sclgo/impala-go/internal/services/cli_service"
"github.com/stretchr/testify/require"

"github.com/sclgo/impala-go/services/cli_service"
)

func TestOperation(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion hive/result_set.go → internal/hive/result_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io"
"time"

"github.com/sclgo/impala-go/services/cli_service"
"github.com/sclgo/impala-go/internal/services/cli_service"
)

// ResultSet ...
Expand Down
3 changes: 1 addition & 2 deletions hive/result_set_test.go → internal/hive/result_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import (
"testing"

"github.com/samber/lo"
"github.com/sclgo/impala-go/internal/services/cli_service"
"github.com/stretchr/testify/require"

"github.com/sclgo/impala-go/services/cli_service"
)

func TestResultSet(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion hive/session.go → internal/hive/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package hive
import (
"context"

"github.com/sclgo/impala-go/services/cli_service"
"github.com/sclgo/impala-go/internal/services/cli_service"
)

// Session represents hive session
Expand Down
18 changes: 16 additions & 2 deletions connection.go → internal/isql/connection.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package impala
package isql

import (
"context"
"database/sql/driver"
"errors"
"fmt"
"log"
"time"

"github.com/apache/thrift/lib/go/thrift"
"github.com/sclgo/impala-go/hive"
"github.com/sclgo/impala-go/internal/hive"
)

var (
// ErrNotSupported means this operation is not supported by impala driver
ErrNotSupported = errors.New("impala: not supported")
)

// Conn to impala. It is not used concurrently by multiple goroutines.
Expand Down Expand Up @@ -136,3 +142,11 @@ func (c *Conn) Close() error {
}
return nil
}

func NewConn(client *hive.Client, transport thrift.TTransport, logger *log.Logger) *Conn {
return &Conn{
t: transport,
client: client,
log: logger,
}
}
Loading
Loading