func()

in pkg/discovery/routing/router.go [159:169]


func (r *router) ResolveWithNegativeCacheCallback(ctx context.Context, key string, allowSelf bool, count int) (<-chan PeerInfo, func(), error) {
	if val, ok := r.lookupCache.Get(key); ok && val.(string) == strPeerNotFound {
		// TODO avtakkar: currently only doing a negative cache, this could maybe become a positive cache as well.
		return nil, nil, ContentNotFoundError{key: key, error: fmt.Errorf("(cached) peer not found for key")}
	}

	peerCh, err := r.Resolve(ctx, key, allowSelf, count)
	return peerCh, func() {
		r.lookupCache.SetWithTTL(key, strPeerNotFound, 1, negCacheTtl)
	}, err
}