Documentation ¶
Index ¶
- Variables
- type Delay
- type DumbWatchManager
- type FullTableWatch
- type Graveyard
- func (g *Graveyard) DumpTxn(tx *memdb.Txn) (memdb.ResultIterator, error)
- func (g *Graveyard) GetMaxIndexTxn(tx *memdb.Txn, prefix string) (uint64, error)
- func (g *Graveyard) InsertTxn(tx *memdb.Txn, key string, idx uint64) error
- func (g *Graveyard) ReapTxn(tx *memdb.Txn, idx uint64) error
- func (g *Graveyard) RestoreTxn(tx *memdb.Txn, stone *Tombstone) error
- type IndexEntry
- type MultiWatch
- type NotifyGroup
- type PrefixWatch
- type StateRestore
- func (s *StateRestore) ACL(acl *structs.ACL) error
- func (s *StateRestore) Abort()
- func (s *StateRestore) Commit()
- func (s *StateRestore) Coordinates(idx uint64, updates structs.Coordinates) error
- func (s *StateRestore) KVS(entry *structs.DirEntry) error
- func (s *StateRestore) PreparedQuery(query *structs.PreparedQuery) error
- func (s *StateRestore) Registration(idx uint64, req *structs.RegisterRequest) error
- func (s *StateRestore) Session(sess *structs.Session) error
- func (s *StateRestore) Tombstone(stone *Tombstone) error
- type StateSnapshot
- func (s *StateSnapshot) ACLs() (memdb.ResultIterator, error)
- func (s *StateSnapshot) Checks(node string) (memdb.ResultIterator, error)
- func (s *StateSnapshot) Close()
- func (s *StateSnapshot) Coordinates() (memdb.ResultIterator, error)
- func (s *StateSnapshot) KVs() (memdb.ResultIterator, error)
- func (s *StateSnapshot) LastIndex() uint64
- func (s *StateSnapshot) Nodes() (memdb.ResultIterator, error)
- func (s *StateSnapshot) PreparedQueries() (memdb.ResultIterator, error)
- func (s *StateSnapshot) Services(node string) (memdb.ResultIterator, error)
- func (s *StateSnapshot) Sessions() (memdb.ResultIterator, error)
- func (s *StateSnapshot) Tombstones() (memdb.ResultIterator, error)
- type StateStore
- func (s *StateStore) ACLDelete(idx uint64, aclID string) error
- func (s *StateStore) ACLGet(aclID string) (uint64, *structs.ACL, error)
- func (s *StateStore) ACLList() (uint64, structs.ACLs, error)
- func (s *StateStore) ACLSet(idx uint64, acl *structs.ACL) error
- func (s *StateStore) CheckServiceNodes(serviceName string) (uint64, structs.CheckServiceNodes, error)
- func (s *StateStore) CheckServiceTagNodes(serviceName, tag string) (uint64, structs.CheckServiceNodes, error)
- func (s *StateStore) ChecksInState(state string) (uint64, structs.HealthChecks, error)
- func (s *StateStore) CoordinateBatchUpdate(idx uint64, updates structs.Coordinates) error
- func (s *StateStore) CoordinateGetRaw(node string) (*coordinate.Coordinate, error)
- func (s *StateStore) Coordinates() (uint64, structs.Coordinates, error)
- func (s *StateStore) DeleteCheck(idx uint64, node, id string) error
- func (s *StateStore) DeleteNode(idx uint64, nodeID string) error
- func (s *StateStore) DeleteService(idx uint64, nodeID, serviceID string) error
- func (s *StateStore) EnsureCheck(idx uint64, hc *structs.HealthCheck) error
- func (s *StateStore) EnsureNode(idx uint64, node *structs.Node) error
- func (s *StateStore) EnsureRegistration(idx uint64, req *structs.RegisterRequest) error
- func (s *StateStore) EnsureService(idx uint64, node string, svc *structs.NodeService) error
- func (s *StateStore) GetKVSWatch(prefix string) Watch
- func (s *StateStore) GetNode(id string) (uint64, *structs.Node, error)
- func (s *StateStore) GetQueryWatch(method string) Watch
- func (s *StateStore) KVSDelete(idx uint64, key string) error
- func (s *StateStore) KVSDeleteCAS(idx, cidx uint64, key string) (bool, error)
- func (s *StateStore) KVSDeleteTree(idx uint64, prefix string) error
- func (s *StateStore) KVSGet(key string) (uint64, *structs.DirEntry, error)
- func (s *StateStore) KVSList(prefix string) (uint64, structs.DirEntries, error)
- func (s *StateStore) KVSListKeys(prefix, sep string) (uint64, []string, error)
- func (s *StateStore) KVSLock(idx uint64, entry *structs.DirEntry) (bool, error)
- func (s *StateStore) KVSLockDelay(key string) time.Time
- func (s *StateStore) KVSSet(idx uint64, entry *structs.DirEntry) error
- func (s *StateStore) KVSSetCAS(idx uint64, entry *structs.DirEntry) (bool, error)
- func (s *StateStore) KVSUnlock(idx uint64, entry *structs.DirEntry) (bool, error)
- func (s *StateStore) NodeChecks(nodeID string) (uint64, structs.HealthChecks, error)
- func (s *StateStore) NodeDump() (uint64, structs.NodeDump, error)
- func (s *StateStore) NodeInfo(node string) (uint64, structs.NodeDump, error)
- func (s *StateStore) NodeServices(nodeID string) (uint64, *structs.NodeServices, error)
- func (s *StateStore) NodeSessions(nodeID string) (uint64, structs.Sessions, error)
- func (s *StateStore) Nodes() (uint64, structs.Nodes, error)
- func (s *StateStore) PreparedQueryDelete(idx uint64, queryID string) error
- func (s *StateStore) PreparedQueryGet(queryID string) (uint64, *structs.PreparedQuery, error)
- func (s *StateStore) PreparedQueryList() (uint64, structs.PreparedQueries, error)
- func (s *StateStore) PreparedQueryLookup(queryIDOrName string) (uint64, *structs.PreparedQuery, error)
- func (s *StateStore) PreparedQuerySet(idx uint64, query *structs.PreparedQuery) error
- func (s *StateStore) ReapTombstones(index uint64) error
- func (s *StateStore) Restore() *StateRestore
- func (s *StateStore) ServiceChecks(serviceName string) (uint64, structs.HealthChecks, error)
- func (s *StateStore) ServiceNodes(serviceName string) (uint64, structs.ServiceNodes, error)
- func (s *StateStore) ServiceTagNodes(service, tag string) (uint64, structs.ServiceNodes, error)
- func (s *StateStore) Services() (uint64, structs.Services, error)
- func (s *StateStore) SessionCreate(idx uint64, sess *structs.Session) error
- func (s *StateStore) SessionDestroy(idx uint64, sessionID string) error
- func (s *StateStore) SessionGet(sessionID string) (uint64, *structs.Session, error)
- func (s *StateStore) SessionList() (uint64, structs.Sessions, error)
- func (s *StateStore) Snapshot() *StateSnapshot
- type Tombstone
- type TombstoneGC
- type Watch
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMissingNode is the error returned when trying an operation // which requires a node registration but none exists. ErrMissingNode = errors.New("Missing node registration") // ErrMissingService is the error we return if trying an // operation which requires a service but none exists. ErrMissingService = errors.New("Missing service registration") // ErrMissingSessionID is returned when a session registration // is attempted with an empty session ID. ErrMissingSessionID = errors.New("Missing session ID") // ErrMissingACLID is returned when an ACL set is called on // an ACL with an empty ID. ErrMissingACLID = errors.New("Missing ACL ID") // ErrMissingQueryID is returned when a Query set is called on // a Query with an empty ID. ErrMissingQueryID = errors.New("Missing Query ID") )
Functions ¶
This section is empty.
Types ¶
type Delay ¶
type Delay struct {
// contains filtered or unexported fields
}
Delay is used to mark certain locks as unacquirable. When a lock is forcefully released (failing health check, destroyed session, etc.), it is subject to the LockDelay impossed by the session. This prevents another session from acquiring the lock for some period of time as a protection against split-brains. This is inspired by the lock-delay in Chubby. Because this relies on wall-time, we cannot assume all peers perceive time as flowing uniformly. This means KVSLock MUST ignore lockDelay, since the lockDelay may have expired on the leader, but not on the follower. Rejecting the lock could result in inconsistencies in the FSMs due to the rate time progresses. Instead, only the opinion of the leader is respected, and the Raft log is never questioned.
func (*Delay) GetExpiration ¶
GetExpiration returns the expiration time of a key lock delay. This must be checked on the leader node, and not in KVSLock due to the variability of clocks.
type DumbWatchManager ¶
type DumbWatchManager struct {
// contains filtered or unexported fields
}
DumbWatchManager is a wrapper that allows nested code to arm full table watches multiple times but fire them only once. This doesn't have any way to clear the state, and it's not thread-safe, so it should be used once and thrown away inside the context of a single thread.
func NewDumbWatchManager ¶
func NewDumbWatchManager(tableWatches map[string]*FullTableWatch) *DumbWatchManager
NewDumbWatchManager returns a new dumb watch manager.
func (*DumbWatchManager) Arm ¶
func (d *DumbWatchManager) Arm(table string)
Arm arms the given table's watch.
func (*DumbWatchManager) Notify ¶
func (d *DumbWatchManager) Notify()
Notify fires watches for all the armed tables.
type FullTableWatch ¶
type FullTableWatch struct {
// contains filtered or unexported fields
}
FullTableWatch implements a single notify group for a table.
func NewFullTableWatch ¶
func NewFullTableWatch() *FullTableWatch
NewFullTableWatch returns a new full table watch.
func (*FullTableWatch) Notify ¶
func (w *FullTableWatch) Notify()
Notify wakes up all the watchers registered for this table.
type Graveyard ¶
type Graveyard struct {
// contains filtered or unexported fields
}
Graveyard manages a set of tombstones.
func NewGraveyard ¶
func NewGraveyard(gc *TombstoneGC) *Graveyard
NewGraveyard returns a new graveyard.
func (*Graveyard) GetMaxIndexTxn ¶
GetMaxIndexTxn returns the highest index tombstone whose key matches the given context, using a prefix match.
func (*Graveyard) ReapTxn ¶
ReapTxn cleans out all tombstones whose index values are less than or equal to the given idx. This prevents unbounded storage growth of the tombstones.
func (*Graveyard) RestoreTxn ¶
RestoreTxn is used when restoring from a snapshot. For general inserts, use InsertTxn.
type IndexEntry ¶
IndexEntry keeps a record of the last index per-table.
type MultiWatch ¶
type MultiWatch struct {
// contains filtered or unexported fields
}
MultiWatch wraps several watches and allows any of them to trigger the caller.
func NewMultiWatch ¶
func NewMultiWatch(watches ...Watch) *MultiWatch
NewMultiWatch returns a new new multi watch over the given set of watches.
type NotifyGroup ¶
type NotifyGroup struct {
// contains filtered or unexported fields
}
NotifyGroup is used to allow a simple notification mechanism. Channels can be marked as waiting, and when notify is invoked, all the waiting channels get a message and are cleared from the notify list.
func (*NotifyGroup) Clear ¶
func (n *NotifyGroup) Clear(ch chan struct{})
Clear removes a channel from the notify group
func (*NotifyGroup) Notify ¶
func (n *NotifyGroup) Notify()
Notify will do a non-blocking send to all waiting channels, and clear the notify list
func (*NotifyGroup) Wait ¶
func (n *NotifyGroup) Wait(ch chan struct{})
Wait adds a channel to the notify group
func (*NotifyGroup) WaitCh ¶
func (n *NotifyGroup) WaitCh() chan struct{}
WaitCh allocates a channel that is subscribed to notifications
type PrefixWatch ¶
type PrefixWatch struct {
// contains filtered or unexported fields
}
PrefixWatch maintains a notify group for each prefix, allowing for much more fine-grained watches.
func (*PrefixWatch) GetSubwatch ¶
func (w *PrefixWatch) GetSubwatch(prefix string) *NotifyGroup
GetSubwatch returns the notify group for the given prefix.
func (*PrefixWatch) Notify ¶
func (w *PrefixWatch) Notify(prefix string, subtree bool)
Notify wakes up all the watchers associated with the given prefix. If subtree is true then we will also notify all the tree under the prefix, such as when a key is being deleted.
type StateRestore ¶
type StateRestore struct {
// contains filtered or unexported fields
}
StateRestore is used to efficiently manage restoring a large amount of data to a state store.
func (*StateRestore) ACL ¶
func (s *StateRestore) ACL(acl *structs.ACL) error
ACL is used when restoring from a snapshot. For general inserts, use ACLSet.
func (*StateRestore) Abort ¶
func (s *StateRestore) Abort()
Abort abandons the changes made by a restore. This or Commit should always be called.
func (*StateRestore) Commit ¶
func (s *StateRestore) Commit()
Commit commits the changes made by a restore. This or Abort should always be called.
func (*StateRestore) Coordinates ¶
func (s *StateRestore) Coordinates(idx uint64, updates structs.Coordinates) error
Coordinates is used when restoring from a snapshot. For general inserts, use CoordinateBatchUpdate. We do less vetting of the updates here because they already got checked on the way in during a batch update.
func (*StateRestore) KVS ¶
func (s *StateRestore) KVS(entry *structs.DirEntry) error
KVS is used when restoring from a snapshot. Use KVSSet for general inserts.
func (*StateRestore) PreparedQuery ¶
func (s *StateRestore) PreparedQuery(query *structs.PreparedQuery) error
PrepparedQuery is used when restoring from a snapshot. For general inserts, use PreparedQuerySet.
func (*StateRestore) Registration ¶
func (s *StateRestore) Registration(idx uint64, req *structs.RegisterRequest) error
Registration is used to make sure a node, service, and check registration is performed within a single transaction to avoid race conditions on state updates.
func (*StateRestore) Session ¶
func (s *StateRestore) Session(sess *structs.Session) error
Session is used when restoring from a snapshot. For general inserts, use SessionCreate.
func (*StateRestore) Tombstone ¶
func (s *StateRestore) Tombstone(stone *Tombstone) error
Tombstone is used when restoring from a snapshot. For general inserts, use Graveyard.InsertTxn.
type StateSnapshot ¶
type StateSnapshot struct {
// contains filtered or unexported fields
}
StateSnapshot is used to provide a point-in-time snapshot. It works by starting a read transaction against the whole state store.
func (*StateSnapshot) ACLs ¶
func (s *StateSnapshot) ACLs() (memdb.ResultIterator, error)
ACLs is used to pull all the ACLs from the snapshot.
func (*StateSnapshot) Checks ¶
func (s *StateSnapshot) Checks(node string) (memdb.ResultIterator, error)
Checks is used to pull the full list of checks for a given node for use during snapshots.
func (*StateSnapshot) Close ¶
func (s *StateSnapshot) Close()
Close performs cleanup of a state snapshot.
func (*StateSnapshot) Coordinates ¶
func (s *StateSnapshot) Coordinates() (memdb.ResultIterator, error)
Coordinates is used to pull all the coordinates from the snapshot.
func (*StateSnapshot) KVs ¶
func (s *StateSnapshot) KVs() (memdb.ResultIterator, error)
KVs is used to pull the full list of KVS entries for use during snapshots.
func (*StateSnapshot) LastIndex ¶
func (s *StateSnapshot) LastIndex() uint64
LastIndex returns that last index that affects the snapshotted data.
func (*StateSnapshot) Nodes ¶
func (s *StateSnapshot) Nodes() (memdb.ResultIterator, error)
Nodes is used to pull the full list of nodes for use during snapshots.
func (*StateSnapshot) PreparedQueries ¶
func (s *StateSnapshot) PreparedQueries() (memdb.ResultIterator, error)
PreparedQueries is used to pull all the prepared queries from the snapshot.
func (*StateSnapshot) Services ¶
func (s *StateSnapshot) Services(node string) (memdb.ResultIterator, error)
Services is used to pull the full list of services for a given node for use during snapshots.
func (*StateSnapshot) Sessions ¶
func (s *StateSnapshot) Sessions() (memdb.ResultIterator, error)
Sessions is used to pull the full list of sessions for use during snapshots.
func (*StateSnapshot) Tombstones ¶
func (s *StateSnapshot) Tombstones() (memdb.ResultIterator, error)
Tombstones is used to pull all the tombstones from the graveyard.
type StateStore ¶
type StateStore struct {
// contains filtered or unexported fields
}
StateStore is where we store all of Consul's state, including records of node registrations, services, checks, key/value pairs and more. The DB is entirely in-memory and is constructed from the Raft log through the FSM.
func NewStateStore ¶
func NewStateStore(gc *TombstoneGC) (*StateStore, error)
NewStateStore creates a new in-memory state storage layer.
func (*StateStore) ACLDelete ¶
func (s *StateStore) ACLDelete(idx uint64, aclID string) error
ACLDelete is used to remove an existing ACL from the state store. If the ACL does not exist this is a no-op and no error is returned.
func (*StateStore) ACLList ¶
func (s *StateStore) ACLList() (uint64, structs.ACLs, error)
ACLList is used to list out all of the ACLs in the state store.
func (*StateStore) ACLSet ¶
func (s *StateStore) ACLSet(idx uint64, acl *structs.ACL) error
ACLSet is used to insert an ACL rule into the state store.
func (*StateStore) CheckServiceNodes ¶
func (s *StateStore) CheckServiceNodes(serviceName string) (uint64, structs.CheckServiceNodes, error)
CheckServiceNodes is used to query all nodes and checks for a given service The results are compounded into a CheckServiceNodes, and the index returned is the maximum index observed over any node, check, or service in the result set.
func (*StateStore) CheckServiceTagNodes ¶
func (s *StateStore) CheckServiceTagNodes(serviceName, tag string) (uint64, structs.CheckServiceNodes, error)
CheckServiceTagNodes is used to query all nodes and checks for a given service, filtering out services that don't contain the given tag. The results are compounded into a CheckServiceNodes, and the index returned is the maximum index observed over any node, check, or service in the result set.
func (*StateStore) ChecksInState ¶
func (s *StateStore) ChecksInState(state string) (uint64, structs.HealthChecks, error)
ChecksInState is used to query the state store for all checks which are in the provided state.
func (*StateStore) CoordinateBatchUpdate ¶
func (s *StateStore) CoordinateBatchUpdate(idx uint64, updates structs.Coordinates) error
CoordinateBatchUpdate processes a batch of coordinate updates and applies them in a single transaction.
func (*StateStore) CoordinateGetRaw ¶
func (s *StateStore) CoordinateGetRaw(node string) (*coordinate.Coordinate, error)
CoordinateGetRaw queries for the coordinate of the given node. This is an unusual state store method because it just returns the raw coordinate or nil, none of the Raft or node information is returned. This hits the 90% internal-to-Consul use case for this data, and this isn't exposed via an endpoint, so it doesn't matter that the Raft info isn't available.
func (*StateStore) Coordinates ¶
func (s *StateStore) Coordinates() (uint64, structs.Coordinates, error)
Coordinates queries for all nodes with coordinates.
func (*StateStore) DeleteCheck ¶
func (s *StateStore) DeleteCheck(idx uint64, node, id string) error
DeleteCheck is used to delete a health check registration.
func (*StateStore) DeleteNode ¶
func (s *StateStore) DeleteNode(idx uint64, nodeID string) error
DeleteNode is used to delete a given node by its ID.
func (*StateStore) DeleteService ¶
func (s *StateStore) DeleteService(idx uint64, nodeID, serviceID string) error
DeleteService is used to delete a given service associated with a node.
func (*StateStore) EnsureCheck ¶
func (s *StateStore) EnsureCheck(idx uint64, hc *structs.HealthCheck) error
EnsureCheck is used to store a check registration in the db.
func (*StateStore) EnsureNode ¶
func (s *StateStore) EnsureNode(idx uint64, node *structs.Node) error
EnsureNode is used to upsert node registration or modification.
func (*StateStore) EnsureRegistration ¶
func (s *StateStore) EnsureRegistration(idx uint64, req *structs.RegisterRequest) error
EnsureRegistration is used to make sure a node, service, and check registration is performed within a single transaction to avoid race conditions on state updates.
func (*StateStore) EnsureService ¶
func (s *StateStore) EnsureService(idx uint64, node string, svc *structs.NodeService) error
EnsureService is called to upsert creation of a given NodeService.
func (*StateStore) GetKVSWatch ¶
func (s *StateStore) GetKVSWatch(prefix string) Watch
GetKVSWatch returns a watch for the given prefix in the key value store.
func (*StateStore) GetQueryWatch ¶
func (s *StateStore) GetQueryWatch(method string) Watch
GetQueryWatch returns a watch for the given query method. This is used for all methods except for KV; you should call GetKVSWatch instead. This will panic if the method is unknown.
func (*StateStore) KVSDelete ¶
func (s *StateStore) KVSDelete(idx uint64, key string) error
KVSDelete is used to perform a shallow delete on a single key in the the state store.
func (*StateStore) KVSDeleteCAS ¶
func (s *StateStore) KVSDeleteCAS(idx, cidx uint64, key string) (bool, error)
KVSDeleteCAS is used to try doing a KV delete operation with a given raft index. If the CAS index specified is not equal to the last observed index for the given key, then the call is a noop, otherwise a normal KV delete is invoked.
func (*StateStore) KVSDeleteTree ¶
func (s *StateStore) KVSDeleteTree(idx uint64, prefix string) error
KVSDeleteTree is used to do a recursive delete on a key prefix in the state store. If any keys are modified, the last index is set, otherwise this is a no-op.
func (*StateStore) KVSList ¶
func (s *StateStore) KVSList(prefix string) (uint64, structs.DirEntries, error)
KVSList is used to list out all keys under a given prefix. If the prefix is left empty, all keys in the KVS will be returned. The returned is the max index of the returned kvs entries or applicable tombstones, or else it's the full table indexes for kvs and tombstones.
func (*StateStore) KVSListKeys ¶
func (s *StateStore) KVSListKeys(prefix, sep string) (uint64, []string, error)
KVSListKeys is used to query the KV store for keys matching the given prefix. An optional separator may be specified, which can be used to slice off a part of the response so that only a subset of the prefix is returned. In this mode, the keys which are omitted are still counted in the returned index.
func (*StateStore) KVSLock ¶
KVSLock is similar to KVSSet but only performs the set if the lock can be acquired.
func (*StateStore) KVSLockDelay ¶
func (s *StateStore) KVSLockDelay(key string) time.Time
KVSLockDelay returns the expiration time for any lock delay associated with the given key.
func (*StateStore) KVSSet ¶
func (s *StateStore) KVSSet(idx uint64, entry *structs.DirEntry) error
KVSSet is used to store a key/value pair.
func (*StateStore) KVSSetCAS ¶
KVSSetCAS is used to do a check-and-set operation on a KV entry. The ModifyIndex in the provided entry is used to determine if we should write the entry to the state store or bail. Returns a bool indicating if a write happened and any error.
func (*StateStore) KVSUnlock ¶
KVSUnlock is similar to KVSSet but only performs the set if the lock can be unlocked (the key must already exist and be locked).
func (*StateStore) NodeChecks ¶
func (s *StateStore) NodeChecks(nodeID string) (uint64, structs.HealthChecks, error)
NodeChecks is used to retrieve checks associated with the given node from the state store.
func (*StateStore) NodeDump ¶
func (s *StateStore) NodeDump() (uint64, structs.NodeDump, error)
NodeDump is used to generate a dump of all nodes. This call is expensive as it has to query every node, service, and check. The response can also be quite large since there is currently no filtering applied.
func (*StateStore) NodeInfo ¶
NodeInfo is used to generate a dump of a single node. The dump includes all services and checks which are registered against the node.
func (*StateStore) NodeServices ¶
func (s *StateStore) NodeServices(nodeID string) (uint64, *structs.NodeServices, error)
NodeServices is used to query service registrations by node ID.
func (*StateStore) NodeSessions ¶
NodeSessions returns a set of active sessions associated with the given node ID. The returned index is the highest index seen from the result set.
func (*StateStore) Nodes ¶
func (s *StateStore) Nodes() (uint64, structs.Nodes, error)
Nodes is used to return all of the known nodes.
func (*StateStore) PreparedQueryDelete ¶
func (s *StateStore) PreparedQueryDelete(idx uint64, queryID string) error
PreparedQueryDelete deletes the given query by ID.
func (*StateStore) PreparedQueryGet ¶
func (s *StateStore) PreparedQueryGet(queryID string) (uint64, *structs.PreparedQuery, error)
PreparedQueryGet returns the given prepared query by ID.
func (*StateStore) PreparedQueryList ¶
func (s *StateStore) PreparedQueryList() (uint64, structs.PreparedQueries, error)
PreparedQueryList returns all the prepared queries.
func (*StateStore) PreparedQueryLookup ¶
func (s *StateStore) PreparedQueryLookup(queryIDOrName string) (uint64, *structs.PreparedQuery, error)
PreparedQueryLookup returns the given prepared query by looking up an ID or Name.
func (*StateStore) PreparedQuerySet ¶
func (s *StateStore) PreparedQuerySet(idx uint64, query *structs.PreparedQuery) error
PreparedQuerySet is used to create or update a prepared query.
func (*StateStore) ReapTombstones ¶
func (s *StateStore) ReapTombstones(index uint64) error
ReapTombstones is used to delete all the tombstones with an index less than or equal to the given index. This is used to prevent unbounded storage growth of the tombstones.
func (*StateStore) Restore ¶
func (s *StateStore) Restore() *StateRestore
Restore is used to efficiently manage restoring a large amount of data into the state store. It works by doing all the restores inside of a single transaction.
func (*StateStore) ServiceChecks ¶
func (s *StateStore) ServiceChecks(serviceName string) (uint64, structs.HealthChecks, error)
ServiceChecks is used to get all checks associated with a given service ID. The query is performed against a service _name_ instead of a service ID.
func (*StateStore) ServiceNodes ¶
func (s *StateStore) ServiceNodes(serviceName string) (uint64, structs.ServiceNodes, error)
ServiceNodes returns the nodes associated with a given service name.
func (*StateStore) ServiceTagNodes ¶
func (s *StateStore) ServiceTagNodes(service, tag string) (uint64, structs.ServiceNodes, error)
ServiceTagNodes returns the nodes associated with a given service, filtering out services that don't contain the given tag.
func (*StateStore) Services ¶
func (s *StateStore) Services() (uint64, structs.Services, error)
Services returns all services along with a list of associated tags.
func (*StateStore) SessionCreate ¶
func (s *StateStore) SessionCreate(idx uint64, sess *structs.Session) error
SessionCreate is used to register a new session in the state store.
func (*StateStore) SessionDestroy ¶
func (s *StateStore) SessionDestroy(idx uint64, sessionID string) error
SessionDestroy is used to remove an active session. This will implicitly invalidate the session and invoke the specified session destroy behavior.
func (*StateStore) SessionGet ¶
SessionGet is used to retrieve an active session from the state store.
func (*StateStore) SessionList ¶
func (s *StateStore) SessionList() (uint64, structs.Sessions, error)
SessionList returns a slice containing all of the active sessions.
func (*StateStore) Snapshot ¶
func (s *StateStore) Snapshot() *StateSnapshot
Snapshot is used to create a point-in-time snapshot of the entire db.
type TombstoneGC ¶
type TombstoneGC struct {
// contains filtered or unexported fields
}
TombstoneGC is used to track creation of tombstones so that they can be garbage collected after their TTL expires. The tombstones allow queries to provide monotonic index values within the TTL window. The GC is used to prevent monotonic growth in storage usage. This is a trade off between the length of the TTL and the storage overhead.
In practice, this is required to fix the issue of delete visibility. When data is deleted from the KV store, the "latest" row can go backwards if the newest row is removed. The tombstones provide a way to ensure time doesn't move backwards within some interval.
func NewTombstoneGC ¶
func NewTombstoneGC(ttl, granularity time.Duration) (*TombstoneGC, error)
NewTombstoneGC is used to construct a new TombstoneGC given a TTL for tombstones and a tracking granularity. Longer TTLs ensure correct behavior for more time, but use more storage. A shorter granularity increases the number of Raft transactions and reduce how far past the TTL we perform GC.
func (*TombstoneGC) ExpireCh ¶
func (t *TombstoneGC) ExpireCh() <-chan uint64
ExpireCh is used to return a channel that streams the next index that should be expired
func (*TombstoneGC) Hint ¶
func (t *TombstoneGC) Hint(index uint64)
Hint is used to indicate that keys at the given index have been deleted, and that their GC should be scheduled.
func (*TombstoneGC) PendingExpiration ¶
func (t *TombstoneGC) PendingExpiration() bool
PendingExpiration is used to check if any expirations are pending
func (*TombstoneGC) SetEnabled ¶
func (t *TombstoneGC) SetEnabled(enabled bool)
SetEnabled is used to control if the tombstone GC is enabled. Should only be enabled by the leader node.