Documentation
¶
Index ¶
- func HasPrefix(prefix string) func(string) bool
- type ImportOption
- func BatchSize(size int) ImportOption
- func Drop(drop bool) ImportOption
- func EnsureIndexes(ensure bool) ImportOption
- func Exclude(exprs ...*regexp.Regexp) ImportOption
- func FilterDatabases(filter ...func(string) bool) ImportOption
- func Parallel(p int) ImportOption
- func PingTimeout(d time.Duration) ImportOption
- func SkipConfirm(skip bool) ImportOption
- func Verbose(v bool) ImportOption
- type Importer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ImportOption ¶
type ImportOption func(*importConfig)
ImportOption is a configuration function that modifies the importConfig struct, allowing users to customize the behavior of the Importer when importing data from one MongoDB instance to another. It provides options for filtering databases, ensuring indexes, dropping existing data, skipping confirmation prompts, and adjusting parallelism and batch sizes for performance tuning.
func BatchSize ¶ added in v0.2.2
func BatchSize(size int) ImportOption
BatchSize sets the size of the batches used when importing data from the source to the target database.
func Drop ¶
func Drop(drop bool) ImportOption
Drop sets the drop option for the importConfig. If true, the target database will be dropped before importing data.
func EnsureIndexes ¶ added in v0.3.2
func EnsureIndexes(ensure bool) ImportOption
EnsureIndexes sets the ensureIndexes field in the importConfig struct to the provided boolean value. If set to true, the function ensures that indexes are created on the target database during the import process.
func Exclude ¶ added in v0.3.1
func Exclude(exprs ...*regexp.Regexp) ImportOption
func FilterDatabases ¶
func FilterDatabases(filter ...func(string) bool) ImportOption
FilterDatabases returns an ImportOption that appends one or more filter functions to the importConfig's dbFilter list. These filter functions are used to determine which databases should be imported.
func Parallel ¶ added in v0.2.0
func Parallel(p int) ImportOption
Parallel sets the number of parallel import operations to be performed by the Importer. It takes an integer value as an input and returns an ImportOption function.
func PingTimeout ¶
func PingTimeout(d time.Duration) ImportOption
PingTimeout sets the duration for the ping timeout when establishing a connection to the source and target MongoDB instances.
func SkipConfirm ¶
func SkipConfirm(skip bool) ImportOption
SkipConfirm sets whether to skip the confirmation prompt during the import process. If set to true, it will bypass the confirmation and proceed with the import without user interaction.
func Verbose ¶
func Verbose(v bool) ImportOption
Verbose sets the verbosity of the import process. If set to true, additional log messages will be printed during the import process.
type Importer ¶
type Importer struct {
// contains filtered or unexported fields
}
Importer is a type that performs data import operations between two MongoDB instances, handling database filtering, index management, and parallel processing for efficient data transfers. It provides options to customize the import process, such as specifying filters for databases, ensuring indexes are created on the target instance, and configuring batch sizes and parallel processing.
func New ¶
New creates a new Importer instance with the specified source and target MongoDB clients. The source and target clients must not be nil; otherwise, it panics.
func (*Importer) Import ¶
func (i *Importer) Import(ctx context.Context, opts ...ImportOption) error
Import imports the specified databases from the source MongoDB client to the target MongoDB client using the provided import options. It handles database filtering, dropping existing databases, ensuring indexes, and parallelizing import operations.