2016-08-30 02:09:57 +00:00
|
|
|
package structs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/raft"
|
|
|
|
)
|
|
|
|
|
2016-08-30 18:30:56 +00:00
|
|
|
// RaftServer has information about a server in the Raft configuration.
|
|
|
|
type RaftServer struct {
|
|
|
|
// ID is the unique ID for the server. These are currently the same
|
|
|
|
// as the address, but they will be changed to a real GUID in a future
|
|
|
|
// release of Consul.
|
|
|
|
ID raft.ServerID
|
|
|
|
|
|
|
|
// Node is the node name of the server, as known by Consul, or this
|
|
|
|
// will be set to "(unknown)" otherwise.
|
|
|
|
Node string
|
|
|
|
|
|
|
|
// Address is the IP:port of the server, used for Raft communications.
|
|
|
|
Address raft.ServerAddress
|
|
|
|
|
|
|
|
// Leader is true if this server is the current cluster leader.
|
|
|
|
Leader bool
|
|
|
|
|
|
|
|
// Voter is true if this server has a vote in the cluster. This might
|
|
|
|
// be false if the server is staging and still coming online, or if
|
|
|
|
// it's a non-voting server, which will be added in a future release of
|
|
|
|
// Consul.
|
|
|
|
Voter bool
|
|
|
|
}
|
|
|
|
|
2016-08-30 02:09:57 +00:00
|
|
|
// RaftConfigrationResponse is returned when querying for the current Raft
|
2016-08-30 18:30:56 +00:00
|
|
|
// configuration.
|
2016-08-30 02:09:57 +00:00
|
|
|
type RaftConfigurationResponse struct {
|
2016-08-30 18:30:56 +00:00
|
|
|
// Servers has the list of servers in the Raft configuration.
|
|
|
|
Servers []*RaftServer
|
|
|
|
|
|
|
|
// Index has the Raft index of this configuration.
|
|
|
|
Index uint64
|
2016-08-30 02:09:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// RaftPeerByAddressRequest is used by the Operator endpoint to apply a Raft
|
|
|
|
// operation on a specific Raft peer by address in the form of "IP:port".
|
|
|
|
type RaftPeerByAddressRequest struct {
|
|
|
|
// Datacenter is the target this request is intended for.
|
|
|
|
Datacenter string
|
|
|
|
|
|
|
|
// Address is the peer to remove, in the form "IP:port".
|
|
|
|
Address raft.ServerAddress
|
|
|
|
|
|
|
|
// WriteRequest holds the ACL token to go along with this request.
|
|
|
|
WriteRequest
|
|
|
|
}
|
|
|
|
|
|
|
|
// RequestDatacenter returns the datacenter for a given request.
|
|
|
|
func (op *RaftPeerByAddressRequest) RequestDatacenter() string {
|
|
|
|
return op.Datacenter
|
|
|
|
}
|