Closed srl295 closed 8 years ago
That seems like it makes sense; it would be extending the functionality of getServices()
, and fills a niche of finding services that match some kind of spec. Should it be the same kind of spec as getService()
?
Yes, I'd think the same kind of spec. Maybe returning a map like { "MyService-abc": { stuff..}, "MyService-bcd": {stuff…}}
I guess it would be useful for you to see if just filtering the result is easy enough. See https://tonicdev.com/pmuellr/get-services-spec for an example of filtering the results with underscore.pick()
.
Here's the code from the tonic:
const us = require("underscore")
const services = {a:"1", b:"2", c:"3"}
console.log(us.pick(services, (val,key)=>key.match(/a|b/)))
console.log(us.pick(services, ["b", "c"]))
I don't really have the cycles for this. If someone does want to add it, submit a PR:
@pmuellr looks easy enough wiht pick()
, thanks.
getServices()
returns all services.Could it take an optional
spec
parameter with a regex?Then if I bind against a bunch of
MyService-abc
,MyService-bcd
, ... I can dogetServices(/MyService-.*/)
to use a user-provided service to set a list.