Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunCronJob ¶
func RunCronJob(ctx context.Context, cfg ElectionConfig, job CronJob) error
RunCronJob runs a CronJob and blocks. If cfg.LeaseEnabled is true then only one pod (if application is scaled) will run the cron job. This is done using leader election from k8s with leases. Returns error in case of bad configuration or bad connection to k8s cluster
Types ¶
type ElectionConfig ¶
type ElectionConfig struct { LeaseLockName string `envconfig:"APP_ELECTION_LEASE_LOCK_NAME"` LeaseLockNamespace string `envconfig:"APP_ELECTION_LEASE_LOCK_NAMESPACE"` LeaseDuration time.Duration `envconfig:"optional,default=60s,APP_ELECTION_LEASE_DURATION"` RenewDeadline time.Duration `envconfig:"optional,default=15s,APP_ELECTION_RENEW_DEADLINE"` RetryPeriod time.Duration `envconfig:"optional,default=5s,APP_ELECTION_RETRY_PERIOD"` ElectionEnabled bool `envconfig:"optional,default=true,APP_ELECTION_ENABLED"` ClientConfig kubernetes.Config }
ElectionConfig configuration for k8s leader election with lease
Click to show internal directories.
Click to hide internal directories.