package bootstrap import ( "isle/garage" ) // GarageNodes returns a Node for each known garage instance in the network. func (b Bootstrap) GarageNodes() []garage.RemoteNode { var nodes []garage.RemoteNode for _, host := range b.Hosts { nodes = append(nodes, host.GarageNodes()...) } return nodes } // ChooseGarageNode returns a RemoteNode for a garage instance from the network. // It will prefer a garage instance on this particular host, if there is one, // but will otherwise return a random endpoint. func (b Bootstrap) ChooseGarageNode() garage.RemoteNode { thisHost := b.ThisHost() if len(thisHost.Garage.Instances) > 0 { return thisHost.GarageNodes()[0] } for _, node := range b.GarageNodes() { return node } panic("no garage instances configured") }