diff options
| author | EuAndreh <eu@euandre.org> | 2024-10-27 07:40:51 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2024-10-27 07:40:51 -0300 |
| commit | f637c04d24bbb3a1f6bbd64180de55fa1aee44e2 (patch) | |
| tree | 5c578ddfdd5af4cfc9df5823a9d1faa93f207e35 /tests/functional/new-instance-takeover | |
| parent | Makefile: Simplify output generation of "bench" target dependencies (diff) | |
| download | fiinha-f637c04d24bbb3a1f6bbd64180de55fa1aee44e2.tar.gz fiinha-f637c04d24bbb3a1f6bbd64180de55fa1aee44e2.tar.xz | |
src/q.go: New() - manage *sql.DB handle internally
Diffstat (limited to 'tests/functional/new-instance-takeover')
| -rw-r--r-- | tests/functional/new-instance-takeover/q.go | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/tests/functional/new-instance-takeover/q.go b/tests/functional/new-instance-takeover/q.go index 10c4744..6e04e5f 100644 --- a/tests/functional/new-instance-takeover/q.go +++ b/tests/functional/new-instance-takeover/q.go @@ -1,12 +1,10 @@ package q import ( -"fmt" - "database/sql" + "fmt" "runtime" "os" - "golite" "guuid" g "gobang" ) @@ -38,16 +36,13 @@ func startInstance( databasePath string, instanceID int, name string, -) (*sql.DB, IQueue, error) { - db, err := sql.Open(golite.DriverName, databasePath) - g.TErrorIf(err) - - iqueue, err := New(db) +) (IQueue, error) { + iqueue, err := New(databasePath) g.TErrorIf(err) queue := iqueue.(queueT) notifyFn := makeNotifyFn(queue.subscriptions.read, queue.pinger) - queries, err := initDB(db, defaultPrefix, notifyFn, instanceID) + queries, err := initDB(queue.db, defaultPrefix, notifyFn, instanceID) g.TErrorIf(err) err = queue.queries.close() @@ -67,7 +62,7 @@ func startInstance( queue.Subscribe(topic, individual, handlerFn(pub_(individual))) queue.Subscribe(topic, shared, handlerFn(pub_(shared + "-" + name))) - return db, queue, nil + return queue, nil } @@ -98,9 +93,8 @@ func MainTest() { fmt.Fprintf(os.Stderr, "(PID %d + 1) ", instanceID1) } - db, q1, err := startInstance(dbpath, instanceID1, "first") + q1, err := startInstance(dbpath, instanceID1, "first") g.TErrorIf(err) - defer db.Close() defer q1.Close() pub(q1, topic, guuid.New()) @@ -111,9 +105,8 @@ func MainTest() { <- q1.WaitFor( "shared-first", flowID1, "w").Channel // println("waited 1") - db, q2, err := startInstance(dbpath, instanceID2, "second") + q2, err := startInstance(dbpath, instanceID2, "second") g.TErrorIf(err) - defer db.Close() defer q2.Close() <- q2.WaitFor("individual-second", flowID1, "w").Channel |
