eqpg

package
v0.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, db *sql.DB, nw entroq.NotifyWaiter) (*backend, error)

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.

func Opener

func Opener(hostPort string, opts ...PGOpt) entroq.BackendOpener

Opener creates an opener function to be used to get a backend.

Types

type PGOpt

type PGOpt func(opts *pgOptions)

PGOpt sets an option for the opener.

func WithConnectAttempts

func WithConnectAttempts(num int) PGOpt

WithConnectAttempts sets the number of connection attempts before giving up. The opener waits 5 seconds between each attempt.

func WithDB

func WithDB(db string) PGOpt

WithDB changes the name of the database to connect to.

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 WithPassword

func WithPassword(pwd string) PGOpt

WithPassword sets the connection password.

func WithSSL

func WithSSL(mode SSLMode, sslOpts ...PGOpt) PGOpt

WithSSL provides SSL-specific options to the database connection.

func WithSSLClientFiles

func WithSSLClientFiles(certFile, keyFile string) PGOpt

WithSSLClientFiles specfies the client cert and key files for the connection.

func WithSSLServerCAFile

func WithSSLServerCAFile(caFile string) PGOpt

WithSSLServerCAFile specifies the CA file for verifying the server.

func WithUsername

func WithUsername(name string) PGOpt

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.
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL