orbiter
orbiter copied to clipboard
Optimize by querying by ID
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
This is a good catch @bjwschaap thanks!