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

Rename repo to tigris-client-go #56

Merged
merged 1 commit into from
Apr 26, 2022
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "api/proto"]
path = api/proto
url = ssh://git@github.com/tigrisdata/tigrisdb-api.git
url = ssh://git@github.com/tigrisdata/tigris-api.git
branch = main
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ V=v1
GEN_DIR=${API_DIR}/server/${V}
PROTO_DIR=${API_DIR}/proto/server/${V}

BUILD_PARAM=-tags=release -ldflags "-X 'main.Version=$(VERSION)'" $(shell printenv BUILD_PARAM)
BUILD_PARAM=-tags=release -ldflags "-X 'github.com/tigrisdata/tigris-client-go/main.Version=$(VERSION)'" $(shell printenv BUILD_PARAM)
TEST_PARAM=-cover -race -tags=test $(shell printenv TEST_PARAM)

all: generate ${GO_SRC}
Expand Down Expand Up @@ -36,7 +36,7 @@ generate: ${GEN_DIR}/api.pb.go ${GEN_DIR}/health.pb.go ${API_DIR}/client/${V}/ap

mock/api_grpc.go: generate
mkdir -p mock
mockgen -package mock -destination mock/api_grpc.go github.com/tigrisdata/tigrisdb-client-go/api/server/v1 TigrisDBServer
mockgen -package mock -destination mock/api_grpc.go github.com/tigrisdata/tigris-client-go/api/server/v1 TigrisServer

mock: mock/api_grpc.go

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# TigrisDB Golang client
# Tigris Golang client

[![Go Report](https://goreportcard.com/badge/github.com/tigrisdata/tigrisdb-client-go)](https://goreportcard.com/report/github.com/tigrisdata/tigrisdb-client-go)
[![Build Status](https://github.com/tigrisdata/tigrisdb-client-go/workflows/go-test/badge.svg)]()
[![Build Status](https://github.com/tigrisdata/tigrisdb-client-go/workflows/go-lint/badge.svg)]()
[![codecov](https://codecov.io/gh/tigrisdata/tigrisdb-client-go/branch/main/graph/badge.svg)](https://codecov.io/gh/tigrisdata/tigrisdb-client-go)
[![Go Report](https://goreportcard.com/badge/github.com/tigrisdata/tigris-client-go)](https://goreportcard.com/report/github.com/tigrisdata/tigris-client-go)
[![Build Status](https://github.com/tigrisdata/tigris-client-go/workflows/go-test/badge.svg)]()
[![Build Status](https://github.com/tigrisdata/tigris-client-go/workflows/go-lint/badge.svg)]()
[![codecov](https://codecov.io/gh/tigrisdata/tigris-client-go/branch/main/graph/badge.svg)](https://codecov.io/gh/tigrisdata/tigris-client-go)

# Install

```sh
go get github.com/tigrisdata/tigrisdb-client-go@latest
go get github.com/tigrisdata/tigris-client-go@latest
```

# Example
Expand All @@ -20,7 +20,7 @@ import (
"context"
"fmt"

"github.com/tigrisdata/tigrisdb-client-go/driver"
"github.com/tigrisdata/tigris-client-go/driver"
)

func example() error {
Expand Down
1,178 changes: 589 additions & 589 deletions api/client/v1/api/http.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/proto
Submodule proto updated from 31086a to b9dbc0
326 changes: 163 additions & 163 deletions api/server/v1/api.pb.go

Large diffs are not rendered by default.

422 changes: 211 additions & 211 deletions api/server/v1/api.pb.gw.go

Large diffs are not rendered by default.

340 changes: 170 additions & 170 deletions api/server/v1/api_grpc.pb.go

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions api/server/v1/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ import (
"google.golang.org/protobuf/types/known/anypb"
)

// TigrisDBError is our Tigris HTTP counterpart of grpc status. All the APIs should use this Error to return as a user facing
// error. TigrisDBError will return grpcStatus to the muxer so that grpc client can see grpcStatus as the final output. For
// TigrisError is our Tigris HTTP counterpart of grpc status. All the APIs should use this Error to return as a user facing
// error. TigrisError will return grpcStatus to the muxer so that grpc client can see grpcStatus as the final output. For
// HTTP clients see the **MarshalStatus** method where we are returning the response by not the grpc code as that is not
// needed for HTTP clients.
type TigrisDBError struct {
type TigrisError struct {
// The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. We don't need to marshal
// this code for HTTP clients.
Code codes.Code `json:"code,omitempty"`
Expand All @@ -41,12 +41,12 @@ type TigrisDBError struct {
}

// Error to return the underlying error message
func (e *TigrisDBError) Error() string {
func (e *TigrisError) Error() string {
return e.Message
}

// GRPCStatus converts the TigrisDBError and return status.Status. This is used to return grpc status to the grpc clients
func (e *TigrisDBError) GRPCStatus() *status.Status {
// GRPCStatus converts the TigrisError and return status.Status. This is used to return grpc status to the grpc clients
func (e *TigrisError) GRPCStatus() *status.Status {
s := &spb.Status{
Code: int32(e.Code),
Message: e.Message,
Expand All @@ -69,15 +69,15 @@ func (e *TigrisDBError) GRPCStatus() *status.Status {
return status.FromProto(s)
}

// WithDetails a helper method for adding details to the TigrisDBError
func (e *TigrisDBError) WithDetails(details ...*ErrorDetails) *TigrisDBError {
// WithDetails a helper method for adding details to the TigrisError
func (e *TigrisError) WithDetails(details ...*ErrorDetails) *TigrisError {
e.Details = details
return e
}

// MarshalStatus marshal status object
func MarshalStatus(status *spb.Status) ([]byte, error) {
var resp = &TigrisDBError{}
var resp = &TigrisError{}
resp.Message = status.Message
if len(status.Details) > 0 {
var internalDetails []*ErrorDetails
Expand All @@ -96,17 +96,17 @@ func MarshalStatus(status *spb.Status) ([]byte, error) {
}

// Errorf returns Error(c, fmt.Sprintf(format, a...)).
func Errorf(c codes.Code, format string, a ...interface{}) *TigrisDBError {
func Errorf(c codes.Code, format string, a ...interface{}) *TigrisError {
return Error(c, fmt.Sprintf(format, a...))
}

// Error returns an error representing c and msg. If c is OK, returns nil.
func Error(c codes.Code, msg string) *TigrisDBError {
func Error(c codes.Code, msg string) *TigrisError {
if c == codes.OK {
return nil
}

return &TigrisDBError{
return &TigrisError{
Code: c,
Message: msg,
}
Expand Down
9 changes: 4 additions & 5 deletions api/server/v1/health.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions api/server/v1/health_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import (
"fmt"
"strings"

"github.com/tigrisdata/tigrisdb-client-go/driver"
"github.com/tigrisdata/tigris-client-go/driver"
)

// Client is the interface for a TigrisDB client.
// Client is the interface for a Tigris client.
type Client interface {
// Database returns a Database interface for the provided
// database name.
Expand Down
4 changes: 2 additions & 2 deletions client/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"path"
"path/filepath"

"github.com/tigrisdata/tigrisdb-client-go/driver"
"github.com/tigrisdata/tigris-client-go/driver"
)

// TxFunc is a user-provided function that will be run
Expand All @@ -26,7 +26,7 @@ type Tx interface {
}

// Database is the interface for interacting with a specific database
// in TigrisDB.
// in Tigris.
type Database interface {
// Transact runs the provided TranactionFunc in a transaction. If the
// function returns an error then the transaction will be aborted,
Expand Down
4 changes: 2 additions & 2 deletions driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"reflect"
)

// Driver implements TigrisDB API
// Driver implements Tigris API
type Driver interface {
// Insert array of documents into specified database and collection
Insert(ctx context.Context, db string, collection string, docs []Document, options ...*InsertOptions) (*InsertResponse, error)
Expand Down Expand Up @@ -315,7 +315,7 @@ func validateOptionsParam(options interface{}, out interface{}) (interface{}, er
return v.Index(0).Interface(), nil
}

// NewDriver connect to TigrisDB at the specified URL
// NewDriver connect to Tigris at the specified URL
// URL should be in the form: {hostname}:{port}
func NewDriver(ctx context.Context, url string, config *Config) (Driver, error) {
if config == nil {
Expand Down
46 changes: 23 additions & 23 deletions driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import (
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
api "github.com/tigrisdata/tigrisdb-client-go/api/server/v1"
"github.com/tigrisdata/tigrisdb-client-go/mock"
api "github.com/tigrisdata/tigris-client-go/api/server/v1"
"github.com/tigrisdata/tigris-client-go/mock"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
Expand All @@ -57,7 +57,7 @@ var (
documentPathPattern = "/documents/*"
)

func testError(t *testing.T, d Driver, mc *mock.MockTigrisDBServer, in error, exp error) {
func testError(t *testing.T, d Driver, mc *mock.MockTigrisServer, in error, exp error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

Expand All @@ -78,18 +78,18 @@ func testError(t *testing.T, d Driver, mc *mock.MockTigrisDBServer, in error, ex
require.Equal(t, exp, err)
}

func testErrors(t *testing.T, d Driver, mc *mock.MockTigrisDBServer) {
func testErrors(t *testing.T, d Driver, mc *mock.MockTigrisServer) {
cases := []struct {
name string
in error
exp error
}{
{"tigrisdb_error", &api.TigrisDBError{Code: codes.Unauthenticated, Message: "some error"},
&api.TigrisDBError{Code: codes.Unauthenticated, Message: "some error"}},
{"tigris_error", &api.TigrisError{Code: codes.Unauthenticated, Message: "some error"},
&api.TigrisError{Code: codes.Unauthenticated, Message: "some error"}},
{"error", fmt.Errorf("some error 1"),
&api.TigrisDBError{Code: codes.Unknown, Message: "some error 1"}},
&api.TigrisError{Code: codes.Unknown, Message: "some error 1"}},
{"grpc_error", status.Error(codes.PermissionDenied, "some error 1"),
&api.TigrisDBError{Code: codes.PermissionDenied, Message: "some error 1"}},
&api.TigrisError{Code: codes.PermissionDenied, Message: "some error 1"}},
{"no_error", nil, nil},
}

Expand Down Expand Up @@ -131,7 +131,7 @@ func pm(m proto.Message) gomock.Matcher {
return &protoMatcher{m}
}

func testTxCRUDBasic(t *testing.T, c Tx, mc *mock.MockTigrisDBServer) {
func testTxCRUDBasic(t *testing.T, c Tx, mc *mock.MockTigrisServer) {
ctx := context.TODO()

doc1 := []Document{Document(`{"K1":"vK1","K2":1,"D1":"vD1"}`)}
Expand Down Expand Up @@ -250,7 +250,7 @@ func testTxCRUDBasic(t *testing.T, c Tx, mc *mock.MockTigrisDBServer) {
require.NoError(t, err)
}

func testCRUDBasic(t *testing.T, c Driver, mc *mock.MockTigrisDBServer) {
func testCRUDBasic(t *testing.T, c Driver, mc *mock.MockTigrisServer) {
ctx := context.TODO()

doc1 := []Document{Document(`{"K1":"vK1","K2":1,"D1":"vD1"}`)}
Expand Down Expand Up @@ -336,7 +336,7 @@ func testCRUDBasic(t *testing.T, c Driver, mc *mock.MockTigrisDBServer) {
require.Equal(t, "deleted", delResp.Status)
}

func testDriverBasic(t *testing.T, c Driver, mc *mock.MockTigrisDBServer) {
func testDriverBasic(t *testing.T, c Driver, mc *mock.MockTigrisServer) {
ctx := context.TODO()

// Test empty list response
Expand Down Expand Up @@ -457,7 +457,7 @@ func testDriverBasic(t *testing.T, c Driver, mc *mock.MockTigrisDBServer) {
testCRUDBasic(t, c, mc)
}

func testTxBasic(t *testing.T, c Driver, mc *mock.MockTigrisDBServer) {
func testTxBasic(t *testing.T, c Driver, mc *mock.MockTigrisServer) {
ctx := context.TODO()

txCtx := &api.TransactionCtx{Id: "tx_id1", Origin: "origin_id1"}
Expand Down Expand Up @@ -516,7 +516,7 @@ func TestTxHTTPDriver(t *testing.T) {
testTxBasic(t, client, mockServer)
}

func testTxCRUDBasicNegative(t *testing.T, c Tx, mc *mock.MockTigrisDBServer) {
func testTxCRUDBasicNegative(t *testing.T, c Tx, mc *mock.MockTigrisServer) {
ctx := context.TODO()

doc1 := []Document{Document(`{"K1":"vK1","K2":1,"D1":"vD1"}`)}
Expand Down Expand Up @@ -620,7 +620,7 @@ func testTxCRUDBasicNegative(t *testing.T, c Tx, mc *mock.MockTigrisDBServer) {
require.Error(t, err)
}

func testTxBasicNegative(t *testing.T, c Driver, mc *mock.MockTigrisDBServer) {
func testTxBasicNegative(t *testing.T, c Driver, mc *mock.MockTigrisServer) {
ctx := context.TODO()

txCtx := &api.TransactionCtx{Id: "tx_id1", Origin: "origin_id1"}
Expand Down Expand Up @@ -700,7 +700,7 @@ func TestNewDriver(t *testing.T) {
require.Error(t, err)
}

func setupGRPCTests(t *testing.T, config *Config) (Driver, *mock.MockTigrisDBServer, func()) {
func setupGRPCTests(t *testing.T, config *Config) (Driver, *mock.MockTigrisServer, func()) {
mockServer, cancel := setupTests(t)

certPool := x509.NewCertPool()
Expand All @@ -714,7 +714,7 @@ func setupGRPCTests(t *testing.T, config *Config) (Driver, *mock.MockTigrisDBSer
return client, mockServer, func() { cancel(); _ = client.Close() }
}

func setupHTTPTests(t *testing.T, config *Config) (Driver, *mock.MockTigrisDBServer, func()) {
func setupHTTPTests(t *testing.T, config *Config) (Driver, *mock.MockTigrisServer, func()) {
mockServer, cancel := setupTests(t)

certPool := x509.NewCertPool()
Expand All @@ -731,18 +731,18 @@ func setupHTTPTests(t *testing.T, config *Config) (Driver, *mock.MockTigrisDBSer
return client, mockServer, func() { cancel(); _ = client.Close() }
}

func setupTests(t *testing.T) (*mock.MockTigrisDBServer, func()) {
func setupTests(t *testing.T) (*mock.MockTigrisServer, func()) {
c := gomock.NewController(t)

m := mock.NewMockTigrisDBServer(c)
m := mock.NewMockTigrisServer(c)

inproc := &inprocgrpc.Channel{}
client := api.NewTigrisDBClient(inproc)
client := api.NewTigrisClient(inproc)

mux := runtime.NewServeMux(runtime.WithMarshalerOption(runtime.MIMEWildcard, &runtime.JSONBuiltin{}))
err := api.RegisterTigrisDBHandlerClient(context.TODO(), mux, client)
err := api.RegisterTigrisHandlerClient(context.TODO(), mux, client)
require.NoError(t, err)
api.RegisterTigrisDBServer(inproc, m)
api.RegisterTigrisServer(inproc, m)

cert, err := tls.X509KeyPair([]byte(testServerCert), []byte(testServerKey))
require.NoError(t, err)
Expand All @@ -753,7 +753,7 @@ func setupTests(t *testing.T) (*mock.MockTigrisDBServer, func()) {
}

s := grpc.NewServer(grpc.Creds(credentials.NewTLS(tlsConfig)))
api.RegisterTigrisDBServer(s, m)
api.RegisterTigrisServer(s, m)

r := chi.NewRouter()

Expand Down Expand Up @@ -800,7 +800,7 @@ func setupTests(t *testing.T) (*mock.MockTigrisDBServer, func()) {
}
}

func testDriverAuth(t *testing.T, d Driver, mc *mock.MockTigrisDBServer, token string) {
func testDriverAuth(t *testing.T, d Driver, mc *mock.MockTigrisServer, token string) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

Expand Down
Loading