address

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoteAddressAvail added in v1.0.0

func RemoteAddressAvail(address string, timeout time.Duration) bool

RemoteAddressAvail checks if remote address can be connected.

Types

type Address

type Address struct {
	// ListenAddress listen address
	ListenAddress string `toml:"listen-address"`
	// ServiceAddress service address
	ServiceAddress string `toml:"service-addresss"`
}

Address is used to describe the address of a MO running service, divided into 2 addresses, ListenAddress and ServiceAddress.

ListenAddress is used to indicate the address of the service listener, used to accept external connections.

ServiceAddress is used to register to the HAKeeper address, other nodes can get this address to connect to this MO's service

TODO(fagongzi): refactor all address configurations in MO.

func (*Address) Adjust

func (addr *Address) Adjust(
	machineHost string,
	defaultListenAddress string)

Adjust adjust address according to the rules: 1. If ListenAddress is not set, then use defaultListenAddress 2. if ServiceAddress is not set, then use ListenAddress 3. if machineHost is set, then replace the host of ServiceAddress with machineHost

type AddressManager added in v1.0.0

type AddressManager interface {
	// Register registers a service by its name and port slot.
	Register(portSlot int)
	// ListenAddress returns the service address of the service.
	ListenAddress(slot int) string
	// ServiceAddress returns the service address of the service.
	ServiceAddress(slot int) string
}

AddressManager manages all service names and ports. It uses unified listen address and service address. The port of each service is generated by port base and the port slot.

func NewAddressManager added in v1.0.0

func NewAddressManager(serviceAddress string, portBase int) AddressManager

Jump to

Keyboard shortcuts

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