mongo

package
v0.0.0-...-c9c06cf Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReadPreferencePrimary            = "primary"
	ReadPreferencePrimaryPreferred   = "primaryPreferred"
	ReadPreferenceSecondary          = "secondary"
	ReadPreferenceSecondaryPreferred = "secondaryPreferred"
	ReadPreferenceNearest            = "nearest"
)
View Source
const (
	MinSupportedVersion    = "4.4.0"
	MinOplogRetentionHours = 24

	ReplicaSet     = "ReplicaSet"
	ShardedCluster = "ShardedCluster"

	AtlasDomain      = ".mongodb.net"
	DocumentDBDomain = "docdb.amazonaws.com"
)

Variables

View Source
var RequiredRoles = [...]string{"readAnyDatabase", "clusterMonitor"}

Functions

func BuildClientOptions

func BuildClientOptions(config ClientConfig) (*options.ClientOptions, error)

func CompareServerVersions

func CompareServerVersions(a, b string) (int, error)

func GetCollectionNames

func GetCollectionNames(ctx context.Context, client *mongo.Client, databaseName string) ([]string, error)

Filter out views and system collections after listing all collections. Some MongoDB Atlas tiers (e.g., free tier) don't support regex filters in ListCollections.

func GetDatabaseNames

func GetDatabaseNames(ctx context.Context, client *mongo.Client) ([]string, error)

Filter out system databases after listing all databases. Some MongoDB Atlas tiers (e.g., free tier) don't support regex filters in ListDatabases.

func GetTopologyType

func GetTopologyType(ctx context.Context, client *mongo.Client) (string, error)

func ValidateCollections

func ValidateCollections(ctx context.Context, client *mongo.Client, tables []*common.QualifiedTable) error

func ValidateOplogRetention

func ValidateOplogRetention(ctx context.Context, client *mongo.Client) error

func ValidateServerCompatibility

func ValidateServerCompatibility(ctx context.Context, client *mongo.Client) error

func ValidateUserRoles

func ValidateUserRoles(ctx context.Context, client *mongo.Client) error

Types

type AuthInfo

type AuthInfo struct {
	AuthenticatedUserRoles []Role `bson:"authenticatedUserRoles"`
}

type BuildInfo

type BuildInfo struct {
	Version string `bson:"version"`
}

func GetBuildInfo

func GetBuildInfo(ctx context.Context, client *mongo.Client) (BuildInfo, error)

type ClientConfig

type ClientConfig struct {
	Uri                  string
	Username             string
	Password             string
	ReadPreference       string
	DisableTls           bool
	SkipCertVerification bool
	RootCa               string
	TlsHost              string
	CreateTlsConfigFunc  func(minVersion uint16, rootCAs string, host string, tlsHost string, skipCertVerification bool) (*tls.Config, error)
	Dialer               options.ContextDialer
}

type CollStats

type CollStats struct {
	// uncompressed
	Size int64 `bson:"size"`
	// compressed
	StorageSize int64 `bson:"storageSize"`
}

func GetCollStats

func GetCollStats(ctx context.Context, client *mongo.Client, database string, collection string) (CollStats, error)

type ConnectionStatus

type ConnectionStatus struct {
	AuthInfo AuthInfo `bson:"authInfo"`
}

func GetConnectionStatus

func GetConnectionStatus(ctx context.Context, client *mongo.Client) (ConnectionStatus, error)

type HelloResponse

type HelloResponse struct {
	Msg   string   `bson:"msg,omitempty"`
	Hosts []string `bson:"hosts,omitempty"`
}

func GetHelloResponse

func GetHelloResponse(ctx context.Context, client *mongo.Client) (HelloResponse, error)

type OpTime

type OpTime struct {
	Ts bson.Timestamp `bson:"ts"`
	T  int64          `bson:"t"`
}

type OpTimes

type OpTimes struct {
	LastCommittedOpTime OpTime `bson:"lastCommittedOpTime"`
}

type OplogTruncation

type OplogTruncation struct {
	OplogMinRetentionHours float64 `bson:"oplogMinRetentionHours"`
}

type ReplSetStatus

type ReplSetStatus struct {
	OpTimes OpTimes `bson:"optimes"`
}

func GetReplSetStatus

func GetReplSetStatus(ctx context.Context, client *mongo.Client) (ReplSetStatus, error)

type Role

type Role struct {
	Role string `bson:"role"`
	DB   string `bson:"db"`
}

type ServerStatus

type ServerStatus struct {
	StorageEngine   StorageEngine   `bson:"storageEngine"`
	OplogTruncation OplogTruncation `bson:"oplogTruncation"`
	Host            string          `bson:"host"`
}

func GetServerStatus

func GetServerStatus(ctx context.Context, client *mongo.Client) (ServerStatus, error)

type StorageEngine

type StorageEngine struct {
	Name string `bson:"name"`
}

Jump to

Keyboard shortcuts

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