introduce databse connection pooling and harden RowSet operations

This commit is contained in:
amy
2026-11-12 14:25:11 -07:00
parent ec50f048a1
commit 630d129bb5
10 changed files with 97 additions and 21 deletions
+14 -4
View File
@@ -180,6 +180,7 @@ func AmGetCommunityServices(ctx context.Context, cid int32) ([]*ServiceDef, erro
if err != nil {
return nil, err
}
defer rs.Close()
dom := serviceRoot.byName[AM_DOMAIN_COMMUNITY]
a := make([]*ServiceDef, 0, len(dom.Services))
for rs.Next() {
@@ -188,8 +189,12 @@ func AmGetCommunityServices(ctx context.Context, cid int32) ([]*ServiceDef, erro
a = append(a, dom.byIndex[ndx])
}
}
servicesCache.Add(cid, a)
rc = a
if rs.Err() == nil {
servicesCache.Add(cid, a)
rc = a
} else {
return nil, rs.Err()
}
}
return rc.([]*ServiceDef), nil
}
@@ -212,6 +217,7 @@ func AmGetCommunityServicesTx(ctx context.Context, tx *sqlx.Tx, cid int32) ([]*S
if err != nil {
return nil, err
}
defer rs.Close()
dom := serviceRoot.byName[AM_DOMAIN_COMMUNITY]
a := make([]*ServiceDef, 0, len(dom.Services))
for rs.Next() {
@@ -220,8 +226,12 @@ func AmGetCommunityServicesTx(ctx context.Context, tx *sqlx.Tx, cid int32) ([]*S
a = append(a, dom.byIndex[ndx])
}
}
servicesCache.Add(cid, a)
rc = a
if rs.Err() == nil {
servicesCache.Add(cid, a)
rc = a
} else {
return nil, rs.Err()
}
}
return rc.([]*ServiceDef), nil
}