github.com/blend/go-sdk@v1.20240719.1/cron/job_lifecycle.go (about) 1 /* 2 3 Copyright (c) 2024 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package cron 9 10 import "context" 11 12 // JobLifecycle is a suite of lifeycle hooks 13 // you can set for a given job. 14 type JobLifecycle struct { 15 // OnLoad is called when the job is loaded into the job manager. 16 OnLoad func(context.Context) error 17 // OnUnload is called when the job is unloaded from the manager 18 // or the job manager is stopped. 19 OnUnload func(context.Context) error 20 21 // OnBegin fires whenever a job is started. 22 OnBegin func(context.Context) 23 // OnComplete fires whenever a job finishes, regardless of status. 24 OnComplete func(context.Context) 25 26 // OnCancellation is called if the job is canceled explicitly 27 // or it sets a timeout in the .Config() and exceeds that timeout. 28 OnCancellation func(context.Context) 29 // OnError is called if the job returns an error or panics during 30 // execution, but will not be called if the job is canceled. 31 OnError func(context.Context) 32 // OnSuccess is called if the job completes without an error. 33 OnSuccess func(context.Context) 34 35 // OnBroken is called if the job errors after having completed successfully 36 // the previous invocation. 37 OnBroken func(context.Context) 38 // OnFixed is called if the job completes successfully after having 39 // returned an error on the previous invocation. 40 OnFixed func(context.Context) 41 42 // OnEnabled is called if the job is explicitly enabled. 43 OnEnabled func(context.Context) 44 // OnDisabled is called if the job is explicitly disabled. 45 OnDisabled func(context.Context) 46 }