2015-04-22 08:00:15 +00:00
|
|
|
package queue
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
|
2015-05-17 20:51:42 +00:00
|
|
|
common "github.com/drone/drone/pkg/types"
|
2015-04-22 08:00:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Work represents an item for work to be
|
|
|
|
// processed by a worker.
|
|
|
|
type Work struct {
|
2015-09-02 23:14:25 +00:00
|
|
|
System *common.System `json:"system"`
|
|
|
|
User *common.User `json:"user"`
|
|
|
|
Repo *common.Repo `json:"repo"`
|
|
|
|
Build *common.Build `json:"build"`
|
|
|
|
Keys *common.Keypair `json:"keypair"`
|
|
|
|
Netrc *common.Netrc `json:"netrc"`
|
2015-09-07 19:13:27 +00:00
|
|
|
Config []byte `json:"config"`
|
|
|
|
Secret []byte `json:"secret"`
|
2015-04-22 08:00:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// represents a worker that has connected
|
|
|
|
// to the system in order to perform work
|
|
|
|
type Worker struct {
|
|
|
|
Name string
|
|
|
|
Addr string
|
|
|
|
IsHealthy bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ping pings to worker to verify it is
|
|
|
|
// available and in good health.
|
|
|
|
func (w *Worker) Ping() (bool, error) {
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Logs fetches the logs for a work item.
|
|
|
|
func (w *Worker) Logs() (io.Reader, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cancel cancels a work item.
|
|
|
|
func (w *Worker) Cancel() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// type Monitor struct {
|
|
|
|
// manager *Manager
|
|
|
|
// }
|
|
|
|
|
|
|
|
// func NewMonitor(manager *Manager) *Monitor {
|
|
|
|
// return &Monitor{manager}
|
|
|
|
// }
|
|
|
|
|
|
|
|
// // start is a helper function that is used to monitor
|
|
|
|
// // all registered workers and ensure they are in a
|
|
|
|
// // healthy state.
|
|
|
|
// func (m *Monitor) Start() {
|
|
|
|
// ticker := time.NewTicker(1 * time.Hour)
|
|
|
|
// go func() {
|
|
|
|
// for {
|
|
|
|
// select {
|
|
|
|
// case <-ticker.C:
|
|
|
|
// workers := m.manager.Workers()
|
|
|
|
// for _, worker := range workers {
|
|
|
|
// // ping the worker to make sure it is
|
|
|
|
// // available and still accepting builds.
|
|
|
|
// if _, err := worker.Ping(); err != nil {
|
|
|
|
// m.manager.SetHealth(worker, false)
|
|
|
|
// } else {
|
|
|
|
// m.manager.SetHealth(worker, true)
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|