Add framework for remote liveness check
This commit is contained in:
parent
d7181b1cf6
commit
5337ea544b
@ -13,12 +13,21 @@ type RemoteInfo struct {
|
|||||||
Token string
|
Token string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RemoteProto string
|
||||||
|
|
||||||
|
const (
|
||||||
|
RemoteProtoSSH RemoteProto = "ssh"
|
||||||
|
RemoteProtoHTTP RemoteProto = "http"
|
||||||
|
RemoteProtoHTTPS RemoteProto = "https"
|
||||||
|
)
|
||||||
|
|
||||||
// Any remote needs to be able to return
|
// Any remote needs to be able to return
|
||||||
// the number of projects the user has access to and also
|
// the number of projects the user has access to and also
|
||||||
// stream all projects along with updates to channels
|
// stream all projects along with updates to channels
|
||||||
// provided by *load.ProgressInfo
|
// provided by *load.ProgressInfo
|
||||||
type Remote interface {
|
type Remote interface {
|
||||||
GetInfo() *RemoteInfo
|
GetInfo() *RemoteInfo // Returns basic RemoteInfo struct
|
||||||
GetNumProjects(*RemoteQueryOpts) int
|
IsAlive(RemoteProto) bool // Indicates if the remote is reachable by either SSH or HTTP
|
||||||
StreamProjects(*load.ProgressInfo, *RemoteQueryOpts)
|
GetNumProjects(*RemoteQueryOpts) int // Returns total number of accessible projects
|
||||||
|
StreamProjects(*load.ProgressInfo, *RemoteQueryOpts) // Streams projects to chans provided in load.ProgressInfo
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,15 @@ func (r *Remotes) AddRemote(remote remote.Remote) {
|
|||||||
*r = append(*r, remote)
|
*r = append(*r, remote)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Remotes) GetRemoteByHost(host string) remote.Remote {
|
||||||
|
for _, remote := range *r {
|
||||||
|
if remote.GetInfo().Host == host {
|
||||||
|
return remote
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Launches project streamsers for all remotes in goroutines
|
// Launches project streamsers for all remotes in goroutines
|
||||||
// returns slice of load.ProgressInfo
|
// returns slice of load.ProgressInfo
|
||||||
func (r *Remotes) StreamRemotes(opts *remote.RemoteQueryOpts) []*load.ProgressInfo {
|
func (r *Remotes) StreamRemotes(opts *remote.RemoteQueryOpts) []*load.ProgressInfo {
|
||||||
|
Loading…
Reference in New Issue
Block a user