shell

package
v0.0.0-...-cb6e037 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	BuildinfoCommand = "buildinfo"
)

Constants representing required shell commands.

Variables

This section is empty.

Functions

func MakeShellService

func MakeShellService(service mrpc.Service) (mrpc.Service, error)

MakeShellService takes an existing mrpc.Service and adds support for mongo shell clients.

func MessageToRequest

func MessageToRequest(msg mongowire.Message, out interface{}) error

MessageToRequest converts a mongowire.Message into a request

func MessageToResponse

func MessageToResponse(msg mongowire.Message, out interface{}) error

MessageToResponse converts a mongowire.Message into a response.

func NewShellService

func NewShellService(host string, port int) (mrpc.Service, error)

NewShellService returns a service for mongo shell clients listening on the given host and port.

func RequestToMessage

func RequestToMessage(t mongowire.OpType, req interface{}) (mongowire.Message, error)

RequestToMessage converts a request into a wire protocol query.

func ResponseToMessage

func ResponseToMessage(t mongowire.OpType, resp interface{}) (mongowire.Message, error)

ResponseToMessage converts a response into a wire protocol reply.

func WriteErrorResponse

func WriteErrorResponse(ctx context.Context, w io.Writer, t mongowire.OpType, err error, op string)

WriteErrorResponse writes a response indicating an error occurred to the writer output.

func WriteNotOKResponse

func WriteNotOKResponse(ctx context.Context, w io.Writer, t mongowire.OpType, op string)

WriteOKResponse writes a response indicating that the request was not ok.

func WriteOKResponse

func WriteOKResponse(ctx context.Context, w io.Writer, t mongowire.OpType, op string)

WriteOKResponse writes a response indicating that the request was ok.

func WriteResponse

func WriteResponse(ctx context.Context, w io.Writer, resp mongowire.Message, op string)

WriteResponse sends a response the the writer output.

Types

type ErrorResponse

type ErrorResponse struct {
	OK           int    `bson:"ok"`
	ErrorMessage string `bson:"errmsg,omitempty"`
}

ErrorResponse represents a response indicating whether the operation was okay and errors, if any.

func MakeErrorResponse

func MakeErrorResponse(ok bool, err error) ErrorResponse

MakeErrorResponse returns an ErrorResponse with the given ok status and error message, if any.

func MakeSuccessResponse

func MakeSuccessResponse() ErrorResponse

MakeSuccessResponse returns an ErrorResponse that is ok and has no error.

func (ErrorResponse) SuccessOrError

func (r ErrorResponse) SuccessOrError() error

Jump to

Keyboard shortcuts

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