1
0
mirror of https://github.com/nxshock/gron.git synced 2024-11-27 03:41:00 +05:00

Add default timeout for go-ora library

This commit is contained in:
nxshock 2023-05-21 15:20:25 +05:00
parent 67d0cf83d8
commit ab02e120cc
2 changed files with 9 additions and 1 deletions

View File

@ -1,8 +1,12 @@
package main
import "time"
const (
defaultConfigFileName = "gron.conf"
defaultDbTimeout = 24 * time.Hour
defaultOnSuccessMessageFmt = "Job {{.JobName}} finished."
defaultOnErrorMessageFmt = "Job {{.JobName}} failed:\n\n{{.Error}}"
)

6
job.go
View File

@ -1,6 +1,7 @@
package main
import (
"context"
"database/sql"
"errors"
"fmt"
@ -245,7 +246,10 @@ func (j *Job) runSql(jobLogFile *os.File) error {
}
defer db.Close()
_, err = db.Exec(j.JobConfig.SqlText)
ctx, cancel := context.WithTimeout(context.Background(), defaultDbTimeout)
defer cancel()
_, err = db.ExecContext(ctx, j.JobConfig.SqlText)
if err != nil {
return err
}