shell

package
v0.0.0-...-3c23f65 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

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 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 RequestMessageToDocument

func RequestMessageToDocument(msg mongowire.Message) (*birch.Document, error)

RequestMessageToDocument converts a wire protocol request message into a document.

func RequestToMessage

func RequestToMessage(t mongowire.OpType, doc *birch.Document) (mongowire.Message, error)

RequestToMessage converts a request into a wire protocol query.

func ResponseMessageToDocument

func ResponseMessageToDocument(msg mongowire.Message) (*birch.Document, error)

ResponseMessageToDocument converts a wire protocol response message into a document.

func ResponseToMessage

func ResponseToMessage(t mongowire.OpType, doc *birch.Document) (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) MarshalDocument

func (r ErrorResponse) MarshalDocument() (*birch.Document, error)

func (ErrorResponse) SuccessOrError

func (r ErrorResponse) SuccessOrError() error

func (*ErrorResponse) UnmarshalDocument

func (r *ErrorResponse) UnmarshalDocument(in *birch.Document) error

Jump to

Keyboard shortcuts

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