change id to name in resolver

This commit is contained in:
Asim Aslam 2019-07-28 20:00:09 +01:00
parent 2b5bf1154a
commit 5b327ce723
4 changed files with 14 additions and 14 deletions

View File

@ -1,4 +1,4 @@
// Package dns resolves ids to dns srv records // Package dns resolves names to dns srv records
package dns package dns
import ( import (
@ -11,8 +11,8 @@ import (
type Resolver struct{} type Resolver struct{}
// Resolve assumes ID is a domain name e.g micro.mu // 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) {
_, addrs, err := net.LookupSRV("network", "udp", id) _, addrs, err := net.LookupSRV("network", "udp", name)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -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 package http
import ( import (
@ -18,8 +18,8 @@ type Resolver struct {
Path string Path string
} }
// Resolve assumes ID is a domain which can be converted to a http://id/network request // Resolve assumes ID is a domain which can be converted to a http://name/network request
func (r *Resolver) Resolve(id string) ([]*resolver.Record, error) { func (r *Resolver) Resolve(name string) ([]*resolver.Record, error) {
proto := "http" proto := "http"
path := "/network" path := "/network"
@ -34,7 +34,7 @@ func (r *Resolver) Resolve(id string) ([]*resolver.Record, error) {
uri := &url.URL{ uri := &url.URL{
Scheme: proto, Scheme: proto,
Path: path, Path: path,
Host: id, Host: name,
} }
rsp, err := http.Get(uri.String()) rsp, err := http.Get(uri.String())

View File

@ -1,4 +1,4 @@
// Package registry resolves ids using the go-micro registry // Package registry resolves names using the go-micro registry
package registry package registry
import ( import (
@ -12,13 +12,13 @@ type Resolver struct {
} }
// Resolve assumes ID is a domain name e.g micro.mu // 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 reg := r.Registry
if reg == nil { if reg == nil {
reg = registry.DefaultRegistry reg = registry.DefaultRegistry
} }
services, err := reg.GetService(id) services, err := reg.GetService(name)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -1,12 +1,12 @@
// Package resolver resolves network ids to addresses // Package resolver resolves network names to addresses
package resolver package resolver
// Resolver is network resolver. It's used to find network nodes // 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. // Before we can be part of any network, we have to connect to it.
type Resolver interface { type Resolver interface {
// Resolve returns a list of addresses for an id // Resolve returns a list of addresses for an name
Resolve(id string) ([]*Record, error) Resolve(name string) ([]*Record, error)
} }
// A resolved record // A resolved record