package http import ( "context" "errors" "git.diulo.com/mogfee/kit/registry" "git.diulo.com/mogfee/kit/selector" "net/url" "strings" ) type Target struct { Scheme string Authority string Endpoint string } func parseTarget(endpoint string, insecure bool) (*Target, error) { if !strings.Contains(endpoint, "://") { if insecure { endpoint = "http://" + endpoint } else { endpoint = "https://" + endpoint } } u, err := url.Parse(endpoint) if err != nil { return nil, err } target := &Target{ Scheme: u.Scheme, Authority: u.Host, Endpoint: "", } if len(u.Path) > 1 { target.Endpoint = u.Path[1:] } return target, nil } type resolver struct { rebalancer selector.Rebalancer target *Target watcher registry.Watcher insecure bool } func newResolver(ctx context.Context, discovery registry.Discovery, target *Target, rebalancer selector.Rebalancer, block, insecure bool) (*resolver, error) { //watcher, err := discovery.Watch(ctx, target.Endpoint) //if err != nil { // return nil, err //} //r := &resolver{ // rebalancer: rebalancer, // target: target, // watcher: watcher, // insecure: insecure, //} //if block { // done := make(chan error, 1) // go func() { // for { // services, err := watcher.Next() // if err != nil { // done <- err // return // } // } // }() //} return nil, errors.New("un impl") } func (r *resolver) update() { } func (r *resolver) Close() error { return r.watcher.Stop() }