change id to name in resolver
This commit is contained in:
		| @@ -1,4 +1,4 @@ | ||||
| // Package dns resolves ids to dns srv records | ||||
| // Package dns resolves names to dns srv records | ||||
| package dns | ||||
|  | ||||
| import ( | ||||
| @@ -11,8 +11,8 @@ import ( | ||||
| type Resolver struct{} | ||||
|  | ||||
| // Resolve assumes ID is a domain name e.g micro.mu | ||||
| func (r *Resolver) Resolve(id string) ([]*resolver.Record, error) { | ||||
| 	_, addrs, err := net.LookupSRV("network", "udp", id) | ||||
| func (r *Resolver) Resolve(name string) ([]*resolver.Record, error) { | ||||
| 	_, addrs, err := net.LookupSRV("network", "udp", name) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| // Package http resolves ids to network addresses using a http request | ||||
| // Package http resolves names to network addresses using a http request | ||||
| package http | ||||
|  | ||||
| import ( | ||||
| @@ -18,8 +18,8 @@ type Resolver struct { | ||||
| 	Path string | ||||
| } | ||||
|  | ||||
| // Resolve assumes ID is a domain which can be converted to a http://id/network request | ||||
| func (r *Resolver) Resolve(id string) ([]*resolver.Record, error) { | ||||
| // Resolve assumes ID is a domain which can be converted to a http://name/network request | ||||
| func (r *Resolver) Resolve(name string) ([]*resolver.Record, error) { | ||||
| 	proto := "http" | ||||
| 	path := "/network" | ||||
|  | ||||
| @@ -34,7 +34,7 @@ func (r *Resolver) Resolve(id string) ([]*resolver.Record, error) { | ||||
| 	uri := &url.URL{ | ||||
| 		Scheme: proto, | ||||
| 		Path:   path, | ||||
| 		Host:   id, | ||||
| 		Host:   name, | ||||
| 	} | ||||
|  | ||||
| 	rsp, err := http.Get(uri.String()) | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| // Package registry resolves ids using the go-micro registry | ||||
| // Package registry resolves names using the go-micro registry | ||||
| package registry | ||||
|  | ||||
| import ( | ||||
| @@ -12,13 +12,13 @@ type Resolver struct { | ||||
| } | ||||
|  | ||||
| // Resolve assumes ID is a domain name e.g micro.mu | ||||
| func (r *Resolver) Resolve(id string) ([]*resolver.Record, error) { | ||||
| func (r *Resolver) Resolve(name string) ([]*resolver.Record, error) { | ||||
| 	reg := r.Registry | ||||
| 	if reg == nil { | ||||
| 		reg = registry.DefaultRegistry | ||||
| 	} | ||||
|  | ||||
| 	services, err := reg.GetService(id) | ||||
| 	services, err := reg.GetService(name) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|   | ||||
| @@ -1,12 +1,12 @@ | ||||
| // Package resolver resolves network ids to addresses | ||||
| // Package resolver resolves network names to addresses | ||||
| package resolver | ||||
|  | ||||
| // Resolver is network resolver. It's used to find network nodes | ||||
| // via id to connect to. This is done based on Network.Id(). | ||||
| // via the name to connect to. This is done based on Network.Name(). | ||||
| // Before we can be part of any network, we have to connect to it. | ||||
| type Resolver interface { | ||||
| 	// Resolve returns a list of addresses for an id | ||||
| 	Resolve(id string) ([]*Record, error) | ||||
| 	// Resolve returns a list of addresses for an name | ||||
| 	Resolve(name string) ([]*Record, error) | ||||
| } | ||||
|  | ||||
| // A resolved record | ||||
|   | ||||
		Reference in New Issue
	
	Block a user