MCPcopy Index your code
hub / github.com/riverqueue/river / DBPoolClone

Function DBPoolClone

rivershared/riversharedtest/riversharedtest.go:88–103  ·  view source on GitHub ↗

DBPoolClone returns a disposable clone of DBPool. Share resources by using DBPool when possible, but this is useless for areas like stress tests where context cancellations are likely to end up closing the pool. Unlike DBPool, adds a test cleanup hook that closes the pool after run.

(ctx context.Context, tb testing.TB)

Source from the content-addressed store, hash-verified

86//
87// Unlike DBPool, adds a test cleanup hook that closes the pool after run.
88func DBPoolClone(ctx context.Context, tb testing.TB) *pgxpool.Pool {
89 tb.Helper()
90
91 dbPool := DBPool(ctx, tb)
92
93 config := dbPool.Config()
94 config.MaxConns = 4 // dramatically reduce max allowed conns for clones so we they don't clobber the database server
95
96 var err error
97 dbPool, err = pgxpool.NewWithConfig(ctx, config)
98 require.NoError(tb, err)
99
100 tb.Cleanup(dbPool.Close)
101
102 return dbPool
103}
104
105// Gets an SQLite test directory at project root so it's invariant of which
106// package tests are being run in.

Callers 6

Test_Client_CommonFunction · 0.92
Test_Client_InsertFunction · 0.92
Test_Client_QueueUpdateFunction · 0.92
TestTestTxFunction · 0.92
TestElector_WithNotifierFunction · 0.92
TestNotifierFunction · 0.92

Calls 3

DBPoolFunction · 0.85
CleanupMethod · 0.80
HelperMethod · 0.65

Tested by 6

Test_Client_CommonFunction · 0.74
Test_Client_InsertFunction · 0.74
Test_Client_QueueUpdateFunction · 0.74
TestTestTxFunction · 0.74
TestElector_WithNotifierFunction · 0.74
TestNotifierFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…