proxy

package
v0.0.0-...-e1efe0e Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

Config encapsulates the required configuration options for spinning up a mongo proxy instance.

func NewConfig

func NewConfig(opts ...ConfigOption) (*Config, error)

NewConfig creates a new proxy configuration and applies the provided options.

type ConfigOption

type ConfigOption func(*Config) error

ConfigOption applies a configuration setting to a Config instance.

func WithListenAddress

func WithListenAddress(addr string) ConfigOption

WithListenAddress specifies the address where the proxy listens for incoming client connections.

func WithLogger

func WithLogger(logger *logrus.Entry) ConfigOption

WithLogger configures the proxy server to use the specified logger.

func WithRequestHandler

func WithRequestHandler(handler RequestHandler) ConfigOption

WithRequestHandler specifies the handler that will be invoked to process incoming client requests.

func WithTLS

func WithTLS(tlsConfig *tls.Config) ConfigOption

WithTLS enables TLS mode for incoming client connections using the specified TLS configuration settings.

type RequestHandler

type RequestHandler interface {
	// HandleRequest processes the incoming request and writes a response
	// using the mongo wire format back to the provided io.Writer.
	HandleRequest(clientID string, w io.Writer, r []byte) error

	// RemoveClient is invoked when the remote mongo client disconnects.
	RemoveClient(clientID string) error
}

RequestHandler is implemented by objects that process incoming requests from mongo clients.

type Server

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

Server implements a proxy server that buffers incoming mongo requests and passes them to a user-defined handler for further processing.

func NewServer

func NewServer(cfg *Config) *Server

NewServer creates a new proxy server instance using the specified config.

func (*Server) Listen

func (s *Server) Listen(ctx context.Context) error

Listen for incoming connections until ctx expires.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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