package main import "time" // shouldInitEmail returns true if email config has host and user set. func shouldInitEmail(host, user string) bool { return host != "" && user != "" } // shouldInitStorage returns true if upload directory is configured. func shouldInitStorage(uploadDir string) bool { return uploadDir != "" } // shouldInitEncryption returns true if encryption key is set. func shouldInitEncryption(encryptionKey string) bool { return encryptionKey != "" } // connectWithRetry attempts a connection with exponential backoff. // Returns nil on success or the last error after all retries fail. func connectWithRetry(connect func() error, maxRetries int) error { var err error for i := 0; i < maxRetries; i++ { err = connect() if err == nil { return nil } time.Sleep(time.Duration(i+1) * time.Millisecond) // use ms in tests } return err }