Skip to content

Commit

Permalink
Merge branch 'main' into linking-prs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekSi committed Oct 19, 2022
2 parents 9e7375c + 656055c commit 82a440a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
10 changes: 7 additions & 3 deletions CONTRIBUTING.md
Expand Up @@ -102,13 +102,17 @@ The `internal` subpackages contain most of the FerretDB code:
* `clientconn` package provides client connection implementation.
It accepts client connections, reads `wire`/`bson` protocol messages, and passes them to `handlers`.
Responses are then converted to `wire`/`bson` messages and sent back to the client.
* `handlers` handle protocol commands.
They use `fjson` package for storing data in PostgreSQL in jsonb columns, but they don't use `bson` package –
all data is represented as built-in and `types` types.
* `handlers` contains a common interface for backend handlers that they should implement.
Handlers use `types` and `wire` packages, but `bson` package details are hidden.
* `handlers/common` contains code shared by different handlers.
* `handlers/dummy` contains a stub implementation of that interface that could be copied into a new package
as a starting point for the new handlers.
* `handlers/pg` contains the implementation of the PostgreSQL handler.
* `handlers/pg/pjson` provides converters from/to PJSON for built-in and `types` types.
PJSON adds some extensions to JSON for keeping object keys in order,
preserving BSON type information in the values themselves, etc.
It is used by `pg` handler.
* `handlers/tigris` contains the implementation of the Tigris handler.
* `tjson` provides converters from/to JSON with JSON Schema for built-in and `types` types.
BSON type information is preserved either in the schema (where possible) or in the values themselves.
It is used by `tigris` handler.
Expand Down
5 changes: 4 additions & 1 deletion internal/handlers/dummy/dummy.go
Expand Up @@ -33,8 +33,11 @@ func notImplemented(command string) error {
// - connectionStatus;
// - debugError;
// - getCmdLineOpts;
// - getFreeMonitoringStatus;
// - hostInfo;
// - listCommands.
// - listCommands;
// - setFreeMonitoringStatus;
// - whatsmyuri.
type Handler struct{}

// New returns a new handler.
Expand Down
4 changes: 2 additions & 2 deletions internal/handlers/tigris/msg_collmod.go
Expand Up @@ -17,11 +17,11 @@ package tigris
import (
"context"

"github.com/FerretDB/FerretDB/internal/util/must"
"github.com/FerretDB/FerretDB/internal/handlers/common"
"github.com/FerretDB/FerretDB/internal/wire"
)

// MsgCollMod implements HandlerInterface.
func (h *Handler) MsgCollMod(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error) {
return nil, notImplemented(must.NotFail(msg.Document()).Command())
return nil, common.NewErrorMsg(common.ErrNotImplemented, "`collMod` command is not implemented yet")
}
4 changes: 2 additions & 2 deletions internal/handlers/tigris/msg_explain.go
Expand Up @@ -17,11 +17,11 @@ package tigris
import (
"context"

"github.com/FerretDB/FerretDB/internal/util/must"
"github.com/FerretDB/FerretDB/internal/handlers/common"
"github.com/FerretDB/FerretDB/internal/wire"
)

// MsgExplain implements HandlerInterface.
func (h *Handler) MsgExplain(ctx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error) {
return nil, notImplemented(must.NotFail(msg.Document()).Command())
return nil, common.NewErrorMsg(common.ErrNotImplemented, "`explain` command is not implemented yet")
}
5 changes: 0 additions & 5 deletions internal/handlers/tigris/tigris.go
Expand Up @@ -30,11 +30,6 @@ import (
"github.com/FerretDB/FerretDB/internal/util/lazyerrors"
)

// notImplemented returns error for stub command handlers.
func notImplemented(command string) error {
return common.NewErrorMsg(common.ErrNotImplemented, "I'm a stub, not a real handler for "+command)
}

// NewOpts represents handler configuration.
type NewOpts struct {
ClientID string
Expand Down

0 comments on commit 82a440a

Please sign in to comment.