Skip to content
This repository has been archived by the owner on Feb 20, 2024. It is now read-only.

Passing Fields To Workers

Robert Catmull edited this page Dec 15, 2020 · 6 revisions

Adding Values

Fields can be passed via the worker's object.

worker ONLY use the Send() method to get data into your worker. It is not shared memory unlike the worker objects values.

type MyWorker struct {
	message string
}

func NewMyWorker(message string) *MyWorker {
	return &MyWorker{message}
}

func (my *MyWorker) Work(w *goworker.Worker, in interface{}) error {
	fmt.Println(my.message)
}

worker := worker.NewWorker(ctx, NewMyWorker(), 100).Work()
Clone this wiki locally