}
type pgEventSource struct {
- DataSource string
- QueueSize int
+ DataSource string
+ MaxOpenConns int
+ QueueSize int
db *sql.DB
pqListener *pq.Listener
logger(nil).WithError(err).Error("sql.Open failed")
return
}
+ if ps.MaxOpenConns <= 0 {
+ logger(nil).Warn("no database connection limit configured -- consider setting PostgresPool>0 in arvados-ws configuration file")
+ }
+ db.SetMaxOpenConns(ps.MaxOpenConns)
if err = db.Ping(); err != nil {
logger(nil).WithError(err).Error("db.Ping failed")
return
return ps.db
}
+func (ps *pgEventSource) DBHealth() error {
+ ctx, _ := context.WithDeadline(context.Background(), time.Now().Add(time.Second))
+ var i int
+ return ps.db.QueryRowContext(ctx, "SELECT 1").Scan(&i)
+}
+
func (ps *pgEventSource) DebugStatus() interface{} {
ps.mtx.Lock()
defer ps.mtx.Unlock()