266
}
267
268
>
func (w *perNamespaceWorker) getWorkerAllocation(args refreshArgs) (workerAllocation, error) {
pernamespaceworker.go
269
>
if args.count < 0 {
270
return workerAllocation{}, errInvalidConfiguration
272
return workerAllocation{0, 0}, nil
273
}
275
>
if err != nil {
276
return workerAllocation{}, err
277
}
279
}
280
281
>
func (w *perNamespaceWorker) getLocallyDesiredWorkers(args refreshArgs) (int, error) {
pernamespaceworker.go
282
>
key := args.ns.ID().String()
283
>
availableHosts := w.wm.serviceResolver.LookupN(key, args.count)
284
>
hostsCount := len(availableHosts)
285
>
if hostsCount == 0 {
286
return 0, membership.ErrInsufficientHosts
287
}
289
>
desiredDistribution := util.RepeatSlice(availableHosts, maxWorkersPerHost)[:args.count]
290
>
291
>
isLocal := func(info membership.HostInfo) bool { return info.Identity() == w.wm.self.Identity() }
292
>
result := len(util.FilterSlice(desiredDistribution, isLocal))
293
>
return result, nil
294
}
295