forked from mtusi2026/mtusi2026lab2
This commit is contained in:
@@ -54,7 +54,7 @@ func main() {
|
||||
}
|
||||
|
||||
func run() error {
|
||||
urlFile := flag.String("database-url-file", "secrets/database_url", "file containing the PostgreSQL URL")
|
||||
databaseURL := flag.String("database-url", os.Getenv("DATABASE_URL"), "PostgreSQL URL")
|
||||
output := flag.String("output", "evidence/lab2-track2.json", "result JSON path")
|
||||
messages := flag.Int("messages", 100000, "number of messages")
|
||||
writeRows := flag.Int("write-rows", 10000, "rows per write test")
|
||||
@@ -66,11 +66,10 @@ func run() error {
|
||||
return fmt.Errorf("write-rows must be at least 1000")
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(*urlFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("read database URL: %w", err)
|
||||
if strings.TrimSpace(*databaseURL) == "" {
|
||||
return fmt.Errorf("database URL is required")
|
||||
}
|
||||
pool, err := pgxpool.New(context.Background(), strings.TrimSpace(string(data)))
|
||||
pool, err := pgxpool.New(context.Background(), strings.TrimSpace(*databaseURL))
|
||||
if err != nil {
|
||||
return fmt.Errorf("open database: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user