github.com/outbrain/consul@v1.4.5/agent/structs/operator.go (about)

     1  package structs
     2  
     3  import (
     4  	"net"
     5  
     6  	"github.com/hashicorp/consul/agent/consul/autopilot"
     7  	"github.com/hashicorp/raft"
     8  )
     9  
    10  // RaftServer has information about a server in the Raft configuration.
    11  type RaftServer struct {
    12  	// ID is the unique ID for the server. These are currently the same
    13  	// as the address, but they will be changed to a real GUID in a future
    14  	// release of Consul.
    15  	ID raft.ServerID
    16  
    17  	// Node is the node name of the server, as known by Consul, or this
    18  	// will be set to "(unknown)" otherwise.
    19  	Node string
    20  
    21  	// Address is the IP:port of the server, used for Raft communications.
    22  	Address raft.ServerAddress
    23  
    24  	// Leader is true if this server is the current cluster leader.
    25  	Leader bool
    26  
    27  	// Protocol version is the raft protocol version used by the server
    28  	ProtocolVersion string
    29  
    30  	// Voter is true if this server has a vote in the cluster. This might
    31  	// be false if the server is staging and still coming online, or if
    32  	// it's a non-voting server, which will be added in a future release of
    33  	// Consul.
    34  	Voter bool
    35  }
    36  
    37  // RaftConfigurationResponse is returned when querying for the current Raft
    38  // configuration.
    39  type RaftConfigurationResponse struct {
    40  	// Servers has the list of servers in the Raft configuration.
    41  	Servers []*RaftServer
    42  
    43  	// Index has the Raft index of this configuration.
    44  	Index uint64
    45  }
    46  
    47  // RaftRemovePeerRequest is used by the Operator endpoint to apply a Raft
    48  // operation on a specific Raft peer by address in the form of "IP:port".
    49  type RaftRemovePeerRequest struct {
    50  	// Datacenter is the target this request is intended for.
    51  	Datacenter string
    52  
    53  	// Address is the peer to remove, in the form "IP:port".
    54  	Address raft.ServerAddress
    55  
    56  	// ID is the peer ID to remove.
    57  	ID raft.ServerID
    58  
    59  	// WriteRequest holds the ACL token to go along with this request.
    60  	WriteRequest
    61  }
    62  
    63  // RequestDatacenter returns the datacenter for a given request.
    64  func (op *RaftRemovePeerRequest) RequestDatacenter() string {
    65  	return op.Datacenter
    66  }
    67  
    68  // AutopilotSetConfigRequest is used by the Operator endpoint to update the
    69  // current Autopilot configuration of the cluster.
    70  type AutopilotSetConfigRequest struct {
    71  	// Datacenter is the target this request is intended for.
    72  	Datacenter string
    73  
    74  	// Config is the new Autopilot configuration to use.
    75  	Config autopilot.Config
    76  
    77  	// CAS controls whether to use check-and-set semantics for this request.
    78  	CAS bool
    79  
    80  	// WriteRequest holds the ACL token to go along with this request.
    81  	WriteRequest
    82  }
    83  
    84  // RequestDatacenter returns the datacenter for a given request.
    85  func (op *AutopilotSetConfigRequest) RequestDatacenter() string {
    86  	return op.Datacenter
    87  }
    88  
    89  // (Enterprise-only) NetworkSegment is the configuration for a network segment, which is an
    90  // isolated serf group on the LAN.
    91  type NetworkSegment struct {
    92  	// Name is the name of the segment.
    93  	Name string
    94  
    95  	// Bind is the bind address for this segment.
    96  	Bind *net.TCPAddr
    97  
    98  	// Advertise is the advertise address of this segment.
    99  	Advertise *net.TCPAddr
   100  
   101  	// RPCListener is whether to bind a separate RPC listener on the bind address
   102  	// for this segment.
   103  	RPCListener bool
   104  }