* PoC: memory registry using maps instead of slice madness * Updated proto and handlers. Fixed tests across codebase. * Implemented ttl pruning for memory registry * Added extensive memory registry tests * Squased a bunch of bugs * Proto indent; memory.Registry.String() returns "memory" * Write a test to prove memory registry TTLs are busted Signed-off-by: Erik Hollensbe <github@hollensbe.org> * Additional memory testing and fixups: * DefaultTTL removed * When TTL == 0, it is automatically removed from expiry conditions * Additional improvements to new tests Signed-off-by: Erik Hollensbe <github@hollensbe.org>
This commit is contained in:
committed by
Asim Aslam
parent
97c1300f53
commit
4107733453
@@ -8,12 +8,25 @@ import (
|
||||
|
||||
type servicesKey struct{}
|
||||
|
||||
func getServices(ctx context.Context) map[string][]*registry.Service {
|
||||
s, ok := ctx.Value(servicesKey{}).(map[string][]*registry.Service)
|
||||
func getServiceRecords(ctx context.Context) map[string]map[string]*record {
|
||||
memServices, ok := ctx.Value(servicesKey{}).(map[string][]*registry.Service)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
return s
|
||||
|
||||
services := make(map[string]map[string]*record)
|
||||
|
||||
for name, svc := range memServices {
|
||||
if _, ok := services[name]; !ok {
|
||||
services[name] = make(map[string]*record)
|
||||
}
|
||||
// go through every version of the service
|
||||
for _, s := range svc {
|
||||
services[s.Name][s.Version] = serviceToRecord(s, 0)
|
||||
}
|
||||
}
|
||||
|
||||
return services
|
||||
}
|
||||
|
||||
// Services is an option that preloads service data
|
||||
|
||||
Reference in New Issue
Block a user