mirror of https://github.com/go-co-op/gocron.git
clarify context docs
This commit is contained in:
parent
8df2bbf7cd
commit
96fe017828
|
|
@ -362,8 +362,8 @@ func ExampleNewTask() {
|
||||||
gocron.DurationJob(time.Second),
|
gocron.DurationJob(time.Second),
|
||||||
gocron.NewTask(
|
gocron.NewTask(
|
||||||
func(ctx context.Context) {
|
func(ctx context.Context) {
|
||||||
// gocron will pass in a context (either the default Job context, or one provided via WithContext)
|
// gocron will pass in a context (either the default Job context, or one
|
||||||
// to the job and will cancel the context on shutdown.
|
// provided via WithContext) to the job and will cancel the context on shutdown.
|
||||||
// This allows you to listen for and handle cancellation within your job.
|
// This allows you to listen for and handle cancellation within your job.
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
@ -627,8 +627,8 @@ func ExampleWithContext() {
|
||||||
),
|
),
|
||||||
gocron.NewTask(
|
gocron.NewTask(
|
||||||
func(ctx context.Context) {
|
func(ctx context.Context) {
|
||||||
// gocron will pass in a context (either the default Job context, or one provided via WithContext)
|
// gocron will pass in a context (either the default Job context, or one
|
||||||
// to the job and will cancel the context on shutdown.
|
// provided via WithContext) to the job and will cancel the context on shutdown.
|
||||||
// This allows you to listen for and handle cancellation within your job.
|
// This allows you to listen for and handle cancellation within your job.
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
||||||
8
job.go
8
job.go
|
|
@ -84,8 +84,8 @@ type Task func() task
|
||||||
|
|
||||||
// NewTask provides the job's task function and parameters.
|
// NewTask provides the job's task function and parameters.
|
||||||
// If you set the first argument of your Task func to be a context.Context,
|
// If you set the first argument of your Task func to be a context.Context,
|
||||||
// gocron will pass in a context (either the default Job context, or one provided via WithContext)
|
// gocron will pass in a context (either the default Job context, or one
|
||||||
// to the job and will cancel the context on shutdown.
|
// provided via WithContext) to the job and will cancel the context on shutdown.
|
||||||
// This allows you to listen for and handle cancellation within your job.
|
// This allows you to listen for and handle cancellation within your job.
|
||||||
func NewTask(function any, parameters ...any) Task {
|
func NewTask(function any, parameters ...any) Task {
|
||||||
return func() task {
|
return func() task {
|
||||||
|
|
@ -710,8 +710,8 @@ func WithIdentifier(id uuid.UUID) JobOption {
|
||||||
|
|
||||||
// WithContext sets the parent context for the job
|
// WithContext sets the parent context for the job
|
||||||
// If you set the first argument of your Task func to be a context.Context,
|
// If you set the first argument of your Task func to be a context.Context,
|
||||||
// gocron will pass in a context (either the default Job context, or one provided via WithContext)
|
// gocron will pass in a context (either the default Job context, or one
|
||||||
// to the job and will cancel the context on shutdown.
|
// provided via WithContext) to the job and will cancel the context on shutdown.
|
||||||
// This allows you to listen for and handle cancellation within your job.
|
// This allows you to listen for and handle cancellation within your job.
|
||||||
func WithContext(ctx context.Context) JobOption {
|
func WithContext(ctx context.Context) JobOption {
|
||||||
return func(j *internalJob, _ time.Time) error {
|
return func(j *internalJob, _ time.Time) error {
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ type Scheduler interface {
|
||||||
// definition when the Scheduler is started. If the Scheduler is already running
|
// definition when the Scheduler is started. If the Scheduler is already running
|
||||||
// the job will be scheduled when the Scheduler is started.
|
// the job will be scheduled when the Scheduler is started.
|
||||||
// If you set the first argument of your Task func to be a context.Context,
|
// If you set the first argument of your Task func to be a context.Context,
|
||||||
// gocron will pass in a context (either the default Job context, or one provided via WithContext)
|
// gocron will pass in a context (either the default Job context, or one
|
||||||
// to the job and will cancel the context on shutdown.
|
// provided via WithContext) to the job and will cancel the context on shutdown.
|
||||||
// This allows you to listen for and handle cancellation within your job.
|
// This allows you to listen for and handle cancellation within your job.
|
||||||
NewJob(JobDefinition, Task, ...JobOption) (Job, error)
|
NewJob(JobDefinition, Task, ...JobOption) (Job, error)
|
||||||
// RemoveByTags removes all jobs that have at least one of the provided tags.
|
// RemoveByTags removes all jobs that have at least one of the provided tags.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue