feta/archiver.go

34 lines
525 B
Go
Raw Normal View History

2019-10-24 12:14:36 +00:00
package main
2019-11-02 06:56:17 +00:00
import "time"
2019-10-24 12:14:36 +00:00
type InstanceHostName string
2019-11-02 06:56:17 +00:00
type TootArchiver struct {
2019-10-24 12:14:36 +00:00
locator *InstanceLocator
instances map[InstanceHostName]*Instance
startup *time.Time
}
2019-11-02 06:56:17 +00:00
func NewTootArchiver() *TootArchiver {
a := new(TootArchiver)
2019-10-24 12:14:36 +00:00
return a
}
2019-11-02 06:56:17 +00:00
func (a *TootArchiver) Uptime() time.Duration {
2019-10-24 12:41:05 +00:00
return time.Since(*a.startup)
}
2019-10-24 12:14:36 +00:00
2019-11-02 06:56:17 +00:00
func (a *TootArchiver) RunForever() int {
2019-10-24 12:41:05 +00:00
t := time.Now()
a.startup = &t
a.locator = NewInstanceLocator()
go a.locator.Locate()
for {
time.Sleep(1 * time.Second)
}
2019-10-24 12:41:05 +00:00
return 0
2019-10-24 12:14:36 +00:00
}