Documentation ¶
Index ¶
- Constants
- func NewPgxpoolStatsCollector(dbpool *pgxpool.Pool, dbName string) prometheus.Collector
- func NewPostgresDatastore(url string, options ...Option) (datastore.Datastore, error)
- type Option
- func ConnMaxIdleTime(idle time.Duration) Option
- func ConnMaxLifetime(lifetime time.Duration) Option
- func DebugAnalyzeBeforeStatistics() Option
- func EnableTracing() Option
- func GCInterval(interval time.Duration) Option
- func GCMaxOperationTime(time time.Duration) Option
- func GCWindow(window time.Duration) Option
- func HealthCheckPeriod(period time.Duration) Option
- func MaxOpenConns(conns int) Option
- func MaxRevisionStalenessPercent(stalenessPercent float64) Option
- func MinOpenConns(conns int) Option
- func RevisionQuantization(quantization time.Duration) Option
- func SplitAtUsersetCount(splitAtUsersetCount uint16) Option
- func WatchBufferLength(watchBufferLength uint16) Option
- func WithEnablePrometheusStats(enablePrometheusStats bool) Option
Constants ¶
const (
Engine = "postgres"
)
Variables ¶
This section is empty.
Functions ¶
func NewPgxpoolStatsCollector ¶
func NewPgxpoolStatsCollector(dbpool *pgxpool.Pool, dbName string) prometheus.Collector
NewPgxpoolStatsCollector returns a collector that exports stats available in a pgxpool.
For more info see: https://pkg.go.dev/github.com/jackc/pgx/v4/pgxpool#Stat
func NewPostgresDatastore ¶
NewPostgresDatastore initializes a SpiceDB datastore that uses a PostgreSQL database by leveraging manual book-keeping to implement revisioning.
This datastore is also tested to be compatible with CockroachDB.
Types ¶
type Option ¶ added in v1.0.0
type Option func(*postgresOptions)
Option provides the facility to configure how clients within the Postgres datastore interact with the running Postgres database.
func ConnMaxIdleTime ¶
ConnMaxIdleTime is the duration after which an idle connection will be automatically closed by the health check.
This value defaults to having no maximum.
func ConnMaxLifetime ¶
ConnMaxLifetime is the duration since creation after which a connection will be automatically closed.
This value defaults to having no maximum.
func DebugAnalyzeBeforeStatistics ¶ added in v1.6.0
func DebugAnalyzeBeforeStatistics() Option
DebugAnalyzeBeforeStatistics signals to the Statistics method that it should run Analyze on the database before returning statistics. This should only be used for debug and testing.
Disabled by default.
func EnableTracing ¶
func EnableTracing() Option
EnableTracing enables trace-level logging for the Postgres clients being used by the datastore.
Tracing is disabled by default.
func GCInterval ¶ added in v1.1.0
GCInterval is the the interval at which garbage collection will occur.
This value defaults to 3 minutes.
func GCMaxOperationTime ¶ added in v1.1.0
GCMaxOperationTime is the maximum operation time of a garbage collection pass before it times out.
This value defaults to 1 minute.
func GCWindow ¶
GCWindow is the maximum age of a passed revision that will be considered valid.
This value defaults to 24 hours.
func HealthCheckPeriod ¶
HealthCheckPeriod is the interval by which idle Postgres client connections are health checked in order to keep them alive in a connection pool.
func MaxOpenConns ¶
MaxOpenConns is the maximum size of the connection pool.
This value defaults to having no maximum.
func MaxRevisionStalenessPercent ¶ added in v1.7.0
MaxRevisionStalenessPercent is the amount of time, expressed as a percentage of the revision quantization window, that a previously computed rounded revision can still be advertised after the next rounded revision would otherwise be ready.
This value defaults to 0.1 (10%).
func MinOpenConns ¶
MinOpenConns is the minimum size of the connection pool. The health check will increase the number of connections to this amount if it had dropped below.
This value defaults to zero.
func RevisionQuantization ¶ added in v1.7.0
RevisionQuantization is the time bucket size to which advertised revisions will be rounded.
This value defaults to 5 seconds.
func SplitAtUsersetCount ¶ added in v1.5.0
SplitAtUsersetCount is the batch size for which userset queries will be split into smaller queries.
This defaults to 1024.
func WatchBufferLength ¶
WatchBufferLength is the number of entries that can be stored in the watch buffer while awaiting read by the client.
This value defaults to 128.
func WithEnablePrometheusStats ¶ added in v1.7.0
WithEnablePrometheusStats marks whether Prometheus metrics provided by the Postgres clients being used by the datastore are enabled.
Prometheus metrics are disabled by default.