MCPcopy
hub / github.com/riverqueue/river / WorkFunc

Function WorkFunc

worker.go:221–223  ·  view source on GitHub ↗

WorkFunc wraps a function to implement the Worker interface. A job args struct implementing JobArgs will still be required to specify a Kind. For example: river.AddWorker(workers, river.WorkFunc(func(ctx context.Context, job *river.Job[WorkFuncArgs]) error { fmt.Printf("Message: %s", job.Args.M

(f func(context.Context, *Job[T]) error)

Source from the content-addressed store, hash-verified

219// return nil
220// }))
221func WorkFunc[T JobArgs](f func(context.Context, *Job[T]) error) Worker[T] {
222 return &workFunc[T]{f: f, kind: (*new(T)).Kind()}
223}

Callers 15

Example_workFuncFunction · 0.92
TestMiddlewareFunction · 0.92
ExerciseClientFunction · 0.92
TestWorker_NewWorkerFunction · 0.92
TestWorker_WorkFunction · 0.92
TestWorker_WorkJobFunction · 0.92
TestWorkFunction · 0.85
TestWorkFuncFunction · 0.85
Test_RecordedOutputFunction · 0.85
makeAwaitWorkerFunction · 0.85
Test_Client_CommonFunction · 0.85

Calls 1

KindMethod · 0.65

Tested by 15

Example_workFuncFunction · 0.74
TestMiddlewareFunction · 0.74
ExerciseClientFunction · 0.74
TestWorker_NewWorkerFunction · 0.74
TestWorker_WorkFunction · 0.74
TestWorker_WorkJobFunction · 0.74
TestWorkFunction · 0.68
TestWorkFuncFunction · 0.68
Test_RecordedOutputFunction · 0.68
makeAwaitWorkerFunction · 0.68
Test_Client_CommonFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…