1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-11-23 21:44:41 +02:00

Add endpoint filter

This commit is contained in:
Asim
2016-04-23 21:24:07 +01:00
parent febe87dfb8
commit ed764ca0b2
2 changed files with 100 additions and 0 deletions

View File

@@ -4,6 +4,25 @@ import (
"github.com/micro/go-micro/registry"
)
// FilterEndpoint is an endpoint based Select Filter which will
// only return services with the endpoint specified.
func FilterEndpoint(name string) Filter {
return func(old []*registry.Service) []*registry.Service {
var services []*registry.Service
for _, service := range old {
for _, ep := range service.Endpoints {
if ep.Name == name {
services = append(services, service)
break
}
}
}
return services
}
}
// FilterLabel is a label based Select Filter which will
// only return services with the label specified.
func FilterLabel(key, val string) Filter {