orbiter icon indicating copy to clipboard operation
orbiter copied to clipboard

Optimize by querying by ID

Open bjwschaap opened this issue 6 years ago • 1 comments

You don't need to fetch and loop through all services in the Swarm @ https://github.com/gianarb/orbiter/blob/e8753183828181303209d4152319717be22927a9/autoscaler/autoscaler.go#L56

Instead you can add a filter, and fetch the required service directly. E.g.:

serviceFilter := filters.NewArgs()
serviceFilter.Add("id", serviceId)
services, err := dockerClient.ServiceList(ctx, types.ServiceListOptions{Filters: serviceFilter})

Also see: https://docs.docker.com/engine/reference/commandline/service_ls/#filtering

bjwschaap avatar Jul 20 '18 11:07 bjwschaap

This is a good catch @bjwschaap thanks!

gianarb avatar Jul 20 '18 12:07 gianarb