diff --git a/internal/cache/cache.go b/internal/cache/cache.go index 76edebf2344..741b8fd9cb3 100644 --- a/internal/cache/cache.go +++ b/internal/cache/cache.go @@ -30,7 +30,7 @@ type cache[V any] struct { cacher cacher.Type expireDur time.Duration expireCheckDur time.Duration - expiredHook func(context.Context, string) + expiredHook func(context.Context, string, V) } // New returns the Cache instance or error. diff --git a/internal/cache/gache/gache.go b/internal/cache/gache/gache.go index 246d70ae95b..6f56beba387 100644 --- a/internal/cache/gache/gache.go +++ b/internal/cache/gache/gache.go @@ -29,7 +29,7 @@ type cache[V any] struct { gache gache.Gache[V] expireDur time.Duration expireCheckDur time.Duration - expiredHook func(context.Context, string) + expiredHook func(context.Context, string, V) } // New loads a cache model and returns a new cache struct. diff --git a/internal/cache/gache/option.go b/internal/cache/gache/option.go index 7f3a617d1ee..d6022f9ba69 100644 --- a/internal/cache/gache/option.go +++ b/internal/cache/gache/option.go @@ -42,7 +42,7 @@ func WithGache[V any](g gache.Gache[V]) Option[V] { } // WithExpiredHook returns Option after set expiredHook when f is not nil. -func WithExpiredHook[V any](f func(context.Context, string)) Option[V] { +func WithExpiredHook[V any](f func(context.Context, string, V)) Option[V] { return func(c *cache[V]) { if f != nil { c.expiredHook = f diff --git a/internal/cache/option.go b/internal/cache/option.go index ef5a7583ae0..08966d60787 100644 --- a/internal/cache/option.go +++ b/internal/cache/option.go @@ -36,7 +36,7 @@ func defaultOptions[V any]() []Option[V] { } // WithExpiredHook returns Option after set expiredHook when f is not nil. -func WithExpiredHook[V any](f func(context.Context, string)) Option[V] { +func WithExpiredHook[V any](f func(context.Context, string, V)) Option[V] { return func(c *cache[V]) { if f != nil { c.expiredHook = f diff --git a/internal/core/algorithm/ngt/ngt_test.go b/internal/core/algorithm/ngt/ngt_test.go index 240e1f7b8ae..74b7c5d98c4 100644 --- a/internal/core/algorithm/ngt/ngt_test.go +++ b/internal/core/algorithm/ngt/ngt_test.go @@ -780,7 +780,7 @@ func Test_gen(t *testing.T) { objectType: Uint8, mu: &sync.RWMutex{}, cmu: &sync.RWMutex{}, - smu: &sync.Mutex{}, + smu: &sync.Mutex{}, epl: DefaultErrorBufferLimit, }, }, diff --git a/internal/net/dialer.go b/internal/net/dialer.go index c01ecc5927b..d7159bb40d2 100644 --- a/internal/net/dialer.go +++ b/internal/net/dialer.go @@ -454,7 +454,7 @@ func (d *dialer) tlsHandshake( return tconn, nil } -func (d *dialer) cacheExpireHook(ctx context.Context, addr string) { +func (d *dialer) cacheExpireHook(ctx context.Context, addr string, _ *dialerCache) { if err := safety.RecoverFunc(func() (err error) { _, err = d.lookup(ctx, addr) return diff --git a/internal/net/dialer_test.go b/internal/net/dialer_test.go index 22183ede9e8..9c6261aa0cc 100644 --- a/internal/net/dialer_test.go +++ b/internal/net/dialer_test.go @@ -1516,7 +1516,8 @@ func Test_dialer_dial(t *testing.T) { func Test_dialer_cacheExpireHook(t *testing.T) { t.Parallel() type args struct { - addr string + addr string + cache *dialerCache } type want struct{} type test struct { @@ -1585,7 +1586,7 @@ func Test_dialer_cacheExpireHook(t *testing.T) { test.beforeFunc(d) } - d.cacheExpireHook(ctx, test.args.addr) + d.cacheExpireHook(ctx, test.args.addr, test.args.cache) if err := checkFunc(d); err != nil { tt.Errorf("error = %v", err) }