Download this file
| 1 | package registry |
| 2 | |
| 3 | import "os" |
| 4 | |
| 5 | // ArtifactHosts discovers candidates; it supplies no installation authority. |
| 6 | // Include orphan and inactive timers. Due-time filtering would hide obligations. |
| 7 | func (r *Registry) ArtifactHosts() ([]string, error) { |
| 8 | if r.remote != nil { |
| 9 | out, err := r.remote.call(nil, remoteRequest{Method: "ArtifactHosts"}, nil) |
| 10 | return out.Hosts, err |
| 11 | } |
| 12 | rows, err := r.sql.Query(`SELECT host FROM routes UNION SELECT host FROM timers ORDER BY host LIMIT 8193`) |
| 13 | if err != nil { |
| 14 | return nil, err |
| 15 | } |
| 16 | defer rows.Close() |
| 17 | var hosts []string |
| 18 | for rows.Next() { |
| 19 | var host string |
| 20 | if err := rows.Scan(&host); err != nil { |
| 21 | return nil, err |
| 22 | } |
| 23 | if len(hosts) == 8192 { |
| 24 | return nil, os.ErrPermission |
| 25 | } |
| 26 | hosts = append(hosts, host) |
| 27 | } |
| 28 | if err := rows.Err(); err != nil { |
| 29 | return nil, err |
| 30 | } |
| 31 | return hosts, nil |
| 32 | } |
| 33 | |