MCPcopy Index your code
hub / github.com/riverqueue/river / AddWorkerSafely

Function AddWorkerSafely

worker.go:133–136  ·  view source on GitHub ↗

AddWorkerSafely registers a worker on the provided Workers bundle. Unlike AddWorker, AddWorkerSafely does not panic and instead returns an error if the worker is already registered or if its configuration is invalid. Use by explicitly specifying a JobArgs type and then passing an instance of a work

(workers *Workers, worker Worker[T])

Source from the content-addressed store, hash-verified

131//
132// river.AddWorkerSafely[SortArgs](workers, &SortWorker{}).
133func AddWorkerSafely[T JobArgs](workers *Workers, worker Worker[T]) error {
134 var jobArgs T
135 return workers.add(jobArgs, &workUnitFactoryWrapper[T]{worker: worker})
136}
137
138// Workers is a list of available job workers. A Worker must be registered for
139// each type of Job to be handled.

Callers 1

AddWorkerFunction · 0.85

Calls 1

addMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…