Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRaft ¶
func NewRaft(cfg RaftConfig) *raft
Types ¶
type NodeToAddress ¶
type NodeToAddress interface { // NodeAddress resolves node id into an ip address without the port. NodeAddress(id string) string }
NodeToAddress allows the resolver to compute node-id to ip addresses.
type RaftConfig ¶
type RaftConfig struct { NodeToAddress NodeToAddress RaftPort int IsLocalHost bool NodeNameToPortMap map[string]int }
type Rpc ¶
type Rpc struct {
// contains filtered or unexported fields
}
Rpc implements resolving raft address to their RPC address depending on the configured rpcPort and whether or not this is a local cluster.
func NewRpc ¶
NewRpc returns an implementation of resolver isLocalHost is used to determine which remote port to expect given an address (See: rpcResolver.rpcAddressFromRAFT()) rpcPort is used as the default port on the returned rpcAddresses (see: rpcResolver.Address())
func (*Rpc) Address ¶
rpcAddressFromRAFT returns the FQDN raft address (rpcAddr:rpcPort) based on raftAddr (raftAddr:raftPort). In a real cluster, the RPC port is the same for all nodes. In a local environment, the RPC ports need to be different. Specifically, we calculate the RPC port as the RAFT port + 1. Returns an error if raftAddr is not parseable. Returns an error if raftAddr port is not parse-able as an integer.