Documentation
¶
Overview ¶
Package proxytest builds a real two-role IPC write topology for tests: a migrated database file, the primary's pool with a write coordinator served over a real ZMQ bus, and a secondary's 1-connection 200 ms pool with a DBProxy forwarding to that bus. It is imported only by tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Topology ¶
type Topology struct {
DBPath string
// PrimaryDB is the primary's pool (10 s busy timeout, migrated). The
// coordinator and the statement executor run on it.
PrimaryDB *sql.DB
// SecondaryDB is the secondary's pool (1 connection, 200 ms busy timeout).
SecondaryDB *sql.DB
// Proxy is the secondary's DBProxy: local querier on SecondaryDB, writes
// forwarded to the primary's bus on lock contention.
Proxy *dbproxy.DBProxy
Client *ipc.Client
PubPort, RPCPort int
// contains filtered or unexported fields
}
Topology is a primary + secondary pair sharing one database file.
func New ¶
New builds the topology and starts the primary. Everything is torn down by t.Cleanup, including the package-level statement executor.
func (*Topology) DrainPrimary ¶
DrainPrimary makes the running primary refuse new writes the way a primary handing over does (writecoordinator.ErrDraining), without closing its bus.
func (*Topology) HoldWriteLock ¶
HoldWriteLock takes the database write lock on a primary connection (BEGIN IMMEDIATE) and releases it after d, simulating the primary holding a long write. It returns once the lock is held; the returned channel is closed after the release.
func (*Topology) StartPrimary ¶
StartPrimary starts a (new) primary bus with a fresh write coordinator on PrimaryDB, bound to the topology's ports; it retries the bind for up to 3 s because a just-stopped bus may still own them.
func (*Topology) StopPrimary ¶
func (tp *Topology) StopPrimary()
StopPrimary drains the coordinator and shuts the bus down (idempotent).