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
|
package main
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
defaultConfigFileName = "gron.conf"
|
defaultConfigFileName = "gron.conf"
|
||||||
|
|
||||||
|
defaultDbTimeout = 24 * time.Hour
|
||||||
|
|
||||||
defaultOnSuccessMessageFmt = "Job {{.JobName}} finished."
|
defaultOnSuccessMessageFmt = "Job {{.JobName}} finished."
|
||||||
defaultOnErrorMessageFmt = "Job {{.JobName}} failed:\n\n{{.Error}}"
|
defaultOnErrorMessageFmt = "Job {{.JobName}} failed:\n\n{{.Error}}"
|
||||||
)
|
)
|
||||||
|
6
job.go
6
job.go
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -245,7 +246,10 @@ func (j *Job) runSql(jobLogFile *os.File) error {
|
|||||||
}
|
}
|
||||||
defer db.Close()
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user