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:
parent
67d0cf83d8
commit
ab02e120cc
@ -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
6
job.go
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user