mongo

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 24 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

mongo

This plugin is responsible for forwarding the requests that come in to a downstream mongo compatible API.

Documentation

Index

Constants

View Source
const Name = "mongo"

Variables

View Source
var CommandMonitor = event.CommandMonitor{
	Started: func(ctx context.Context, e *event.CommandStartedEvent) {
	},
	Succeeded: func(ctx context.Context, e *event.CommandSucceededEvent) {
	},
	Failed: func(ctx context.Context, e *event.CommandFailedEvent) {
	},
}

Command metrics

View Source
var PoolMonitor = event.PoolMonitor{
	Event: func(e *event.PoolEvent) {
		switch e.Type {
		case "ConnectionCreated":
			connectionsCreatedTotal.WithLabelValues(e.Address).Inc()
			connectionPoolSize.WithLabelValues(e.Address).Inc()
		case "ConnectionClosedEvent":
			connectionsClosedTotal.WithLabelValues(e.Address).Inc()
			connectionPoolSize.WithLabelValues(e.Address).Dec()
		case "ConnectionCheckedOut":
			connectionPoolSize.WithLabelValues(e.Address).Dec()
			inUseConnections.WithLabelValues(e.Address).Inc()
		case "ConnectionCheckedIn":
			connectionPoolSize.WithLabelValues(e.Address).Inc()
			inUseConnections.WithLabelValues(e.Address).Dec()
		}
	},
}

Pool Metrics

Functions

func ErrorToDoc

func ErrorToDoc(err error) (bson.D, error)

Types

type MongoPlugin

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

This is a plugin that handles sending the request to the acutual downstream mongo

func (*MongoPlugin) Configure

func (p *MongoPlugin) Configure(d bson.D) error

Configure configures this plugin with the given configuration object. Returns an error if the configuration is invalid for the plugin.

func (*MongoPlugin) Name

func (p *MongoPlugin) Name() string

func (*MongoPlugin) Process

func (p *MongoPlugin) Process(ctx context.Context, r *plugins.Request, next plugins.PipelineFunc) (bson.D, error)

Process is the function executed when a message is called in the pipeline.

type MongoPluginConfig

type MongoPluginConfig struct {
	MongoAddr string `bson:"mongoAddr"`
	// Default 30s
	ConnectTimeout *string `bson:"connectTimeout"`
	// zstd,zlib,snappy
	Compressors []string `bson:"compressors"`
	// Default 10s
	HeartbeatInterval *string `bson:"heartbeatInterval"`
	// Default is 0 (indefinite)
	MaxConnIdleTime *string `bson:"maxConnIdleTime"`
	// Default is 100
	MaxPoolSize *uint64 `bson:"maxPoolSize"`
	// Default is 0
	MinPoolSize *uint64 `bson:"minPoolSize"`
	// Default 30s (waiting for available connection)
	ServerSelectionTimeout *string `bson:"serverSelectionTimeout"`
	// How long to wait for socket operations. Default is 0 (infinite)
	SocketTimeout *string `bson:"socketTimeout"`
	// EnableDNSDiscovery enables background resolution of the DNS results to set the host list of the mongo driver
	EnableDNSDiscovery bool `bson:"enableDNSDiscovery"`
}

Jump to

Keyboard shortcuts

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