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

Method Insert

client.go:1823–1838  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1821// // handle error
1822// }
1823func (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

Callers 15

Example_uniqueJobFunction · 0.80
Example_jobArgsHooksFunction · 0.80
Example_jobSnoozeFunction · 0.80
Example_subscriptionFunction · 0.80
Example_resumableCursorFunction · 0.80
Example_jobStuckHandlerFunction · 0.80
Example_customInsertOptsFunction · 0.80
TestWorkFuncFunction · 0.80

Calls 5

WithTxVFunction · 0.92
PoolIsSetMethod · 0.65
GetExecutorMethod · 0.65

Tested by 15

Example_uniqueJobFunction · 0.64
Example_jobArgsHooksFunction · 0.64
Example_jobSnoozeFunction · 0.64
Example_subscriptionFunction · 0.64
Example_resumableCursorFunction · 0.64
Example_jobStuckHandlerFunction · 0.64
Example_customInsertOptsFunction · 0.64
TestWorkFuncFunction · 0.64