handler

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: Apache-2.0 Imports: 45 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(ctx context.Context, query *wire.OpQuery) (*wire.OpReply, error)

CmdQuery implements deprecated OP_QUERY message handling.

func (*Handler) Collect

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

Collect implements prometheus.Collector interface.

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 interface.

func (*Handler) MsgAggregate

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

MsgAggregate implements `aggregate` command.

func (*Handler) MsgBuildInfo

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

MsgBuildInfo implements `buildInfo` command.

func (*Handler) MsgCollMod

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

MsgCollMod implements `collMod` command.

func (*Handler) MsgCollStats

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

MsgCollStats implements `collStats` command.

func (*Handler) MsgCompact

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

MsgCompact implements `compact` command.

func (*Handler) MsgConnectionStatus

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

MsgConnectionStatus implements `connectionStatus` command.

func (*Handler) MsgCount

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

MsgCount implements `count` command.

func (*Handler) MsgCreate

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

MsgCreate implements `create` command.

func (*Handler) MsgCreateIndexes

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

MsgCreateIndexes implements `createIndexes` command.

func (*Handler) MsgCreateUser

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

MsgCreateUser implements `createUser` command.

func (*Handler) MsgCurrentOp

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

MsgCurrentOp implements `currentOp` command.

func (*Handler) MsgDBStats

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

MsgDBStats implements `dbStats` command.

func (*Handler) MsgDataSize

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

MsgDataSize implements `dataSize` command.

func (*Handler) MsgDebugError

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

MsgDebugError implements `debugError` command.

func (*Handler) MsgDelete

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

MsgDelete implements `delete` command.

func (*Handler) MsgDistinct

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

MsgDistinct implements `distinct` command.

func (*Handler) MsgDrop

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

MsgDrop implements `drop` command.

func (*Handler) MsgDropAllUsersFromDatabase

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

MsgDropAllUsersFromDatabase implements `dropAllUsersFromDatabase` command.

func (*Handler) MsgDropDatabase

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

MsgDropDatabase implements `dropDatabase` command.

func (*Handler) MsgDropIndexes

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

MsgDropIndexes implements `dropIndexes` command.

func (*Handler) MsgDropUser

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

MsgDropUser implements `dropUser` command.

func (*Handler) MsgExplain

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

MsgExplain implements `explain` command.

func (*Handler) MsgFind

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

MsgFind implements `find` command.

func (*Handler) MsgFindAndModify

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

MsgFindAndModify implements `findAndModify` command.

func (*Handler) MsgGetCmdLineOpts

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

MsgGetCmdLineOpts implements `getCmdLineOpts` command.

func (*Handler) MsgGetFreeMonitoringStatus

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

MsgGetFreeMonitoringStatus implements `getFreeMonitoringStatus` command.

func (*Handler) MsgGetLog

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

MsgGetLog implements `getLog` command.

func (*Handler) MsgGetMore

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

MsgGetMore implements `getMore` command.

func (*Handler) MsgGetParameter

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

MsgGetParameter implements `getParameter` command.

func (*Handler) MsgHello

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

MsgHello implements `hello` command.

func (*Handler) MsgHostInfo

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

MsgHostInfo implements `hostInfo` command.

func (*Handler) MsgInsert

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

MsgInsert implements `insert` command.

func (*Handler) MsgIsMaster

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

MsgIsMaster implements `isMaster` command.

func (*Handler) MsgKillCursors

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

MsgKillCursors implements `killCursors` command.

func (*Handler) MsgListCollections

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

MsgListCollections implements `listCollections` command.

func (*Handler) MsgListCommands

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

MsgListCommands implements `listCommands` command.

func (*Handler) MsgListDatabases

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

MsgListDatabases implements `listDatabases` command.

func (*Handler) MsgListIndexes

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

MsgListIndexes implements `listIndexes` command.

func (*Handler) MsgLogout

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

MsgLogout implements `logout` command.

func (*Handler) MsgPing

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

MsgPing implements `ping` command.

func (*Handler) MsgRenameCollection

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

MsgRenameCollection implements `renameCollection` command.

func (*Handler) MsgSASLStart

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

MsgSASLStart implements `saslStart` command.

func (*Handler) MsgServerStatus

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

MsgServerStatus implements `serverStatus` command.

func (*Handler) MsgSetFreeMonitoring

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

MsgSetFreeMonitoring implements `setFreeMonitoring` command.

func (*Handler) MsgUpdate

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

MsgUpdate implements `update` command.

func (*Handler) MsgUpdateUser

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

MsgUpdateUser implements `updateUser` command.

func (*Handler) MsgUsersInfo

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

MsgUsersInfo implements `usersInfo` command.

func (*Handler) MsgValidate

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

MsgValidate implements `validate` command.

func (*Handler) MsgWhatsMyURI

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

MsgWhatsMyURI implements `whatsMyURI` command.

type NewOpts

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

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

	// test options
	DisablePushdown         bool
	CappedCleanupInterval   time.Duration
	CappedCleanupPercentage uint8
	EnableNewAuth           bool
}

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.

Jump to

Keyboard shortcuts

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