Skip to content

Commit

Permalink
Fix dns option
Browse files Browse the repository at this point in the history
  • Loading branch information
pipe01 committed Feb 23, 2024
1 parent 32d63b2 commit 1926253
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions discovery/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"time"

"github.com/MouseHatGames/mice/discovery"
"github.com/MouseHatGames/mice/options"
"github.com/patrickmn/go-cache"
)

Expand All @@ -22,18 +23,21 @@ func MaxAge(d time.Duration) Option {
}
}

func Discovery(inner discovery.Discovery, opts ...Option) discovery.Discovery {
cd := &cacheDiscovery{
inner: inner,
maxAge: 5 * time.Minute,
}
func Discovery(inner discovery.Discovery, opts ...Option) options.Option {
return func(o *options.Options) {
cd := &cacheDiscovery{
inner: inner,
maxAge: 5 * time.Minute,
}

for _, opt := range opts {
opt(cd)
}
for _, opt := range opts {
opt(cd)
}

cd.cache = cache.New(cd.maxAge, 5*time.Minute)
return cd
cd.cache = cache.New(cd.maxAge, 5*time.Minute)

o.Discovery = cd
}
}

func (c *cacheDiscovery) Find(svc string) (host string, err error) {
Expand Down

0 comments on commit 1926253

Please sign in to comment.