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

Function AddWorker

worker.go:108–112  ·  view source on GitHub ↗

AddWorker registers a Worker on the provided Workers bundle. Each Worker must be registered so that the Client knows it should handle a specific kind of job (as returned by its `Kind()` method). Use by explicitly specifying a JobArgs type and then passing an instance of a worker for the same type:

(workers *Workers, worker Worker[T])

Source from the content-addressed store, hash-verified

106// an application with invalid hardcoded runtime configuration. If you want to
107// avoid panics, use AddWorkerSafely instead.
108func AddWorker[T JobArgs](workers *Workers, worker Worker[T]) {
109 if err := AddWorkerSafely(workers, worker); err != nil {
110 panic(err)
111 }
112}
113
114// AddWorkerArgs is the same as AddWorker except that it lets args be passed
115// explicitly rather than being instantiated implicitly. We don't know of any

Callers 15

Example_uniqueJobFunction · 0.92
Example_jobArgsHooksFunction · 0.92
Example_jobSnoozeFunction · 0.92
Example_subscriptionFunction · 0.92
Example_insertAndWorkFunction · 0.92
Example_periodicJobFunction · 0.92
Example_cronJobFunction · 0.92
Example_batchInsertFunction · 0.92
Example_resumableCursorFunction · 0.92

Calls 1

AddWorkerSafelyFunction · 0.85

Tested by 15

Example_uniqueJobFunction · 0.74
Example_jobArgsHooksFunction · 0.74
Example_jobSnoozeFunction · 0.74
Example_subscriptionFunction · 0.74
Example_insertAndWorkFunction · 0.74
Example_periodicJobFunction · 0.74
Example_cronJobFunction · 0.74
Example_batchInsertFunction · 0.74
Example_resumableCursorFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…