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

Implement MsgCount for Tigris #928

Merged
merged 22 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
No need for grpc
  • Loading branch information
Elena Grahovac committed Jul 21, 2022
commit 92bbd9e05632ee70efd5491a2a47227f8a5fe6e4
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
golang.org/x/exp v0.0.0-20220713135740-79cabaa25d75
golang.org/x/net v0.0.0-20220708220712-1185a9018129
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8
google.golang.org/grpc v1.48.0
google.golang.org/grpc v1.48.0 // indirect
AlekSi marked this conversation as resolved.
Show resolved Hide resolved
)

require (
Expand Down
11 changes: 7 additions & 4 deletions internal/handlers/tigris/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ package tigris

import (
"context"
"errors"

tigris "github.com/tigrisdata/tigris-client-go/api/server/v1"
"github.com/tigrisdata/tigris-client-go/driver"
"go.uber.org/zap"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/FerretDB/FerretDB/internal/tjson"
"github.com/FerretDB/FerretDB/internal/types"
Expand All @@ -41,14 +41,17 @@ func (h *Handler) fetch(ctx context.Context, param fetchParam) ([]*types.Documen

collection, err := db.DescribeCollection(ctx, param.collection)
if err != nil {
if status.Code(err) == codes.NotFound {
var tigErr *tigris.TigrisError
if !errors.As(err, &tigErr) {
return nil, lazyerrors.Error(err)
}
if tigErr.Code == tigris.Code_NOT_FOUND {
h.L.Debug(
"Collection doesn't exist, handling a case to deal with a non-existing collection (return empty list)",
zap.String("db", param.db), zap.String("collection", param.collection),
)
return []*types.Document{}, nil
}

return nil, lazyerrors.Error(err)
}

Expand Down
10 changes: 7 additions & 3 deletions internal/handlers/tigris/msg_drop.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ package tigris

import (
"context"
"errors"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
tigris "github.com/tigrisdata/tigris-client-go/api/server/v1"

"github.com/FerretDB/FerretDB/internal/handlers/common"
"github.com/FerretDB/FerretDB/internal/types"
Expand Down Expand Up @@ -47,7 +47,11 @@ func (h *Handler) MsgDrop(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, er
}

if err = h.driver.UseDatabase(db).DropCollection(ctx, collection); err != nil {
if status.Code(err) == codes.NotFound {
var tigErr *tigris.TigrisError
if !errors.As(err, &tigErr) {
return nil, lazyerrors.Error(err)
}
if tigErr.Code == tigris.Code_NOT_FOUND {
return nil, common.NewErrorMsg(common.ErrNamespaceNotFound, "ns not found")
}
return nil, lazyerrors.Error(err)
Expand Down