47 lines
903 B
Go
47 lines
903 B
Go
package feta
|
|
|
|
import "time"
|
|
|
|
type InstanceHostname string
|
|
|
|
type TootArchiver struct {
|
|
locator *InstanceLocator
|
|
manager *InstanceManager
|
|
startup *time.Time
|
|
}
|
|
|
|
func NewTootArchiver() *TootArchiver {
|
|
a := new(TootArchiver)
|
|
return a
|
|
}
|
|
|
|
func (a *TootArchiver) Uptime() time.Duration {
|
|
return time.Since(*a.startup)
|
|
}
|
|
|
|
func (a *TootArchiver) RunForever() {
|
|
t := time.Now()
|
|
a.startup = &t
|
|
|
|
newInstanceHostnameNotifications := make(chan InstanceHostname, 10000)
|
|
|
|
a.locator = NewInstanceLocator()
|
|
|
|
a.manager = NewInstanceManager()
|
|
|
|
a.locator.AddInstanceNotificationChannel(newInstanceHostnameNotifications)
|
|
a.manager.AddInstanceNotificationChannel(newInstanceHostnameNotifications)
|
|
|
|
// locator goroutine:
|
|
go a.locator.Locate()
|
|
|
|
// manager goroutine:
|
|
go a.manager.Manage()
|
|
|
|
// this goroutine (main) does nothing until we handle signals
|
|
// FIXME(sneak)
|
|
for {
|
|
time.Sleep(1 * time.Second)
|
|
}
|
|
}
|