Documentation
¶
Index ¶
- Constants
- Variables
- func RowsProcessNoRows(rows pgx.Rows) error
- func WriteMetricDoReadResponce(mp MetricsProvider, mRequest time.Time, poolName, sqlName string, ...)
- func WriteMetricDoRequest(mp MetricsProvider, mRequest time.Time, poolName, sqlName string, ...)
- func WriteMetricGetPool(mp MetricsProvider, mRequest time.Time, poolName, sqlName string, ...)
- func WriteMetricRequest(mp MetricsProvider, poolName, sqlName string)
- func WriteMetricResponce(mp MetricsProvider, mRequest time.Time, poolName, sqlName string, ...)
- type ConnectConfig
- func (cfg *ConnectConfig) FeelCfg(ctxIn context.Context, cfgRaw *oncfg.ConfigRaw) (err error)
- func (cfg *ConnectConfig) MakeConnection(ctxIn context.Context) (cnct *poh.Connection[*pgx.Conn], err error)
- func (cfg *ConnectConfig) MakePool(ctxBase context.Context, ctxClose context.CancelCauseFunc) (pool *PgxMFPool, err error)
- type MetricsProvider
- type PgxMFHub
- type PgxMFPool
- type RowsProcess
Constants ¶
View Source
const ErrorPoolStatus = "ERR_P"
View Source
const ErrorQueryStatus = "ERR_Q"
View Source
const ErrorRowsReadStatus = "ERR_R"
View Source
const ErrorStatus = "ERR"
View Source
const OKStatus = "OK"
Variables ¶
View Source
var ErrGetJsonFail = fmt.Errorf("fail to get json")
View Source
var ErrPgxMFHubClosePoint = fmt.Errorf("close point in hub")
View Source
var ErrQueryCall = fmt.Errorf("call request fail")
View Source
var ErrQueryPoolGet = fmt.Errorf("get free connection fail")
View Source
var ErrRowsProcess = fmt.Errorf("rows process fail")
View Source
var ErrUnmarshalJsonFail = fmt.Errorf("fail json unmarshal")
Functions ¶
func RowsProcessNoRows ¶
func WriteMetricDoReadResponce ¶
func WriteMetricDoReadResponce(mp MetricsProvider, mRequest time.Time, poolName, sqlName string, resultResult string)
func WriteMetricDoRequest ¶
func WriteMetricDoRequest(mp MetricsProvider, mRequest time.Time, poolName, sqlName string, resultResult string)
func WriteMetricGetPool ¶
func WriteMetricGetPool(mp MetricsProvider, mRequest time.Time, poolName, sqlName string, resultResult string)
func WriteMetricRequest ¶
func WriteMetricRequest(mp MetricsProvider, poolName, sqlName string)
func WriteMetricResponce ¶
func WriteMetricResponce(mp MetricsProvider, mRequest time.Time, poolName, sqlName string, resultResult string)
Types ¶
type ConnectConfig ¶
type ConnectConfig struct {
ConnString string `envconfig:"conn_string" default:"user=postgres host=localhost port=5432 dbname=postgres" json:"conn_string"`
Password string `envconfig:"password" default_pwd:"postgres" json:"password"`
MaxConnections int `envconfig:"max_connections" default:"5" json:"max_connections"`
MinConnections int `envconfig:"min_connections" default:"0" json:"min_connections"`
// OpenTimeout time in open state; 0 mean forever open
OpenTimeout time.Duration `envconfig:"open_timeout" default:"600s" json:"open_timeout"`
IdleTimeout time.Duration `envconfig:"idle_timeout" default:"600s" json:"idle_timeout"`
PoolGetConnectionTimeout time.Duration `envconfig:"get_connection_timeout" default:"5s" json:"get_connection_timeout"`
PoolName string `envconfig:"pool_name" json:"pool_name"`
}
ConnectConfig connection config and pool config
func (*ConnectConfig) MakeConnection ¶
func (cfg *ConnectConfig) MakeConnection(ctxIn context.Context) (cnct *poh.Connection[*pgx.Conn], err error)
func (*ConnectConfig) MakePool ¶
func (cfg *ConnectConfig) MakePool(ctxBase context.Context, ctxClose context.CancelCauseFunc) (pool *PgxMFPool, err error)
type MetricsProvider ¶
type MetricsProvider interface {
WriteMetricRequest(poolName, sqlName string)
WriteMetricGetPool(mRequest time.Time, poolName, sqlName string, resultResult string)
WriteMetricDoRequest(mRequest time.Time, poolName, sqlName string, resultResult string)
WriteMetricDoReadResponce(mRequest time.Time, poolName, sqlName string, resultResult string)
WriteMetricResponce(mRequest time.Time, poolName, sqlName string, resultResult string)
}
var DefaultMetricsProvider MetricsProvider
type PgxMFHub ¶ added in v1.0.0
type PgxMFHub struct {
// contains filtered or unexported fields
}
func MakePgxMFHub ¶ added in v1.0.0
func (*PgxMFHub) Cfg ¶ added in v1.0.0
func (pgxhub *PgxMFHub) Cfg() *oncfg.ListSourceConfig
type PgxMFPool ¶
type PgxMFPool struct {
Pool *poh.ConnectionPool[*pgx.Conn]
PoolName func() string
MetricsProvider MetricsProvider
GetNewConnectionTimeout poh.ExpireDurationFunc
// contains filtered or unexported fields
}
func (PgxMFPool) Cfg ¶ added in v1.0.0
func (pool PgxMFPool) Cfg() *ConnectConfig
type RowsProcess ¶
func RowsProcessJson ¶
func RowsProcessJson(js *json.RawMessage, exists *bool) RowsProcess
func RowsProcessStructFronJson ¶
func RowsProcessStructFronJson[T any](objs *[]T, exists *bool) RowsProcess
Click to show internal directories.
Click to hide internal directories.