handler

package
v1.23.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Overview

Package handler provides a universal handler implementation for all backends.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteErrorDocument

func WriteErrorDocument(we *mongo.WriteError) *types.Document

WriteErrorDocument returns a document representation of the write error.

Find a better place for this function. TODO https://github.com/FerretDB/FerretDB/issues/3263

Types

type Handler

type Handler struct {
	*NewOpts
	// contains filtered or unexported fields
}

Handler provides a set of methods to process clients' requests sent over wire protocol.

MsgXXX methods handle OP_MSG commands. CmdQuery handles a limited subset of OP_QUERY messages.

Handler instance is shared between all client connections.

func New

func New(opts *NewOpts) (*Handler, error)

New returns a new handler.

func (*Handler) Close

func (h *Handler) Close()

Close gracefully shutdowns handler. It should be called after listener closes all client connections and stops listening.

func (*Handler) CmdQuery

func (h *Handler) CmdQuery(connCtx context.Context, query *wire.OpQuery) (*wire.OpReply, error)

CmdQuery implements deprecated OP_QUERY message handling.

The passed context is canceled when the client connection is closed.

func (*Handler) Collect

func (h *Handler) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (*Handler) Commands

func (h *Handler) Commands() map[string]*command

Commands returns a map of enabled commands.

func (*Handler) Describe

func (h *Handler) Describe(ch chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

func (*Handler) MsgAggregate

func (h *Handler) MsgAggregate(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgAggregate implements `aggregate` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgBuildInfo

func (h *Handler) MsgBuildInfo(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgBuildInfo implements `buildInfo` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgCollMod

func (h *Handler) MsgCollMod(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgCollMod implements `collMod` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgCollStats

func (h *Handler) MsgCollStats(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgCollStats implements `collStats` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgCompact

func (h *Handler) MsgCompact(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgCompact implements `compact` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgConnectionStatus

func (h *Handler) MsgConnectionStatus(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgConnectionStatus implements `connectionStatus` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgCount

func (h *Handler) MsgCount(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgCount implements `count` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgCreate

func (h *Handler) MsgCreate(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgCreate implements `create` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgCreateIndexes

func (h *Handler) MsgCreateIndexes(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgCreateIndexes implements `createIndexes` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgCreateUser

func (h *Handler) MsgCreateUser(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgCreateUser implements `createUser` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgCurrentOp

func (h *Handler) MsgCurrentOp(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgCurrentOp implements `currentOp` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgDBStats

func (h *Handler) MsgDBStats(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgDBStats implements `dbStats` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgDataSize

func (h *Handler) MsgDataSize(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgDataSize implements `dataSize` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgDebugError

func (h *Handler) MsgDebugError(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgDebugError implements `debugError` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgDelete

func (h *Handler) MsgDelete(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgDelete implements `delete` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgDistinct

func (h *Handler) MsgDistinct(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgDistinct implements `distinct` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgDrop

func (h *Handler) MsgDrop(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgDrop implements `drop` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgDropAllUsersFromDatabase

func (h *Handler) MsgDropAllUsersFromDatabase(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgDropAllUsersFromDatabase implements `dropAllUsersFromDatabase` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgDropDatabase

func (h *Handler) MsgDropDatabase(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgDropDatabase implements `dropDatabase` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgDropIndexes

func (h *Handler) MsgDropIndexes(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgDropIndexes implements `dropIndexes` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgDropUser

func (h *Handler) MsgDropUser(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgDropUser implements `dropUser` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgExplain

func (h *Handler) MsgExplain(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgExplain implements `explain` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgFind

func (h *Handler) MsgFind(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgFind implements `find` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgFindAndModify

func (h *Handler) MsgFindAndModify(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgFindAndModify implements `findAndModify` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgGetCmdLineOpts

func (h *Handler) MsgGetCmdLineOpts(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgGetCmdLineOpts implements `getCmdLineOpts` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgGetFreeMonitoringStatus

func (h *Handler) MsgGetFreeMonitoringStatus(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgGetFreeMonitoringStatus implements `getFreeMonitoringStatus` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgGetLog

func (h *Handler) MsgGetLog(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgGetLog implements `getLog` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgGetMore

func (h *Handler) MsgGetMore(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgGetMore implements `getMore` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgGetParameter

func (h *Handler) MsgGetParameter(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgGetParameter implements `getParameter` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgHello

func (h *Handler) MsgHello(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgHello implements `hello` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgHostInfo

func (h *Handler) MsgHostInfo(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgHostInfo implements `hostInfo` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgInsert

func (h *Handler) MsgInsert(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgInsert implements `insert` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgIsMaster

func (h *Handler) MsgIsMaster(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgIsMaster implements `isMaster` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgKillCursors

func (h *Handler) MsgKillCursors(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgKillCursors implements `killCursors` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgListCollections

func (h *Handler) MsgListCollections(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgListCollections implements `listCollections` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgListCommands

func (h *Handler) MsgListCommands(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgListCommands implements `listCommands` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgListDatabases

func (h *Handler) MsgListDatabases(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgListDatabases implements `listDatabases` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgListIndexes

func (h *Handler) MsgListIndexes(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgListIndexes implements `listIndexes` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgLogout

func (h *Handler) MsgLogout(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgLogout implements `logout` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgPing

func (h *Handler) MsgPing(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgPing implements `ping` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgRenameCollection

func (h *Handler) MsgRenameCollection(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgRenameCollection implements `renameCollection` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgSASLContinue added in v1.20.0

func (h *Handler) MsgSASLContinue(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgSASLContinue implements `saslContinue` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgSASLStart

func (h *Handler) MsgSASLStart(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgSASLStart implements `saslStart` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgServerStatus

func (h *Handler) MsgServerStatus(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgServerStatus implements `serverStatus` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgSetFreeMonitoring

func (h *Handler) MsgSetFreeMonitoring(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgSetFreeMonitoring implements `setFreeMonitoring` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgUpdate

func (h *Handler) MsgUpdate(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgUpdate implements `update` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgUpdateUser

func (h *Handler) MsgUpdateUser(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgUpdateUser implements `updateUser` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgUsersInfo

func (h *Handler) MsgUsersInfo(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgUsersInfo implements `usersInfo` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgValidate

func (h *Handler) MsgValidate(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgValidate implements `validate` command.

The passed context is canceled when the client connection is closed.

func (*Handler) MsgWhatsMyURI

func (h *Handler) MsgWhatsMyURI(connCtx context.Context, msg *wire.OpMsg) (*wire.OpMsg, error)

MsgWhatsMyURI implements `whatsMyURI` command.

The passed context is canceled when the client connection is closed.

type NewOpts

type NewOpts struct {
	Backend     backends.Backend
	TCPHost     string
	ReplSetName string

	SetupDatabase string
	SetupUsername string
	SetupPassword password.Password
	SetupTimeout  time.Duration

	L             *slog.Logger
	ConnMetrics   *connmetrics.ConnMetrics
	StateProvider *state.Provider

	// test options
	DisablePushdown         bool
	EnableNestedPushdown    bool
	CappedCleanupInterval   time.Duration
	CappedCleanupPercentage uint8
	EnableNewAuth           bool
	BatchSize               int
	MaxBsonObjectSizeBytes  int
}

NewOpts represents handler configuration.

Directories

Path Synopsis
Package common contains code used to be shared by different handlers.
Package common contains code used to be shared by different handlers.
aggregations
Package aggregations provides aggregation pipelines.
Package aggregations provides aggregation pipelines.
aggregations/operators
Package operators provides aggregation operators.
Package operators provides aggregation operators.
aggregations/operators/accumulators
Package accumulators provides aggregation accumulator operators.
Package accumulators provides aggregation accumulator operators.
aggregations/stages
Package stages provides aggregation stages.
Package stages provides aggregation stages.
aggregations/stages/projection
Package projection provides projection for aggregations.
Package projection provides projection for aggregations.
Package commonpath contains functions used for path.
Package commonpath contains functions used for path.
Package handlererrors provides handlers errors.
Package handlererrors provides handlers errors.
Package handlerparams provides functions for parsing handlers parameters.
Package handlerparams provides functions for parsing handlers parameters.
Package proxy sends requests to another wire protocol compatible service.
Package proxy sends requests to another wire protocol compatible service.
Package registry provides a registry of handlers.
Package registry provides a registry of handlers.
Package sjson provides converters from/to jsonb with some extensions for built-in and `types` types.
Package sjson provides converters from/to jsonb with some extensions for built-in and `types` types.
Package users provides helper function for user operations.
Package users provides helper function for user operations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL