Skip to content

Commit

Permalink
Add new fields to support PgBouncer 1.8.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbub committed Dec 28, 2017
1 parent 64d97f3 commit 2ce51ba
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 18 deletions.
30 changes: 21 additions & 9 deletions domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,24 @@ import (

// Stat represents stat row.
type Stat struct {
Database string
TotalRequests int64
TotalReceived int64
TotalSent int64
TotalQueryTime int64
AverageRequests int64
AverageReceived int64
AverageSent int64
AverageQuery int64
Database string
TotalRequests int64
TotalReceived int64
TotalSent int64
TotalQueryTime int64
TotalXactCount int64
TotalXactTime int64
TotalQueryCount int64
TotalWaitTime int64
AverageRequests int64
AverageReceived int64
AverageSent int64
AverageQuery int64
AverageQueryCount int64
AverageQueryTime int64
AverageXactTime int64
AverageXactCount int64
AverageWaitTime int64
}

// Pool represents pool row.
Expand All @@ -29,6 +38,7 @@ type Pool struct {
ServerTested int64
ServerLogin int64
MaxWait int64
MaxWaitUs int64
PoolMode string
}

Expand All @@ -44,6 +54,8 @@ type Database struct {
PoolMode string
MaxConnections int64
CurrentConnections int64
Paused int64
Disabled int64
}

// List represents list row.
Expand Down
33 changes: 24 additions & 9 deletions store/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,24 @@ import (
)

type stat struct {
Database string `db:"database"`
TotalRequests int64 `db:"total_requests"`
TotalReceived int64 `db:"total_received"`
TotalSent int64 `db:"total_sent"`
TotalQueryTime int64 `db:"total_query_time"`
AverageRequests int64 `db:"avg_req"`
AverageReceived int64 `db:"avg_recv"`
AverageSent int64 `db:"avg_sent"`
AverageQuery int64 `db:"avg_query"`
Database string `db:"database"`
TotalRequests int64 `db:"total_requests"`
TotalReceived int64 `db:"total_received"`
TotalSent int64 `db:"total_sent"`
TotalQueryTime int64 `db:"total_query_time"`
TotalXactCount int64 `db:"total_xact_count"`
TotalXactTime int64 `db:"total_xact_time"`
TotalQueryCount int64 `db:"total_query_count"`
TotalWaitTime int64 `db:"total_wait_time"`
AverageRequests int64 `db:"avg_req"`
AverageReceived int64 `db:"avg_recv"`
AverageSent int64 `db:"avg_sent"`
AverageQuery int64 `db:"avg_query"`
AverageQueryCount int64 `db:"avg_query_count"`
AverageQueryTime int64 `db:"avg_query_time"`
AverageXactTime int64 `db:"avg_xact_time"`
AverageXactCount int64 `db:"avg_xact_count"`
AverageWaitTime int64 `db:"avg_wait_time"`
}

type pool struct {
Expand All @@ -32,6 +41,7 @@ type pool struct {
ServerTested int64 `db:"sv_tested"`
ServerLogin int64 `db:"sv_login"`
MaxWait int64 `db:"maxwait"`
MaxWaitUs int64 `db:"maxwait_us"`
PoolMode sql.NullString `db:"pool_mode"`
}

Expand All @@ -46,6 +56,8 @@ type database struct {
PoolMode sql.NullString `db:"pool_mode"`
MaxConnections int64 `db:"max_connections"`
CurrentConnections int64 `db:"current_connections"`
Paused int64 `db:"paused"`
Disabled int64 `db:"disabled"`
}

type list struct {
Expand Down Expand Up @@ -99,6 +111,7 @@ func (s *SQLStore) GetPools(ctx context.Context) ([]domain.Pool, error) {
ServerTested: row.ServerTested,
ServerLogin: row.ServerLogin,
MaxWait: row.MaxWait,
MaxWaitUs: row.MaxWaitUs,
PoolMode: row.PoolMode.String,
})
}
Expand All @@ -124,6 +137,8 @@ func (s *SQLStore) GetDatabases(ctx context.Context) ([]domain.Database, error)
PoolMode: row.PoolMode.String,
MaxConnections: row.MaxConnections,
CurrentConnections: row.CurrentConnections,
Paused: row.Paused,
Disabled: row.Disabled,
})
}
return result, nil
Expand Down

0 comments on commit 2ce51ba

Please sign in to comment.