Skip to content

Commit

Permalink
fix: return results from resolve once
Browse files Browse the repository at this point in the history
Previously, we'd return the error + result, then the result.
  • Loading branch information
Stebalien committed Jun 18, 2020
1 parent 84341d0 commit 0f3bc65
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions namesys/namesys.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,12 @@ func (ns *mpns) resolveOnceAsync(ctx context.Context, name string, options opts.
key := segments[2]

if p, ok := ns.cacheGet(key); ok {
var err error
if len(segments) > 3 {
var err error
p, err = path.FromSegments("", strings.TrimRight(p.String(), "/"), segments[3])
if err != nil {
emitOnceResult(ctx, out, onceResult{value: p, err: err})
}
}

out <- onceResult{value: p}
out <- onceResult{value: p, err: err}
close(out)
return out
}
Expand Down Expand Up @@ -183,17 +180,15 @@ func (ns *mpns) resolveOnceAsync(ctx context.Context, name string, options opts.
best = res
}
p := res.value
err := res.err
ttl := res.ttl

// Attach rest of the path
if len(segments) > 3 {
var err error
p, err = path.FromSegments("", strings.TrimRight(p.String(), "/"), segments[3])
if err != nil {
emitOnceResult(ctx, out, onceResult{value: p, ttl: res.ttl, err: err})
}
}

emitOnceResult(ctx, out, onceResult{value: p, ttl: res.ttl, err: res.err})
emitOnceResult(ctx, out, onceResult{value: p, ttl: ttl, err: err})
case <-ctx.Done():
return
}
Expand Down

0 comments on commit 0f3bc65

Please sign in to comment.