resolver

package
v1.25.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

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

func NewRpc(isLocalHost bool, rpcPort int) *Rpc

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

func (cl *Rpc) Address(raftAddr string) (string, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL