handlers

package
v0.0.0-...-b57e8ac Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SupportedCommands

func SupportedCommands(context.Context, *wire.OpMsg) (*wire.OpMsg, error)

SupportedCommands returns a list of currently supported commands.

Types

type Handler

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

func New

func New(opts *NewOpts) *Handler

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, reqHeader *wire.MsgHeader, reqBody wire.MsgBody) (resHeader *wire.MsgHeader, resBody wire.MsgBody, closeConn bool)

Handle handles the message.

Message handlers should:

  • return normal response body;
  • return protocol error (*common.Error) - it will be returned to the client;
  • return any other error - it will be returned to the client as InternalError before terminating connection;
  • panic - that will terminate the connection without a response.

func (*Handler) MsgAuthenticate

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

MsgAuthenticate is so far only used for the authentication needed by MongoDB drivers when using tls. Since username and password is so far not implemented, MsgAuthenticate sends ok: 1 no matter what.

func (*Handler) MsgBuildInfo

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

MsgBuildInfo returns an OpMsg with the build information.

func (*Handler) MsgConnectionStatus

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

MsgConnectionStatus is a common implementation of the connectionStatus command. Is a workaround to make it possible to connect and use GUI's like Studio 3T.

func (*Handler) MsgCreate

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

MsgCreate adds a collection and if the database is not created yet, it also creates a schema.

func (*Handler) MsgDBStats

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

Is a workaround to make it possible to connect and use GUI's like Studio 3T.

func (*Handler) MsgDrop

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

MsgDrop removes a collection.

func (*Handler) MsgDropDatabase

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

MsgDropDatabase removes the current database.

func (*Handler) MsgGetLastError

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

MsgGetLastError is an implementation of the command getlasterror. Is a workaround to make it possible to connect and use GUI's like Studio 3T.

func (*Handler) MsgGetLog

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

MsgGetLog is an administrative command that returns the most recent 1024 logged events.

func (*Handler) MsgHello

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

MsgHello returns a document that describes the role of the instance.

func (*Handler) MsgHostInfo

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

MsgHostInfo returns an OpMsg with the host information.

func (*Handler) MsgListCollections

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

MsgListCollections retrieves information (i.e. the name and options) about the collections and views in a database.

func (*Handler) MsgListDatabases

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

MsgListDatabases command provides a list of all existing databases along with basic statistics about them.

func (*Handler) MsgPing

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

MsgPing OpMsg containing a ping, used to test whether a server is responding to commands.

func (*Handler) MsgRolesInfo

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

MsgRolesinfo returns information about the given roles. Is a workaround to make it possible to connect and use GUI's like Studio 3T.

func (*Handler) MsgUsersInfo

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

MsgUsersInfo returns information about users. Is a workaround to make it possible to connect and use GUI's like Studio 3T.

func (*Handler) MsgWhatsMyURI

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

MsgWhatsMyURI is an internal command, returns the peerAddress of the handler.

func (*Handler) QueryCmd

func (h *Handler) QueryCmd(ctx context.Context, query *wire.OpQuery) (*wire.OpReply, error)

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}

Metrics represents handler metrics.

func NewMetrics

func NewMetrics() *Metrics

NewMetrics creates new handler metrics.

func (*Metrics) Collect

func (lm *Metrics) Collect(ch chan<- prometheus.Metric)

Collect implements prometheus.Collector.

func (*Metrics) Describe

func (lm *Metrics) Describe(ch chan<- *prometheus.Desc)

Describe implements prometheus.Collector.

type NewOpts

type NewOpts struct {
	HanaPool    *hana.Hpool
	Logger      *zap.Logger
	CrudStorage common.Storage
	Metrics     *Metrics
	PeerAddr    string
}

Directories

Path Synopsis
Package proxy sends requests to another wire protocol compatible service.
Package proxy sends requests to another wire protocol compatible service.

Jump to

Keyboard shortcuts

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