feat(jobs): add durable due-time job runner with leases
This commit is contained in:
1 parent
7e80c8ad2a
commit
008254e44a
39 files changed
+4909
-43
No files matched your search
@@ -77,6 +77,18 @@ type Config struct {
|
||||
// ConsumerRebalanceTimeout is the Kafka rebalance timeout of every
|
||||
// consumer group member.
|
||||
ConsumerRebalanceTimeout time.Duration
|
||||
// JobsEnabled runs the scheduled job worker next to the HTTP servers
|
||||
// when a job handler is registered.
|
||||
JobsEnabled bool
|
||||
JobsPollInterval time.Duration
|
||||
JobsBatchSize int
|
||||
JobsLeaseDuration time.Duration
|
||||
// JobsMaxAttempts applies to jobs scheduled without their own limit.
|
||||
JobsMaxAttempts int
|
||||
JobsBackoffInitial time.Duration
|
||||
JobsBackoffMax time.Duration
|
||||
// JobsShutdownGrace bounds the job in progress after shutdown begins.
|
||||
JobsShutdownGrace time.Duration
|
||||
// EmailProvider selects the only active mail transport. Settings of the
|
||||
// other transports are not loaded.
|
||||
EmailProvider EmailProvider
|
||||
@@ -146,6 +158,9 @@ func LoadFromEnv(lookup LookupEnv) (Config, error) {
|
||||
if err := config.loadConsumer(lookup); err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
if err := config.loadJobs(lookup); err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
if err := config.loadMail(lookup); err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
@@ -211,11 +226,14 @@ func (config Config) Validate() error {
|
||||
if config.ShutdownTimeout <= 0 {
|
||||
return errors.New("Config.Validate - SHUTDOWN_TIMEOUT must be positive")
|
||||
}
|
||||
// The consumer shutdown grace is checked against SHUTDOWN_TIMEOUT, so it
|
||||
// follows that check.
|
||||
// The consumer and job shutdown graces are checked against
|
||||
// SHUTDOWN_TIMEOUT, so they follow that check.
|
||||
if err := config.ValidateConsumer(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := config.ValidateJobs(); err != nil {
|
||||
return err
|
||||
}
|
||||
switch config.LogLevel {
|
||||
case "debug", "info", "warn", "error":
|
||||
default:
|
||||
|
||||
Reference in new issue
Block a user