Documentation
¶
Index ¶
- Constants
- Variables
- func Assignments() map[int]Assignment
- func CheckEpoch(indexName string, epoch int64) error
- func ConstrainChanges(changes, owners map[int]string, nodes []string, eligible map[int][]string) map[int]string
- func DecodeSearchResponse(data []byte) (*meta.SearchResponse, error)
- func EligibleOwners(insync map[string][]string, partitions int) map[int][]string
- func Enabled() bool
- func Health(ctx context.Context, indexes []string) map[string]IndexHealth
- func InSync(ctx context.Context) (map[string][]string, error)
- func IsLeader() bool
- func IsLocalInSync(indexName string) bool
- func IsLocalOwner(indexName string) bool
- func IsLocalReplica(indexName string) bool
- func KeyPrefix() string
- func MergeSearch(responses []*meta.SearchResponse, query *meta.ZedQuery) *meta.SearchResponse
- func NoRedirect(*http.Request, []*http.Request) error
- func NodeAddr(ctx context.Context, id string) (string, bool)
- func Owner(indexName string) (string, int64, bool)
- func PartitionOf(indexName string) int
- func PartitionOfN(indexName string, partitions int) int
- func PlanReplicas(owners map[int]string, nodes []string, n int) map[int][]string
- func Rebalance(current map[int]string, nodes []string, partitions int) map[int]string
- func RebalanceWarm(current map[int]string, replicas map[int][]string, nodes []string, ...) map[int]string
- func Replicas(indexName string) []string
- func ScatterQuery(query *meta.ZedQuery) *meta.ZedQuery
- func Start(ctx context.Context) error
- func StartWith(ctx context.Context, store Store) error
- func Stop()
- func Transport() http.RoundTripper
- func UpdateInSync(ctx context.Context, index string, nodes []string, epoch int64) error
- func WorseHealth(a, b string) string
- type Assigner
- func (a *Assigner) Apply(ctx context.Context, current map[int]Assignment, changes map[int]string, ...) error
- func (a *Assigner) AssignPrefix() string
- func (a *Assigner) ClaimPartitions(ctx context.Context) error
- func (a *Assigner) InSyncKey() string
- func (a *Assigner) List(ctx context.Context) (map[int]Assignment, error)
- func (a *Assigner) ListInSync(ctx context.Context) (map[string][]string, int64, error)
- func (a *Assigner) ListReplicas(ctx context.Context) (map[int][]string, int64, error)
- func (a *Assigner) PartitionsKey() string
- func (a *Assigner) ReplicasKey() string
- func (a *Assigner) Set(ctx context.Context, partition int, owner string, rev int64, guards ...Guard) (Assignment, bool, error)
- func (a *Assigner) SetReplicas(ctx context.Context, replicas map[int][]string, rev int64) (bool, error)
- func (a *Assigner) UpdateInSync(ctx context.Context, index string, nodes []string, epoch int64) error
- type Assignment
- type Coordinator
- type Election
- type EpochError
- type EtcdStore
- func (s *EtcdStore) Close() error
- func (s *EtcdStore) CompareAndSwap(ctx context.Context, key string, value []byte, rev int64, lease LeaseID, ...) (int64, bool, error)
- func (s *EtcdStore) Create(ctx context.Context, key string, value []byte, lease LeaseID) (int64, bool, error)
- func (s *EtcdStore) Delete(ctx context.Context, key string) error
- func (s *EtcdStore) Get(ctx context.Context, key string) (KV, error)
- func (s *EtcdStore) Grant(ctx context.Context, ttl time.Duration) (LeaseID, error)
- func (s *EtcdStore) KeepAlive(ctx context.Context, id LeaseID) error
- func (s *EtcdStore) List(ctx context.Context, prefix string) ([]KV, error)
- func (s *EtcdStore) Put(ctx context.Context, key string, value []byte, lease LeaseID) (int64, error)
- func (s *EtcdStore) Revoke(ctx context.Context, id LeaseID) error
- func (s *EtcdStore) Watch(ctx context.Context, prefix string) (<-chan Event, error)
- type Event
- type EventType
- type Fence
- func (f *Fence) Assignments() map[int]Assignment
- func (f *Fence) CheckEpoch(indexName string, epoch int64) error
- func (f *Fence) IsLocalInSync(indexName string) bool
- func (f *Fence) IsLocalOwner(indexName string) bool
- func (f *Fence) IsLocalReplica(indexName string) bool
- func (f *Fence) NodeID() string
- func (f *Fence) Owner(indexName string) (string, int64, bool)
- func (f *Fence) PartitionCounts() map[string]int
- func (f *Fence) Refresh(ctx context.Context) error
- func (f *Fence) Replicas(indexName string) []string
- func (f *Fence) Run(ctx context.Context, resync time.Duration)
- type Guard
- type IndexHealth
- type KV
- type LeaseID
- type Membership
- func (m *Membership) Addr(id string) (string, bool)
- func (m *Membership) Join(ctx context.Context) error
- func (m *Membership) KeepAlive(ctx context.Context) error
- func (m *Membership) Lease() LeaseID
- func (m *Membership) Leave(ctx context.Context) error
- func (m *Membership) ListNodes(ctx context.Context) ([]Node, error)
- func (m *Membership) Live() bool
- func (m *Membership) NodesPrefix() string
- func (m *Membership) Refresh(ctx context.Context) error
- func (m *Membership) Run(ctx context.Context, resync time.Duration)
- func (m *Membership) Watch(ctx context.Context) (<-chan Event, error)
- type MemoryStore
- func (m *MemoryStore) Close() error
- func (m *MemoryStore) CompareAndSwap(_ context.Context, key string, value []byte, rev int64, lease LeaseID, ...) (int64, bool, error)
- func (m *MemoryStore) Create(_ context.Context, key string, value []byte, lease LeaseID) (int64, bool, error)
- func (m *MemoryStore) Delete(_ context.Context, key string) error
- func (m *MemoryStore) Get(_ context.Context, key string) (KV, error)
- func (m *MemoryStore) Grant(_ context.Context, ttl time.Duration) (LeaseID, error)
- func (m *MemoryStore) KeepAlive(_ context.Context, id LeaseID) error
- func (m *MemoryStore) List(_ context.Context, prefix string) ([]KV, error)
- func (m *MemoryStore) Put(_ context.Context, key string, value []byte, lease LeaseID) (int64, error)
- func (m *MemoryStore) Revoke(_ context.Context, id LeaseID) error
- func (m *MemoryStore) SetClock(now func() time.Time)
- func (m *MemoryStore) Watch(ctx context.Context, prefix string) (<-chan Event, error)
- type Node
- type NodeStatus
- type Store
Constants ¶
const ( HealthGreen = "green" HealthYellow = "yellow" HealthRed = "red" )
Health statuses, named like Elasticsearch names them.
const DefaultPartitions = 256
DefaultPartitions is used when the config leaves the count unset.
const PartialAggName = "_partial"
PartialAggName is the sub-aggregation a node attaches to an average so the coordinator can weight it: {"count": n, "sum": s}.
Variables ¶
var ( // ErrStoreClosed is returned by a store that has already been closed. ErrStoreClosed = errors.New("cluster: store closed") // ErrNotEnabled is returned by cluster calls made while clustering is off. ErrNotEnabled = errors.New("cluster: not enabled") )
var ErrNoOwner = errors.New("cluster: index has no owner")
ErrNoOwner is returned when nothing owns the partition of an index yet, which happens before the first rebalance has been applied.
var ErrNotLive = errors.New("cluster: membership lease may have expired")
ErrNotLive is returned when the local membership lease may have expired, so the ownership map this node sees can be stale.
Functions ¶
func Assignments ¶
func Assignments() map[int]Assignment
Assignments returns the ownership map, empty when clustering is off.
func CheckEpoch ¶
CheckEpoch fails when the partition of indexName moved since epoch was taken. Always nil with clustering disabled.
func ConstrainChanges ¶
func ConstrainChanges(changes, owners map[int]string, nodes []string, eligible map[int][]string) map[int]string
ConstrainChanges drops rebalance moves that would hand a replicated partition to a node that is not in sync. A partition whose owner is dead goes to a live in-sync node instead, or nowhere when there is none.
func DecodeSearchResponse ¶
func DecodeSearchResponse(data []byte) (*meta.SearchResponse, error)
DecodeSearchResponse decodes a response received from another node.
meta.AggregationResponse marshals its sub-aggregations inline but has no matching unmarshaller, so a plain decode silently drops them, including the "_partial" counters. This restores every object key that is not a field of AggregationResponse as a sub-aggregation.
func EligibleOwners ¶
EligibleOwners maps every partition holding a replicated index to the nodes that are in sync for all of its indexes. Partitions without a replicated index are absent: any node may own them.
func Health ¶ added in v1.4.1
func Health(ctx context.Context, indexes []string) map[string]IndexHealth
Health reports the state of every index in indexes. With clustering disabled the single node owns everything and all of them are green. When the cluster state cannot be read nothing is known, and all of them are red.
func IsLeader ¶
func IsLeader() bool
IsLeader reports whether this node currently holds the leader lock.
func IsLocalInSync ¶ added in v1.4.1
IsLocalInSync reports whether this node is in the in-sync set of indexName, false when clustering is off.
func IsLocalOwner ¶
IsLocalOwner reports whether this node may write indexName. A node whose membership lease may have expired owns nothing: its partitions may have been handed to another node it cannot hear from.
func IsLocalReplica ¶
IsLocalReplica reports whether this node is a read replica of indexName. Only indexes every node can open read-only (cold, object storage) may be served from a replica; that check is left to the caller.
func KeyPrefix ¶
func KeyPrefix() string
KeyPrefix is the etcd key prefix every cluster key of this deployment lives under.
func MergeSearch ¶
func MergeSearch(responses []*meta.SearchResponse, query *meta.ZedQuery) *meta.SearchResponse
MergeSearch combines the per-owner responses of a scatter-gather search into the single response the client expects.
Hits are re-sorted globally and cut down to the requested window, counts are summed and aggregations are merged according to the aggregation type taken from the original query, which the owners ran as ScatterQuery. Aggregations that cannot be merged exactly (cardinality, percentiles) keep the first node's value and are logged, they are approximations across nodes. Pipeline aggregations are evaluated here, over the merged buckets.
func NoRedirect ¶ added in v1.4.1
NoRedirect is the CheckRedirect of node to node clients. The internal endpoints never redirect, and following one would hand the caller's Authorization or the cluster secret to a host nobody selected, so the redirect is returned as the response instead.
func NodeAddr ¶
NodeAddr returns the advertised address of a node id. It is answered from the member cache; a miss (a node that just joined) falls back to one read, bounded by ctx and at most five seconds.
func Owner ¶
Owner returns the node owning indexName and the epoch of that ownership. ok is false when clustering is off or the partition is unassigned.
func PartitionOf ¶
PartitionOf maps an index name to its partition using the configured partition count. The mapping is a pure function of the name, so every node computes the same partition without coordination.
func PartitionOfN ¶
PartitionOfN maps an index name onto `partitions` buckets.
func PlanReplicas ¶
PlanReplicas picks n read replicas for every owned partition among the live nodes, never the owner itself. The start node rotates with the partition number, so the replicas of one owner spread over all the others instead of piling onto its ring successor.
func Rebalance ¶
Rebalance spreads `partitions` buckets over `nodes` and returns only the partitions that must move.
Stability is the point: a partition already owned by a live node is left alone unless that node is over quota. Adding or removing a node therefore moves roughly partitions/nodes buckets instead of reshuffling everything.
func RebalanceWarm ¶
func RebalanceWarm(current map[int]string, replicas map[int][]string, nodes []string, partitions int) map[int]string
RebalanceWarm is Rebalance that hands a partition that must move to one of its warm replicas first, as long as that replica is alive and under quota. The replica already serves the partition's reads, so failover lands on a node that is ready instead of a cold one.
func Replicas ¶
Replicas returns the nodes keeping a warm read replica of indexName, empty when clustering is off or `zed_cluster_replicas` is 0.
func ScatterQuery ¶ added in v1.4.1
ScatterQuery is the query every owner runs for a scattered search: the whole window, so the merge can re-sort it, and more terms buckets than asked for, so a term outside the top of one node still counts when it is in the merged top. query is left alone, MergeSearch needs it as asked.
func Start ¶
Start joins the cluster. It is a no-op when clustering is disabled, so callers can call it unconditionally.
func StartWith ¶
StartWith joins the cluster using a caller provided store. Tests use it with a MemoryStore, production goes through Start.
func Stop ¶
func Stop()
Stop leaves the cluster: resign leadership, drop the membership record so peers stop routing here, then close the store.
func Transport ¶ added in v1.4.1
func Transport() http.RoundTripper
Transport is the traced round tripper shared by every node to node call: forwarded requests, scatter-gather searches and replication.
func UpdateInSync ¶
UpdateInSync records the in-sync replicas of an index this node owns, nil drops the entry. epoch is the ownership epoch the caller took over the index at; it fails when the partition is owned by another node, or moved since that epoch. A no-op with clustering disabled.
func WorseHealth ¶ added in v1.4.1
WorseHealth returns the more severe of two statuses.
Types ¶
type Assigner ¶
type Assigner struct {
// contains filtered or unexported fields
}
Assigner reads and writes the partition ownership map.
func NewAssigner ¶
NewAssigner builds an assigner over `<prefix>assign/`.
func (*Assigner) Apply ¶
func (a *Assigner) Apply(ctx context.Context, current map[int]Assignment, changes map[int]string, insyncRev int64) error
Apply writes a rebalance result computed from the in-sync map at insyncRev. Every move is one transaction with that revision: an owner that dropped a replica from the in-sync set meanwhile makes the move fail instead of promoting that replica. Partitions skipped that way, or whose assignment changed under us, are picked up by the next round.
func (*Assigner) AssignPrefix ¶
AssignPrefix is the key prefix every assignment lives under.
func (*Assigner) ClaimPartitions ¶ added in v1.4.1
ClaimPartitions records the partition count of the cluster the first time a node joins and fails for a node configured with another one. Such a node would hash an index to a different partition than its peers, and two nodes could both believe they own it.
func (*Assigner) ListInSync ¶
ListInSync returns index -> in-sync replicas and the revision it was read at.
func (*Assigner) ListReplicas ¶
ListReplicas returns the replica map and the revision it was read at, 0 when it was never written.
func (*Assigner) PartitionsKey ¶ added in v1.4.1
PartitionsKey is the key holding the partition count of the cluster.
func (*Assigner) ReplicasKey ¶
ReplicasKey is the key holding the replica map.
func (*Assigner) Set ¶
func (a *Assigner) Set(ctx context.Context, partition int, owner string, rev int64, guards ...Guard) (Assignment, bool, error)
Set installs owner for a partition. rev is the revision the caller last saw for that partition (0 when it was unassigned); the write is rejected when somebody else changed it meanwhile, which keeps epochs strictly ordered, or when a guard no longer holds.
func (*Assigner) SetReplicas ¶
func (a *Assigner) SetReplicas(ctx context.Context, replicas map[int][]string, rev int64) (bool, error)
SetReplicas writes the replica map when it is still at rev.
func (*Assigner) UpdateInSync ¶
func (a *Assigner) UpdateInSync(ctx context.Context, index string, nodes []string, epoch int64) error
UpdateInSync sets the in-sync replicas of index, nil removes the entry. epoch is the ownership epoch of the caller, 0 while the partition is unassigned; the update fails once the partition moved.
type Assignment ¶
type Assignment struct {
Partition int `json:"partition"`
Owner string `json:"owner"`
Epoch int64 `json:"epoch"`
Replicas []string `json:"replicas,omitempty"`
}
Assignment names the single node that owns a partition.
Epoch is the store revision of the assignment key. It is never written by us, it is filled in from the revision the store reports, so it increases on every handoff and can be used as a fencing token.
type Coordinator ¶
type Coordinator struct {
// contains filtered or unexported fields
}
Coordinator keeps the partition map in shape. Only the leader writes, the others just watch membership so they can take over without delay.
func NewCoordinator ¶
func NewCoordinator(election *Election, membership *Membership, assigner *Assigner, partitions, replicas int, interval time.Duration) *Coordinator
NewCoordinator wires the pieces the rebalance loop needs. replicas is the number of warm read replicas kept per partition.
func (*Coordinator) RebalanceOnce ¶
func (c *Coordinator) RebalanceOnce(ctx context.Context) error
RebalanceOnce recomputes ownership from the live member list, writes the partitions that must move, then the replica map. Orphaned partitions go to a warm replica first. It is a no-op on non-leaders.
func (*Coordinator) Run ¶
func (c *Coordinator) Run(ctx context.Context)
Run rebalances on every membership change and on a slow timer, which covers missed watch events after a reconnect.
type Election ¶
type Election struct {
// contains filtered or unexported fields
}
Election is a lease based leader election on `<prefix>leader`. The winner is whoever manages to create the key; it stays leader as long as it keeps the lease alive. When the process dies the lease expires, the key is removed and the next campaign round elects somebody else.
The leader is only a convenience: it is the node that computes and writes the partition assignment. Correctness of ownership does not depend on there being exactly one leader, every assignment write is a compare-and-swap on the partition key.
func NewElection ¶
NewElection builds an election for nodeID over `<prefix>leader`.
func (*Election) Campaign ¶
Campaign runs one election round: renew leadership when we hold it, else try to take the key. It reports whether the local node is leader after the round.
func (*Election) IsLeader ¶
IsLeader reports whether the local node last won the election and its lease cannot have expired yet: when renewals keep failing, another node may already have taken the key.
func (*Election) Leader ¶
Leader returns the node id currently believed to hold the leadership, empty when it is unknown.
type EpochError ¶
EpochError says the partition of an index moved: the epoch presented by the caller is not the epoch currently recorded in the ownership map.
func (*EpochError) Error ¶
func (e *EpochError) Error() string
type EtcdStore ¶
type EtcdStore struct {
// contains filtered or unexported fields
}
EtcdStore is the production Store, it maps our small interface onto the etcd v3 client. Revisions are etcd mod revisions, which is what makes them usable as fencing tokens.
func NewEtcdStore ¶
NewEtcdStore dials the etcd cluster configured in the [Etcd] section.
func (*EtcdStore) CompareAndSwap ¶
type Fence ¶
type Fence struct {
// contains filtered or unexported fields
}
Fence answers "who owns this index and with which epoch" from a local copy of the ownership map kept current by a watch.
The epoch is the store revision of the assignment key, so it grows on every handoff. A request that started while this node was the owner carries the epoch it saw; if the partition moved meanwhile the epoch no longer matches and the write is rejected with 409.
This closes the transfer window - the interval between the new owner taking the partition and the old owner noticing - it does not roll back an append that already reached the WAL. A write that was accepted before the handoff stays accepted; what is prevented is reporting success for a write whose partition is no longer ours.
func (*Fence) Assignments ¶
func (f *Fence) Assignments() map[int]Assignment
Assignments returns a copy of the ownership map, replicas included.
func (*Fence) CheckEpoch ¶
CheckEpoch fails when the ownership of indexName changed since epoch was taken, or when this node is no longer the owner.
func (*Fence) IsLocalInSync ¶ added in v1.4.1
IsLocalInSync reports whether this node is in the in-sync set of indexName as last seen by the watch: the owner removes a replica that failed a write before acknowledging that write.
func (*Fence) IsLocalOwner ¶
IsLocalOwner reports whether this node owns indexName. An unassigned partition counts as local: before the first rebalance every node serves its own requests, exactly like the single node build does.
func (*Fence) IsLocalReplica ¶
IsLocalReplica reports whether this node is a read replica of indexName.
func (*Fence) Owner ¶
Owner returns the node that owns indexName and the epoch of that ownership. ok is false while the partition is unassigned.
func (*Fence) PartitionCounts ¶
PartitionCounts returns how many partitions each node owns.
type Guard ¶ added in v1.4.1
Guard is an extra condition of a CompareAndSwap: Key must be at Revision, 0 when it must not exist, in the same transaction as the write.
type IndexHealth ¶ added in v1.4.1
type IndexHealth struct {
// Status is red when no live node owns the index, yellow when it is
// replicated to fewer nodes than `zed_cluster_replicas`, else green.
Status string
// Replicas is the number of live in-sync replicas.
Replicas int
// Missing is how many more replicas `zed_cluster_replicas` asks for.
Missing int
}
IndexHealth is the state of one index in the cluster.
type KV ¶
KV is a single key with the store revision of its last write. The revision is the fencing token: it only ever grows for a given key.
type LeaseID ¶
type LeaseID int64
LeaseID identifies a lease held by a node. NoLease means the key is written without a lease and therefore never expires on its own.
const NoLease LeaseID = 0
NoLease is the zero lease, keys written with it are permanent.
type Membership ¶
type Membership struct {
// contains filtered or unexported fields
}
Membership keeps `<prefix>/nodes/<id>` alive under a lease. When the process dies the lease expires and the key disappears, which is how the rest of the cluster learns the node is gone.
func NewMembership ¶
NewMembership builds membership for local under prefix.
func (*Membership) Addr ¶
func (m *Membership) Addr(id string) (string, bool)
Addr returns the cached advertise address of a member. Request routing resolves an owner on every forwarded call, the cache keeps that off etcd.
func (*Membership) Join ¶
func (m *Membership) Join(ctx context.Context) error
Join grants a lease and registers the local node under it.
func (*Membership) KeepAlive ¶
func (m *Membership) KeepAlive(ctx context.Context) error
KeepAlive refreshes the lease once. A lease that the store no longer knows about (expired during a network partition) is replaced by re-joining, so a node that comes back always reappears in the member list.
func (*Membership) Lease ¶
func (m *Membership) Lease() LeaseID
Lease returns the lease currently backing the local node record.
func (*Membership) Leave ¶
func (m *Membership) Leave(ctx context.Context) error
Leave revokes the lease, which removes the node record. The key is not deleted by name: a newer process with the same id may own it by now.
func (*Membership) ListNodes ¶
func (m *Membership) ListNodes(ctx context.Context) ([]Node, error)
ListNodes returns every live node, sorted by id so every node computes the same rebalance result from the same input.
func (*Membership) Live ¶
func (m *Membership) Live() bool
Live reports whether the local node record cannot have expired yet: once renewals keep failing past the ttl, the partitions may already be owned by another node.
func (*Membership) NodesPrefix ¶
func (m *Membership) NodesPrefix() string
NodesPrefix is the key prefix every node record lives under.
func (*Membership) Refresh ¶
func (m *Membership) Refresh(ctx context.Context) error
Refresh replaces the cached member list with a full read.
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-process Store used by tests. Lease expiry is driven by a pluggable clock so TTL behaviour can be exercised without sleeping.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore returns an empty store using the wall clock.
func (*MemoryStore) Close ¶
func (m *MemoryStore) Close() error
func (*MemoryStore) CompareAndSwap ¶
func (*MemoryStore) KeepAlive ¶
func (m *MemoryStore) KeepAlive(_ context.Context, id LeaseID) error
func (*MemoryStore) SetClock ¶
func (m *MemoryStore) SetClock(now func() time.Time)
SetClock replaces the clock used for lease expiry, for deterministic tests.
type Node ¶
type Node struct {
ID string `json:"id"`
Addr string `json:"addr"`
StartedAt int64 `json:"started_at"` // unix milliseconds
}
Node is one zedsearch process in the cluster.
type NodeStatus ¶
type NodeStatus struct {
ID string `json:"id"`
Addr string `json:"addr"`
Alive bool `json:"alive"`
Partitions int `json:"partitions"`
IsLeader bool `json:"is_leader"`
}
NodeStatus is one row of `GET /api/cluster/nodes`.
func Nodes ¶
func Nodes() []NodeStatus
Nodes lists the cluster members. With clustering disabled it reports the single local process, so callers do not need a special case.
type Store ¶
type Store interface {
// Grant creates a lease that expires after ttl unless kept alive.
Grant(ctx context.Context, ttl time.Duration) (LeaseID, error)
// KeepAlive refreshes a lease once, it must be called more often than the ttl.
KeepAlive(ctx context.Context, id LeaseID) error
// Revoke drops a lease and every key attached to it.
Revoke(ctx context.Context, id LeaseID) error
// Put writes key unconditionally and returns the new revision.
Put(ctx context.Context, key string, value []byte, lease LeaseID) (int64, error)
// Get returns a single key, errors.ErrKeyNotFound when it is absent.
Get(ctx context.Context, key string) (KV, error)
// List returns every key under prefix, sorted by key.
List(ctx context.Context, prefix string) ([]KV, error)
// Delete removes a key, removing a missing key is not an error.
Delete(ctx context.Context, key string) error
// Create writes key only when it does not exist yet. It reports whether
// the write happened; when it did not, the returned revision belongs to
// the value that is already there.
Create(ctx context.Context, key string, value []byte, lease LeaseID) (int64, bool, error)
// CompareAndSwap writes key only when its current revision is rev and
// every guard holds. Use rev == 0 to require that the key does not exist.
CompareAndSwap(ctx context.Context, key string, value []byte, rev int64, lease LeaseID, guards ...Guard) (int64, bool, error)
// Watch streams changes under prefix until ctx is done.
Watch(ctx context.Context, prefix string) (<-chan Event, error)
// Close releases the underlying connection.
Close() error
}
Store is the small slice of a consistent key value store the cluster needs: leases for liveness, revisions for fencing, prefix watches for change notification. It is implemented by etcd in production and by an in-memory store in tests.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package replication keeps the data of every index on more than one node, following the three OpenSearch replication paths:
|
Package replication keeps the data of every index on more than one node, following the three OpenSearch replication paths: |