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])
| 131 | // |
| 132 | // river.AddWorkerSafely[SortArgs](workers, &SortWorker{}). |
| 133 | func 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. |