Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions example_batch_insert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ func Example_batchInsert() {
subscribeChan, subscribeCancel := riverClient.Subscribe(river.EventKindJobCompleted)
defer subscribeCancel()

if err := riverClient.Start(ctx); err != nil {
panic(err)
}

results, err := riverClient.InsertMany(ctx, []river.InsertManyParams{
{Args: BatchInsertArgs{}},
{Args: BatchInsertArgs{}},
Expand All @@ -78,6 +74,12 @@ func Example_batchInsert() {
}
fmt.Printf("Inserted %d jobs\n", len(results))

// Start the client after inserting and printing so that the "Inserted"
// message is guaranteed to appear before any "Worked" messages.
if err := riverClient.Start(ctx); err != nil {
panic(err)
}

// Wait for jobs to complete. Only needed for purposes of the example test.
riversharedtest.WaitOrTimeoutN(testutil.PanicTB(), subscribeChan, 5)

Expand Down
Loading