Documentation
¶
Overview ¶
Package pgfault relays PostgreSQL connections through a local TCP proxy and injects one fault into the next COMMIT, for tests of a COMMIT whose outcome the client does not learn.
Index ¶
Constants ¶
const CommitDelay = 300 * time.Millisecond
CommitDelay is how long DelayCommit holds the COMMIT.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fault ¶
type Fault int
Fault is what the proxy does to the next COMMIT.
const ( // DropReply relays the COMMIT, swallows the server's reply, and closes // both sides: the transaction commits, and the client never learns it. DropReply Fault = iota + 1 // DropCommit closes both sides instead of relaying the COMMIT: the // server aborts the transaction. DropCommit // HoldCommit closes the client side and keeps the server side open // without relaying the COMMIT: the transaction stays in progress until // the test ends. HoldCommit // CutAll drops the COMMIT like DropCommit, then closes every relayed // connection and the listener: no later connection reaches the server. CutAll // DelayCommit closes the client side, then relays the COMMIT after // CommitDelay: the transaction stays in progress for CommitDelay, then // commits, and the client never learns it. DelayCommit )
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy relays TCP connections to one PostgreSQL server.
func Start ¶
Start relays to the host of dbURL and returns the proxy and dbURL rewritten to connect through it. t's cleanup closes the listener and every relayed connection.
func (*Proxy) Arm ¶
Arm makes the next COMMIT that any relayed connection sends suffer f. onFault, when not nil, runs once, after Fired turns true and before the proxy closes any connection, so Fired is true by the time the client sees the fault. For DropReply it runs after the server's reply arrived: the transaction committed. For the other faults it runs when the proxy holds the COMMIT.