Skip to content

Commit

Permalink
release: update dgo module from v200 to v210 (#148)
Browse files Browse the repository at this point in the history
Upgrades module path from v200 to v210.
Note that there is nothing BREAKING in this version. All the changes are backward compatible. We have added a few new APIs since v200.03.0 release.

DialSlashEndpoint and few more related to auth/slash (these are deprecated and will be removed in later releases)
LoginIntoNamespace
Relogin
GetJwt
This PR additionally:

Updates the README with Login example.
Add deprecation comment for DialSlash* APIs
  • Loading branch information
NamanJain8 committed Apr 7, 2021
1 parent 95bfd74 commit 261d1c2
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 22 deletions.
34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ to understand how to run and work with Dgraph.
Depending on the version of Dgraph that you are connecting to, you will have to
use a different version of this client and their corresponding import paths.

Dgraph version | dgo version | dgo import path |
--------------- | ----------- | ------------------------------- |
dgraph 1.0.X | dgo 1.X.Y | "github.com/dgraph-io/dgo" |
dgraph 1.1.X | dgo 2.X.Y | "github.com/dgraph-io/dgo/v2" |
dgraph 20.03.0 | dgo 200.03.0| "github.com/dgraph-io/dgo/v200" |
Dgraph version | dgo version | dgo import path |
--------------- | ----------- | ------------------------------- |
dgraph 1.0.X | dgo 1.X.Y | "github.com/dgraph-io/dgo" |
dgraph 1.1.X | dgo 2.X.Y | "github.com/dgraph-io/dgo/v2" |
dgraph 20.03.0 | dgo 200.03.0 | "github.com/dgraph-io/dgo/v200" |
dgraph 20.07.0 | dgo 200.03.0 | "github.com/dgraph-io/dgo/v200" |
dgraph 20.11.0 | dgo 200.03.0 | "github.com/dgraph-io/dgo/v200" |
dgraph 21.03.0 | dgo 210.03.0 | "github.com/dgraph-io/dgo/v210" |

Note: One of the most important API breakages from dgo v1 to v2 is in
the function `dgo.Txn.Mutate`. This function returns an `*api.Assigned`
Expand Down Expand Up @@ -65,6 +68,27 @@ defer conn.Close()
dgraphClient := dgo.NewDgraphClient(api.NewDgraphClient(conn))
```

### Login into a namespace

If your server has Access Control Lists enabled (Dgraph v1.1 or above), the client must be
logged in for accessing data. Use `Login` endpoint:

Calling login will obtain and remember the access and refresh JWT tokens. All subsequent operations
via the logged in client will send along the stored access token.

```go
err := dgraphClient.Login(ctx, "user", "passwd")
// Check error
```

If your server additionally has namespaces (Dgraph v21.03 or above), use the
`LoginIntoNamespace` API.

```go
err := dgraphClient.LoginIntoNamespace(ctx, "user", "passwd", 0x10)
// Check error
```

### Altering the database

To set the schema, create an instance of `api.Operation` and use the `Alter` endpoint.
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ git push origin <new tag>

2. Change all the import paths to import `v<new major version>`.

For example, current import path is `"github.com/dgraph-io/dgo/v200"`.
For example, if the current import path is `"github.com/dgraph-io/dgo/v200"`.
When we release v201.07.0, we would replace the import paths to `"github.com/dgraph-io/dgo/v201"`.

3. Update [Supported Version](https://github.com/dgraph-io/dgo/#supported-versions).
Expand Down
4 changes: 2 additions & 2 deletions acl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (

"github.com/stretchr/testify/require"

"github.com/dgraph-io/dgo/v200"
"github.com/dgraph-io/dgo/v200/protos/api"
"github.com/dgraph-io/dgo/v210"
"github.com/dgraph-io/dgo/v210/protos/api"
)

var (
Expand Down
6 changes: 5 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"strings"
"sync"

"github.com/dgraph-io/dgo/v200/protos/api"
"github.com/dgraph-io/dgo/v210/protos/api"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
Expand Down Expand Up @@ -66,6 +66,8 @@ func NewDgraphClient(clients ...api.DgraphClient) *Dgraph {
return dg
}

// DialSlashEndpoint is deprecated and will be removed in v21.07 release. For more details,
// see: https://discuss.dgraph.io/t/regarding-slash-cloud-dgraph-endpoints-in-the-clients/13492
// DialSlashEndpoint creates a new TLS connection to a Slash GraphQL or Slash Enterprise backend
// It requires the backend endpoint as well as the api key
func DialSlashEndpoint(endpoint, key string) (*grpc.ClientConn, error) {
Expand All @@ -90,6 +92,8 @@ func DialSlashEndpoint(endpoint, key string) (*grpc.ClientConn, error) {
)
}

// DialSlashGraphQLEndpoint is deprecated and will be removed in v21.07 release. For more details,
// see: https://discuss.dgraph.io/t/regarding-slash-cloud-dgraph-endpoints-in-the-clients/13492
// DialSlashGraphQLEndpoint is deprecated, as it leaks GRPC connections.
// Please use DialSlashEndpoint instead
func DialSlashGraphQLEndpoint(endpoint, key string) (*Dgraph, error) {
Expand Down
4 changes: 2 additions & 2 deletions errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

"github.com/stretchr/testify/require"

"github.com/dgraph-io/dgo/v200"
"github.com/dgraph-io/dgo/v200/protos/api"
"github.com/dgraph-io/dgo/v210"
"github.com/dgraph-io/dgo/v210/protos/api"
)

func TestTxnErrFinished(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion example_get_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"fmt"
"log"

"github.com/dgraph-io/dgo/v200/protos/api"
"github.com/dgraph-io/dgo/v210/protos/api"
)

func Example_getSchema() {
Expand Down
2 changes: 1 addition & 1 deletion example_set_object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"log"
"time"

"github.com/dgraph-io/dgo/v200/protos/api"
"github.com/dgraph-io/dgo/v210/protos/api"
)

type School struct {
Expand Down
4 changes: 2 additions & 2 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"strings"
"time"

"github.com/dgraph-io/dgo/v200"
"github.com/dgraph-io/dgo/v200/protos/api"
"github.com/dgraph-io/dgo/v210"
"github.com/dgraph-io/dgo/v210/protos/api"
"google.golang.org/grpc"
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/dgraph-io/dgo/v200
module github.com/dgraph-io/dgo/v210

go 1.12

Expand Down
2 changes: 1 addition & 1 deletion testutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/pkg/errors"
"github.com/stretchr/testify/require"

"github.com/dgraph-io/dgo/v200/protos/api"
"github.com/dgraph-io/dgo/v210/protos/api"
)

// LoginParams stores the information needed to perform a login request.
Expand Down
2 changes: 1 addition & 1 deletion txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package dgo
import (
"context"

"github.com/dgraph-io/dgo/v200/protos/api"
"github.com/dgraph-io/dgo/v210/protos/api"
"github.com/pkg/errors"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand Down
4 changes: 2 additions & 2 deletions type_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"fmt"
"testing"

"github.com/dgraph-io/dgo/v200"
"github.com/dgraph-io/dgo/v200/protos/api"
"github.com/dgraph-io/dgo/v210"
"github.com/dgraph-io/dgo/v210/protos/api"

"github.com/stretchr/testify/require"
)
Expand Down
4 changes: 2 additions & 2 deletions upsert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"sort"
"testing"

"github.com/dgraph-io/dgo/v200"
"github.com/dgraph-io/dgo/v200/protos/api"
"github.com/dgraph-io/dgo/v210"
"github.com/dgraph-io/dgo/v210/protos/api"
"github.com/stretchr/testify/require"
)

Expand Down

0 comments on commit 261d1c2

Please sign in to comment.