Documentation ¶
Overview ¶
Package eqpg provides an entroq.Backend using PostgreSQL. Use Opener with entroq.New to create a task client that talks to a PostgreSQL backend.
Index ¶
- func New(ctx context.Context, db *sql.DB, nw entroq.NotifyWaiter) (*backend, error)
- func Opener(hostPort string, opts ...PGOpt) entroq.BackendOpener
- type PGOpt
- func WithConnectAttempts(num int) PGOpt
- func WithDB(db string) PGOpt
- func WithNotifyWaiter(nw entroq.NotifyWaiter) PGOpt
- func WithPassword(pwd string) PGOpt
- func WithSSL(mode SSLMode, sslOpts ...PGOpt) PGOpt
- func WithSSLClientFiles(certFile, keyFile string) PGOpt
- func WithSSLServerCAFile(caFile string) PGOpt
- func WithUsername(name string) PGOpt
- type SSLMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates a new postgres backend that attaches to the given database. If the NotifyWaiter value is provided, Claim will attempt to wait for task events, and Modify will notify on changes and insertions that create "available" tasks. This allows newly-inserted tasks to be picked up more or less immediately if another routine is waiting on the corresponding queue.
Note that this is an *optimization*, not a guarantee that tasks will be picked up immediately. It is therefore safe, though not necessarily very helpful, for multiple of these backends to have their own NotifyWaiter objects.
If left nil, the default behavior is to poll and sleep.
Types ¶
type PGOpt ¶
type PGOpt func(opts *pgOptions)
PGOpt sets an option for the opener.
func WithConnectAttempts ¶
WithConnectAttempts sets the number of connection attempts before giving up. The opener waits 5 seconds between each attempt.
func WithNotifyWaiter ¶
func WithNotifyWaiter(nw entroq.NotifyWaiter) PGOpt
WithNotifyWaiter instructs this backend to use the given NotifyWaiter (instead of its own). This can be useful if there are several interdependent postgres backends in the same process space - they can use the same notification mechanism.
Can be set to nil to disable internal claim/modify wait/notify and revert to claim poll/sleep.
func WithSSLClientFiles ¶
WithSSLClientFiles specfies the client cert and key files for the connection.
func WithSSLServerCAFile ¶
WithSSLServerCAFile specifies the CA file for verifying the server.
func WithUsername ¶
WithUsername changes the username this database will use to connect.
type SSLMode ¶
type SSLMode string
SSLMode is used to request a particular PostgreSQL SSL mode.
const ( SSLDisable SSLMode = "disable" // Always non-SSL. SSLAllow SSLMode = "allow" // Try non-SSL first, fall back to SSL. SSLPrefer SSLMode = "prefer" // Try SSL first, fall back to non-SSL. SSLRequire SSLMode = "require" // Only try SSL. SSLVerifyCA SSLMode = "verify-ca" // Only SSL, check server against CA. SSLVerifyFull SSLMode = "verify-full" // Only SSL, check CA and host name. )