Documentation ¶
Index ¶
- type Registry
- func (r *Registry) ConnFollower(filename string) *sqlite3.SQLiteConn
- func (r *Registry) ConnFollowerAdd(filename string, conn *sqlite3.SQLiteConn)
- func (r *Registry) ConnFollowerDel(filename string)
- func (r *Registry) ConnFollowerExists(filename string) bool
- func (r *Registry) ConnFollowerFilenames() []string
- func (r *Registry) ConnLeaderAdd(filename string, conn *sqlite3.SQLiteConn)
- func (r *Registry) ConnLeaderDel(conn *sqlite3.SQLiteConn)
- func (r *Registry) ConnLeaderFilename(conn *sqlite3.SQLiteConn) string
- func (r *Registry) ConnLeaders(filename string) []*sqlite3.SQLiteConn
- func (r *Registry) ConnSerial(conn *sqlite3.SQLiteConn) uint64
- func (r *Registry) Dir() string
- func (r *Registry) Dump() string
- func (r *Registry) Frames() uint64
- func (r *Registry) FramesIncrease(n uint64)
- func (r *Registry) FramesReset()
- func (r *Registry) HookSyncAdd(data []byte)
- func (r *Registry) HookSyncMatches(data []byte) bool
- func (r *Registry) HookSyncPresent() bool
- func (r *Registry) HookSyncReset()
- func (r *Registry) HookSyncSet()
- func (r *Registry) HookSyncWait()
- func (r *Registry) Index() uint64
- func (r *Registry) IndexUpdate(index uint64)
- func (r *Registry) Lock()
- func (r *Registry) Testing(t *testing.T, node int)
- func (r *Registry) TracerConn(conn *sqlite3.SQLiteConn, hook string) *trace.Tracer
- func (r *Registry) TracerFSM() *trace.Tracer
- func (r *Registry) TxnByConn(conn *sqlite3.SQLiteConn) *transaction.Txn
- func (r *Registry) TxnByFilename(filename string) *transaction.Txn
- func (r *Registry) TxnByID(id uint64) *transaction.Txn
- func (r *Registry) TxnCommittedAdd(txn *transaction.Txn)
- func (r *Registry) TxnCommittedFind(id uint64) bool
- func (r *Registry) TxnDel(id uint64)
- func (r *Registry) TxnDryRun()
- func (r *Registry) TxnFollowerAdd(conn *sqlite3.SQLiteConn, id uint64) *transaction.Txn
- func (r *Registry) TxnFollowerResurrected(txn *transaction.Txn)
- func (r *Registry) TxnFollowerSurrogate(txn *transaction.Txn) *transaction.Txn
- func (r *Registry) TxnLastID(conn *sqlite3.SQLiteConn) uint64
- func (r *Registry) TxnLeaderAdd(conn *sqlite3.SQLiteConn, id uint64) *transaction.Txn
- func (r *Registry) TxnLeaderByFilename(filename string) *transaction.Txn
- func (r *Registry) Unlock()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a dqlite node-level data structure that tracks:
- The directory where dqlite data for this node lives.
- All SQLite connections opened on the node, either in leader replication mode or follower replication mode.
- All inflight WAL write transactions, either for leader or follower connections.
- All tracers used to emit trace messages.
- Last log index applied by the FSM.
A single Registry instance is shared by a single replication.FSM instance, a single replication.Methods instance and a single dqlite.Driver instance.
Methods that access or mutate the registry are not thread-safe and must be performed after acquiring the lock. See Lock() and Unlock().
func New ¶
New creates a new registry.
The 'dir' parameter sets the directory where the node associated with this registry will save the SQLite database files.
func (*Registry) ConnFollower ¶
ConnFollower returns the follower connection used to replicate the database identified by the given filename.
If there's no follower connection registered for the database with the given filename, this method panics.
func (*Registry) ConnFollowerAdd ¶
ConnFollowerAdd adds a new follower connection to the registry.
If a follower connection for the database with the given filename is already registered, this method panics.
func (*Registry) ConnFollowerDel ¶
ConnFollowerDel removes the follower registered against the database with the given filename.
func (*Registry) ConnFollowerExists ¶
ConnFollowerExists checks whether the registry has a follower connection registered against the database with the given filename.
func (*Registry) ConnFollowerFilenames ¶
ConnFollowerFilenames returns the filenames for all databases which currently have registered follower connections.
func (*Registry) ConnLeaderAdd ¶
ConnLeaderAdd adds a new leader connection to the registry.
func (*Registry) ConnLeaderDel ¶
func (r *Registry) ConnLeaderDel(conn *sqlite3.SQLiteConn)
ConnLeaderDel removes the given leader connection from the registry.
func (*Registry) ConnLeaderFilename ¶
ConnLeaderFilename returns the filename of the database associated with the given leader connection.
If conn is not a registered leader connection, this method will panic.
func (*Registry) ConnLeaders ¶
ConnLeaders returns all open leader connections for the database with the given filename.
func (*Registry) ConnSerial ¶
ConnSerial returns a serial number uniquely identifying the given registered connection.
func (*Registry) Frames ¶
Frames returns the number of frames that have been written to the WAL so far.
func (*Registry) FramesIncrease ¶
FramesIncrease increases by the given amount the number of frames written to the WAL so far.
func (*Registry) FramesReset ¶
func (r *Registry) FramesReset()
FramesReset resets the WAL frames counter to zero.
func (*Registry) HookSyncAdd ¶
HookSyncAdd adds a new log command data to the underlying hookSync, which is expected to match the Log.Data bytes received next FSM.Apply() call.
func (*Registry) HookSyncMatches ¶
HookSyncMatches checks whether the Log.Data bytes that an FSM.Apply() call is about to process match the ones that were last added to the hookSync via HookSyncAdd().
func (*Registry) HookSyncPresent ¶
HookSyncPresent checks whether a hook sync was set by methods hook.
func (*Registry) HookSyncReset ¶
func (r *Registry) HookSyncReset()
HookSyncReset clears the hookSync instance created with HookSyncSet.
func (*Registry) HookSyncSet ¶
func (r *Registry) HookSyncSet()
HookSyncSet creates a new hookSync instance associated with this Registry.
func (*Registry) HookSyncWait ¶
func (r *Registry) HookSyncWait()
HookSyncWait blocks until the underlying hookSync is done.
It assumes that the lock is held, releasing it before blocking and requiring it thereafter.
func (*Registry) Index ¶
Index returns the last Raft log index that was successfully applied the FSM.
func (*Registry) IndexUpdate ¶
IndexUpdate updates the index of the last log applied by the FSM we're associated with.
func (*Registry) Testing ¶
Testing sets up this registry for unit-testing.
The tracers will forward all entries to the testing logger, using the given node prefix.
func (*Registry) TracerConn ¶
TracerConn returns the tracer that should be used by the replication.Methods instance associated with this registry when running the given hook for the given connection, which is assumed to be a registered leader connection.
func (*Registry) TracerFSM ¶
TracerFSM returns the tracer that should be used by the replication.FSM instance associated with this registry.
func (*Registry) TxnByConn ¶
func (r *Registry) TxnByConn(conn *sqlite3.SQLiteConn) *transaction.Txn
TxnByConn returns the transaction associated with the given connection, if any.
func (*Registry) TxnByFilename ¶
func (r *Registry) TxnByFilename(filename string) *transaction.Txn
TxnByFilename returns the transaction associated with the given database filename, if any.
If there is more than one transaction for the same filename, this method panics.
func (*Registry) TxnByID ¶
func (r *Registry) TxnByID(id uint64) *transaction.Txn
TxnByID returns the transaction with the given ID, if it exists.
func (*Registry) TxnCommittedAdd ¶
func (r *Registry) TxnCommittedAdd(txn *transaction.Txn)
TxnCommittedAdd saves the ID of the given transaction in the committed buffer, in case a client needs to check if it can be recovered.
func (*Registry) TxnCommittedFind ¶
TxnCommittedFind scans the comitted buffer and returns true if the given ID is present.
func (*Registry) TxnDryRun ¶
func (r *Registry) TxnDryRun()
TxnDryRun makes transactions only transition between states, without actually invoking the relevant SQLite APIs. This is used by tests and by surrogate followers.
func (*Registry) TxnFollowerAdd ¶
func (r *Registry) TxnFollowerAdd(conn *sqlite3.SQLiteConn, id uint64) *transaction.Txn
TxnFollowerAdd adds a new follower transaction to the registry.
The given connection is assumed to be in follower replication mode. The new transaction will be associated with the given transaction ID, which should match the one of the leader transaction that initiated the write.
func (*Registry) TxnFollowerResurrected ¶
func (r *Registry) TxnFollowerResurrected(txn *transaction.Txn)
TxnFollowerResurrected registers a follower transaction created by resurrecting a zombie leader transaction.
func (*Registry) TxnFollowerSurrogate ¶
func (r *Registry) TxnFollowerSurrogate(txn *transaction.Txn) *transaction.Txn
TxnFollowerSurrogate creates a surrogate follower transaction.
Surrogate follower transactions are used to replace leader transactions when a node loses leadership and are supposed to be undone by the next leader.
func (*Registry) TxnLastID ¶
TxnLastID returns the ID of the last transaction executed on the given leader connection.
func (*Registry) TxnLeaderAdd ¶
func (r *Registry) TxnLeaderAdd(conn *sqlite3.SQLiteConn, id uint64) *transaction.Txn
TxnLeaderAdd adds a new transaction to the registry.
The given connection is assumed to be in leader replication mode.
func (*Registry) TxnLeaderByFilename ¶
func (r *Registry) TxnLeaderByFilename(filename string) *transaction.Txn
TxnLeaderByFilename returns the leader transaction associated with the given database filename, if any.
If there is more than one leader transaction for the same filename, this method panics.