package migration import "sync" const ( defaultMailImportBatchSize = 25 defaultDriveImportBatchSize = 10 ) // ImportBatchConfig controls how many items each migration importer processes per worker tick. type ImportBatchConfig struct { Mail int Drive int } var ( importBatchMu sync.RWMutex importBatchConfig = ImportBatchConfig{ Mail: defaultMailImportBatchSize, Drive: defaultDriveImportBatchSize, } ) // ConfigureImportBatch sets package-wide batch sizes for migration importers. func ConfigureImportBatch(cfg ImportBatchConfig) { importBatchMu.Lock() defer importBatchMu.Unlock() if cfg.Mail > 0 { importBatchConfig.Mail = cfg.Mail } if cfg.Drive > 0 { importBatchConfig.Drive = cfg.Drive } } func mailImportBatchSize() int { importBatchMu.RLock() defer importBatchMu.RUnlock() return importBatchConfig.Mail } func driveImportBatchSize() int { importBatchMu.RLock() defer importBatchMu.RUnlock() return importBatchConfig.Drive }