Documentation ¶
Overview ¶
Package address provides functions for working with "happy" addresses, which are URL-like strings that define the location of a resource in the "happy" system. It includes functions for parsing and resolving addresses, as well as methods for converting addresses to strings and checking the format of addresses. The package also provides a convenient way to get the current application's address in the "happy" system.
Index ¶
Constants ¶
const (
// MustCompile against following expression.
Regexp = "^[a-z][a-z0-9-./]*[a-z0-9]$"
)
Variables ¶
var (
ErrAddr = errors.New("address")
)
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
Address represents a happy address in the form of happy://host/instance/path. The happy address is a scheme-based URL that defines the location of a module or service within a service mesh.
func CurrentForDepth ¶
Current returns format of current application happy proto address.
func FromModule ¶
FromModule returns a new Address created from the given go module path. If the module is empty, the resulting address will be an empty address. If the module is not an empty string, it must be a valid module path that conforms to Go's package name syntax and will be used to create a new address.
func Parse ¶
Parse takes a string address and returns a new Address instance. If the address is not valid, an error is returned.
func (*Address) Parse ¶
Parse takes a string representation of an address and returns a pointer to a new Address struct. If the input string is not a valid representation of an address, an error is returned.
func (*Address) ResolveService ¶
ResolveService returns the resolved service Adddress for the given network and instance address. If the address cannot be resolved, it returns an error.
func (*Address) ReverseDNS ¶ added in v0.15.0
func (*Address) String ¶
String reassembles the Address into a valid URL string. The general form of the result is one of:
happy://userinfo@host/path?query#fragment
Any non-ASCII characters in host are escaped. To obtain the path, String uses net.URL.EscapedPath().
In the second form, the following rules apply:
- if u.User is nil, userinfo@ is omitted.
- if u.Host is non-empty and u.Path begins with a /, the form host/path does not add its own /.
- if u.RawQuery is empty, ?query is omitted.
- if u.Fragment is empty, #fragment is omitted.