Documentation
¶
Overview ¶
Package relationaldb connects an application to an Amazon Aurora DSQL database.
It carries the two decisions every client of such a database has to get right, and which would otherwise be rewritten per service: authenticating with short-lived IAM tokens instead of a password, and retrying transactions that lose an optimistic-concurrency conflict.
The database, the role and the grants are created by the platform's relational-database recipe and its migrator; this package only connects as a role it already prepared.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingEndpoint = errors.New("endpoint is required") ErrMissingRole = errors.New("role is required") ErrMissingRegion = errors.New("region is required") )
var DefaultRetry = Retry{Attempts: 5, BaseDelay: 20 * time.Millisecond}
DefaultRetry is what InTx uses. Conflicts resolve in milliseconds, so the delays are short; what matters is that they grow and carry jitter, or the same two writers keep colliding.
var ErrRetriesExhausted = errors.New("transaction kept conflicting")
ErrRetriesExhausted wraps the last conflict when every attempt lost.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Endpoint is the cluster hostname, as published by the recipe's endpoint output.
Endpoint string
// Role is the database role to connect as: client_<key> for the key the stack
// declared for this function.
Role string
// Region of the cluster, used to sign the authentication token.
Region string
// Credentials signs the tokens. Leave nil to use the function's own credentials.
Credentials aws.CredentialsProvider
// MaxConnections caps the pool. Zero uses the default.
MaxConnections int32
}
Config describes the database to connect to. Endpoint, Role and Region come from the function's environment; the recipe sets the first and Lambda sets the region.