@@ -18,7 +18,7 @@ const (
1818 DefaultPendingJobFetchInterval = 60 * time .Second
1919 // the window of time between time.Now() and when a job's RunAfter comes due that neoq will schedule a goroutine to
2020 // schdule the job for execution.
21- // E.g. right now is 16:00 and a job's RunAfter is 16:30 of the same date. This job will get a dedicated goroutine
21+ // E.g. right now is 16:00:00 and a job's RunAfter is 16:00 :30 of the same date. This job will get a dedicated goroutine
2222 // to wait until the job's RunAfter, scheduling the job to be run exactly at RunAfter
2323 DefaultFutureJobWindow = 30 * time .Second
2424 DefaultJobCheckInterval = 1 * time .Second
@@ -32,18 +32,19 @@ var ErrBackendNotSpecified = errors.New("a backend must be specified")
3232// backends. [BackendConcurrency], for example, is only used by the redis backend. Other backends manage concurrency on a
3333// per-handler basis.
3434type Config struct {
35- BackendInitializer BackendInitializer
36- BackendAuthPassword string // password with which to authenticate to the backend
37- BackendConcurrency int // total number of backend processes available to process jobs
38- ConnectionString string // a string containing connection details for the backend
39- JobCheckInterval time.Duration // the interval of time between checking for new future/past-due jobs
40- FutureJobWindow time.Duration // time duration between current time and job.RunAfter that future jobs get scheduled
41- IdleTransactionTimeout int // number of milliseconds PgBackend transaction may idle before the connection is killed
42- ShutdownTimeout time.Duration // duration to wait for jobs to finish during shutdown
43- SynchronousCommit bool // Postgres: Enable synchronous commits (increases durability, decreases performance)
44- LogLevel logging.LogLevel // the log level of the default logger
45- PGConnectionTimeout time.Duration // the amount of time to wait for a connection to become available before timing out
46- RecoveryCallback handler.RecoveryCallback // the recovery handler applied to all Handlers excuted by the associated Neoq instance
35+ BackendInitializer BackendInitializer
36+ BackendAuthPassword string // password with which to authenticate to the backend
37+ BackendConcurrency int // total number of backend processes available to process jobs
38+ ConnectionString string // a string containing connection details for the backend
39+ JobCheckInterval time.Duration // the interval of time between checking for new future jobs
40+ PendingJobCheckInterval time.Duration // duration of time between checking for unprocessed jobs due to downtime/db disconnects
41+ FutureJobWindow time.Duration // time duration between current time and job.RunAfter that future jobs get scheduled
42+ IdleTransactionTimeout int // number of milliseconds PgBackend transaction may idle before the connection is killed
43+ ShutdownTimeout time.Duration // duration to wait for jobs to finish during shutdown
44+ SynchronousCommit bool // Postgres: Enable synchronous commits (increases durability, decreases performance)
45+ LogLevel logging.LogLevel // the log level of the default logger
46+ PGConnectionTimeout time.Duration // the amount of time to wait for a connection to become available before timing out
47+ RecoveryCallback handler.RecoveryCallback // the recovery handler applied to all Handlers excuted by the associated Neoq instance
4748}
4849
4950// ConfigOption is a function that sets optional backend configuration
@@ -139,6 +140,17 @@ func WithJobCheckInterval(interval time.Duration) ConfigOption {
139140 }
140141}
141142
143+ // WithPendingJobCheckInterval configures the duration of time between checking for unprocessed jobs on watched queues.
144+ //
145+ // Pending jobs are jobs that were queued while neoq wasn't listening or while a disconnect occurred. Most jobs are
146+ // processed via Postgres' LISTEN/NOTIFY facilities. This check interval is a last resort and does not need to be short.
147+ // Be careful not to hammer your database by setting this too low.
148+ func WithPendingJobCheckInterval (interval time.Duration ) ConfigOption {
149+ return func (c * Config ) {
150+ c .PendingJobCheckInterval = interval
151+ }
152+ }
153+
142154// WithLogLevel configures the log level for neoq's default logger. By default, log level is "INFO".
143155// if SetLogger is used, WithLogLevel has no effect on the set logger
144156func WithLogLevel (level logging.LogLevel ) ConfigOption {
0 commit comments