move reg util to own package (#1523)

* move reg util to own package

* fix test

* fix broken static router
This commit is contained in:
Asim Aslam 2020-04-10 17:41:10 +01:00 committed by Vasiliy Tolstov
parent 031e2fbfcb
commit 58cd0f660f

View File

@ -9,6 +9,7 @@ import (
"github.com/micro/go-micro/v2/logger"
"github.com/micro/go-micro/v2/registry"
util "github.com/micro/go-micro/v2/util/registry"
)
// Cache is the registry cache interface
@ -119,7 +120,7 @@ func (c *cache) get(service string) ([]*registry.Service, error) {
// get cache ttl
ttl := c.ttls[service]
// make a copy
cp := registry.Copy(services)
cp := util.Copy(services)
// got services && within ttl so return cache
if c.isValid(cp, ttl) {
@ -152,7 +153,7 @@ func (c *cache) get(service string) ([]*registry.Service, error) {
// cache results
c.Lock()
c.set(service, registry.Copy(services))
c.set(service, util.Copy(services))
c.Unlock()
return services, nil