Insert inserts a new job with the provided args. Job opts can be used to override any defaults that may have been provided by an implementation of JobArgsWithInsertOpts.InsertOpts, as well as any global defaults. The provided context is used for the underlying Postgres insert and can be used to canc
(ctx context.Context, args JobArgs, opts *InsertOpts)
| 1821 | // // handle error |
| 1822 | // } |
| 1823 | func (c *Client[TTx]) Insert(ctx context.Context, args JobArgs, opts *InsertOpts) (*rivertype.JobInsertResult, error) { |
| 1824 | if !c.driver.PoolIsSet() { |
| 1825 | return nil, errNoDriverDBPool |
| 1826 | } |
| 1827 | |
| 1828 | res, err := dbutil.WithTxV(ctx, c.driver.GetExecutor(), func(ctx context.Context, execTx riverdriver.ExecutorTx) ([]*rivertype.JobInsertResult, error) { |
| 1829 | return c.validateParamsAndInsertMany(ctx, execTx, []InsertManyParams{{Args: args, InsertOpts: opts}}) |
| 1830 | }) |
| 1831 | if err != nil { |
| 1832 | return nil, err |
| 1833 | } |
| 1834 | |
| 1835 | c.notifyProducerWithoutListenerJobFetch(ctx, res) |
| 1836 | |
| 1837 | return res[0], nil |
| 1838 | } |
| 1839 | |
| 1840 | // InsertTx inserts a new job with the provided args on the given transaction. |
| 1841 | // Job opts can be used to override any defaults that may have been provided by |