Documentation
¶
Index ¶
- Constants
- type AddrCluster
- func (ac AddrCluster) Addr() netip.Addr
- func (ac AddrCluster) As20() (ac20 [20]byte)
- func (ac AddrCluster) AsNetIP() net.IP
- func (in *AddrCluster) DeepCopy() *AddrCluster
- func (in *AddrCluster) DeepCopyInto(out *AddrCluster)
- func (ac0 *AddrCluster) DeepEqual(ac1 *AddrCluster) bool
- func (ac0 AddrCluster) Equal(ac1 AddrCluster) bool
- func (ac AddrCluster) Is4() bool
- func (ac AddrCluster) Is6() bool
- func (ac AddrCluster) IsUnspecified() bool
- func (ac0 AddrCluster) Less(ac1 AddrCluster) bool
- func (ac AddrCluster) String() string
Constants ¶
const ( // ClusterIDMin is the minimum value of the cluster ID ClusterIDMin = 0 // ClusterIDMax is the maximum value of the cluster ID ClusterIDMax = 255 )
const AddrClusterLen = 20
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddrCluster ¶
type AddrCluster struct {
// contains filtered or unexported fields
}
AddrCluster is a type that holds a pair of IP and ClusterID. We should use this type as much as possible when we implement IP + Cluster addressing. We should avoid managing IP and ClusterID separately. Otherwise, it is very hard for code readers to see where we are using cluster-aware addressing.
func AddrClusterFromIP ¶
func AddrClusterFromIP(ip net.IP) (AddrCluster, bool)
AddrClusterFromIP parses the given net.IP using ip.AddrFromIP and returns AddrCluster with ClusterID = 0.
func MustAddrClusterFromIP ¶
func MustAddrClusterFromIP(ip net.IP) AddrCluster
func MustParseAddrCluster ¶
func MustParseAddrCluster(s string) AddrCluster
MustParseAddrCluster calls ParseAddr(s) and panics on error. It is intended for use in tests with hard-coded strings.
func ParseAddrCluster ¶
func ParseAddrCluster(s string) (AddrCluster, error)
ParseAddrCluster parses s as an IP + ClusterID and returns AddrCluster. The string s can be a bare IP string (any IP address format allowed in netip.ParseAddr()) or IP string + @ + ClusterID with decimal. Bare IP string is considered as IP string + @ + ClusterID = 0.
func (AddrCluster) Addr ¶
func (ac AddrCluster) Addr() netip.Addr
Addr returns IP address part of AddrCluster as netip.Addr. This function exists for keeping backward compatibility between the existing components which are not aware of the cluster-aware addressing. Calling this function against the AddrCluster which has non-zero clusterID will lose the ClusterID information. It should be used with an extra care.
func (AddrCluster) As20 ¶
func (ac AddrCluster) As20() (ac20 [20]byte)
As20 returns the AddrCluster in its 20-byte representation which consists of 16-byte IP address part from netip.Addr.As16 and 4-byte ClusterID part.
func (AddrCluster) AsNetIP ¶
func (ac AddrCluster) AsNetIP() net.IP
AsNetIP returns the IP address part of AddCluster as a net.IP type. This function exists for keeping backward compatibility between the existing components which are not aware of the cluster-aware addressing. Calling this function against the AddrCluster which has non-zero clusterID will lose the ClusterID information. It should be used with an extra care.
func (*AddrCluster) DeepCopy ¶
func (in *AddrCluster) DeepCopy() *AddrCluster
DeepCopy returns a new copy of AddrCluster
func (*AddrCluster) DeepCopyInto ¶
func (in *AddrCluster) DeepCopyInto(out *AddrCluster)
DeepCopyInto copies in to out
func (*AddrCluster) DeepEqual ¶
func (ac0 *AddrCluster) DeepEqual(ac1 *AddrCluster) bool
This is an alias of Equal which only exists for satisfying deepequal-gen
func (AddrCluster) Equal ¶
func (ac0 AddrCluster) Equal(ac1 AddrCluster) bool
Equal returns true when given AddrCluster has a same IP address and ClusterID
func (AddrCluster) Is4 ¶
func (ac AddrCluster) Is4() bool
Is4 reports whether IP address part of AddrCluster is an IPv4 address.
func (AddrCluster) Is6 ¶
func (ac AddrCluster) Is6() bool
Is6 reports whether IP address part of AddrCluster is an IPv6 address.
func (AddrCluster) IsUnspecified ¶
func (ac AddrCluster) IsUnspecified() bool
IsUnspecified reports whether IP address part of the AddrCluster is an unspecified address, either the IPv4 address "0.0.0.0" or the IPv6 address "::".
func (AddrCluster) Less ¶
func (ac0 AddrCluster) Less(ac1 AddrCluster) bool
Less compares ac0 and ac1 and returns true if ac0 is lesser than ac1
func (AddrCluster) String ¶
func (ac AddrCluster) String() string
String returns the string representation of the AddrCluster. If AddrCluster.clusterID = 0, it returns bare IP address string. Otherwise, it returns IP string + "@" + ClusterID (e.g. 10.0.0.1@1)