diff --git a/README.md b/README.md index aa3109a..29902a8 100644 --- a/README.md +++ b/README.md @@ -156,11 +156,24 @@ func Push(mgr worker.Manager, job *faktory.Job) error { } func syntheticPush(mgr worker.Manager, job *faktory.Job) error { - if mgr.IsRegistered(job.Type) { - return mgr.Dispatch(job) + if !mgr.IsRegistered(job.Type) { + return fmt.Errorf("failed to execute job type %s inline, job not registered", job.Type) } - return fmt.Errorf("inline job execution failed, unregistered job type %s", job.Type) + if mgr.Pool == nil { + pool, err := faktory.NewPool(2) + if err != nil { + return fmt.Errorf("couldn't create Faktory connection pool in synthetic push: %w", err) + } + mgr.Pool = pool + } + + err := mgr.Dispatch(job) + if err != nil { + return errors.Wrap(err, fmt.Sprintf("job was immediately executed but failed. Job type %s, with args %+v", job.Type, job.Args)) + } + + return nil } func realPush(job *faktory.Job) error {